-
+ 77C9615F3F5C06B35198259CE46F3C7447DDB952A196DA8002AA874124C4E5391B1C46AD0EEE62902234996AFBF5771F677C1EDC70BD5DC0355C11133704ACC1knobs/router.py(0 . 0)(1 . 45)
94 """
95 Import your custom command modules here
96 (alternatively, you -could- put all your command handling scripts in the
97 router() class below, but that could prove messy over time)
98 """
99 from commands import ping_pong, bot_help
100
101 class router:
102 """
103 Each function in this class beginning with 'cmd_' represents a command for logbot.
104
105 Functions intending to be used as callable bot commands MUST use the following format:
106 'cmd_[command to be issued from irc](self, target, source, command_arguments)'
107 source = *irc nick* that issued command
108 target = *where* the irc nick issued the command
109 command_arguments = string representing everything *to the right of* the command issued (to be parsed or ignored as you wish)
110
111 Example:
112 Say you have a knobs.config.bot_command_prefix value of '!G'
113 Someone issuing '!Gping randomgibberish' in #example-irc-channel-where-logbot-is-sitting
114 will trigger main.py to call cmd_ping(), passing ' randomgibberish' to command_arguments.
115
116 In the example above, cmd_ping() just ignores the ' randomgibberish' and simply passes the target and source data to ping_pong.pong() function.
117 However, you could instead choose to parse the 'randomgibberish' and do things with it.
118
119 Hint: You have two easy ways to send command responses back to a target irc channel or nick:
120 1) Use postgres_interfacing.send_to_outbox(target, payload)
121 Directly inserts a record into the 'outbox' table (this is the 'raw' function)
122 2) Use postgres_interfacing.irc_reply(self, target, source, payload)
123 Target and source will be validated before sending data to the 'outbox' table (recommended in most cases)
124 """
125 def cmd_ping(self, target, source, command_arguments):
126 my_pingpong = ping_pong.ping_pong()
127 my_pingpong.reply(target, source, command_arguments)
128
129 def cmd_help(self, target, source, command_arguments):
130 my_bot_help = bot_help.bot_help()
131 my_bot_help.reply(target, source, command_arguments)
132
133 def passive(self, target, source, message):
134 """
135 If knobs.config.route_all_notifications is set to 'True', then main.py will route ALL 'non-command' messages through this function.
136 Useful for, e.g. log-quoters and archive bots
137 """
138 pass