# synarere -- a trivial, highly modular IRC bot.
# Copyright (C) 2010 Michael Rodriguez.
# Rights to this code are documented in ../docs/LICENSE.

'''Example module.'''

# Import required source module.
from src import modules

def on_topic(conn, origin, parv):
    '''Handle the TOPIC command.'''

    pass

def cmd_currtopic(conn, (nick, user, host), target, message):
    '''Handle the .currtopic command.'''

    pass

def cmdme_currtopic(conn, (nick, user, host), target, message):
    '''Handle the <user> <nick>: currtopic command.'''

    pass

def cmd_topicchan(conn, (nick, user, host), message):
    '''Handle the topicchan command.'''

    pass

def ctcp_dingdong(conn, (nick, user, host), message):
    '''Handle the CTCP 'dingdong' command.'''

    pass

def module_init():
    '''Module entry point.'''

    # There are several types of commands you may create.
    # The following are available:
    #
    # irc_cmd -- Raw IRC commands. AWAY, KICK, etc.
    # chan_cmd -- Channel commands, for example: '.register'.
    # chanme_cmd -- Same as chan_cmd, except the bot's nick is prepended. Example: <user> synarere: register
    # priv_cmd -- Private message commands.
    # ctcp_cmd -- CTCP commands.
    #
    # NOTE: For irc_cmd, these are top priority, so you should use modules.create_first() instead of modules.create()!
    modules.create_first('TOPIC', on_topic, modules.irc_cmd)
    modules.create('.currtopic', cmd_currtopic, modules.chan_cmd)
    modules.create('currtopic', cmdme_currtopic, modules.chanme_cmd)
    modules.create('topicchan', cmd_topicchan, modules.priv_cmd)
    modules.create('DINGDONG', ctcp_dingdong, modules.ctcp_cmd)

def module_fini():
    '''Module exit point.'''

    # NOTE: You must destroy all you created, else memory will be used unnecessarily!
    modules.destroy_first('TOPIC', on_topic, modules.irc_cmd)
    modules.destroy('.currtopic', cmd_currtopic, modules.chan_cmd)
    modules.destroy('currtopic', cmdme_currtopic, modules.chanme_cmd)
    modules.destroy('topicchan', cmd_topicchan, modules.priv_cmd)
    modules.destroy('DINGDONG', ctcp_dingdong, modules.ctcp_cmd)
