raw
logbot_command_ro...    1 """
logbot_command_ro... 2 Import your custom command modules here
logbot_command_ro... 3 (alternatively, you -could- put all your command handling scripts in the
logbot_command_ro... 4 router() class below, but that could prove messy over time)
logbot_command_ro... 5 """
logbot_command_ro... 6 from commands import ping_pong, bot_help
logbot_command_ro... 7
logbot_command_ro... 8 class router:
logbot_command_ro... 9 """
logbot_command_ro... 10 Each function in this class beginning with 'cmd_' represents a command for logbot.
logbot_command_ro... 11
logbot_command_ro... 12 Functions intending to be used as callable bot commands MUST use the following format:
logbot_command_ro... 13 'cmd_[command to be issued from irc](self, target, source, command_arguments)'
logbot_command_ro... 14 source = *irc nick* that issued command
logbot_command_ro... 15 target = *where* the irc nick issued the command
logbot_command_ro... 16 command_arguments = string representing everything *to the right of* the command issued (to be parsed or ignored as you wish)
logbot_command_ro... 17
logbot_command_ro... 18 Example:
logbot_command_ro... 19 Say you have a knobs.config.bot_command_prefix value of '!G'
logbot_command_ro... 20 Someone issuing '!Gping randomgibberish' in #example-irc-channel-where-logbot-is-sitting
logbot_command_ro... 21 will trigger main.py to call cmd_ping(), passing ' randomgibberish' to command_arguments.
logbot_command_ro... 22
logbot_command_ro... 23 In the example above, cmd_ping() just ignores the ' randomgibberish' and simply passes the target and source data to ping_pong.pong() function.
logbot_command_ro... 24 However, you could instead choose to parse the 'randomgibberish' and do things with it.
logbot_command_ro... 25
logbot_command_ro... 26 Hint: You have two easy ways to send command responses back to a target irc channel or nick:
logbot_command_ro... 27 1) Use postgres_interfacing.send_to_outbox(target, payload)
logbot_command_ro... 28 Directly inserts a record into the 'outbox' table (this is the 'raw' function)
logbot_command_ro... 29 2) Use postgres_interfacing.irc_reply(self, target, source, payload)
logbot_command_ro... 30 Target and source will be validated before sending data to the 'outbox' table (recommended in most cases)
logbot_command_ro... 31 """
logbot_command_ro... 32 def cmd_ping(self, target, source, command_arguments):
logbot_command_ro... 33 my_pingpong = ping_pong.ping_pong()
logbot_command_ro... 34 my_pingpong.reply(target, source, command_arguments)
logbot_command_ro... 35
logbot_command_ro... 36 def cmd_help(self, target, source, command_arguments):
logbot_command_ro... 37 my_bot_help = bot_help.bot_help()
logbot_command_ro... 38 my_bot_help.reply(target, source, command_arguments)
logbot_command_ro... 39
logbot_command_ro... 40 def passive(self, target, source, message):
logbot_command_ro... 41 """
logbot_command_ro... 42 If knobs.config.route_all_notifications is set to 'True', then main.py will route ALL 'non-command' messages through this function.
logbot_command_ro... 43 Useful for, e.g. log-quoters and archive bots
logbot_command_ro... 44 """
logbot_command_ro... 45 pass