|
@@ -83,10 +83,46 @@ class LocationBot(ircbot.SingleServerIRCBot):
|
|
|
|
|
|
self.__latitude.start()
|
|
|
|
|
|
+ def __help(self, connection, nick, admin, arguments):
|
|
|
+ connection.privmsg(nick, 'Command Arguments Description')
|
|
|
+
|
|
|
+ commands = [
|
|
|
+ ('help', '', 'show this help message'),
|
|
|
+ ('login', 'user secret', 'login as user with secret'),
|
|
|
+ ('register', 'user secret', 'register as user with secret'),
|
|
|
+ ('status', '[user]', 'show where everybody or a user is'),
|
|
|
+ ]
|
|
|
+
|
|
|
+ if True:
|
|
|
+ commands += [
|
|
|
+ ('latitude', '[id]', 'shortcut for !set latitude [id]'),
|
|
|
+ ('set', '[key [value]]', 'display or set variables'),
|
|
|
+ ('unset', 'key', 'unset a variable'),
|
|
|
+ ]
|
|
|
+
|
|
|
+ if admin:
|
|
|
+ commands += [
|
|
|
+ ('restart', '', 'quit and join running more up to date code'),
|
|
|
+ ('say', 'channel message', 'say message in channel'),
|
|
|
+ ]
|
|
|
+
|
|
|
+ commands.sort()
|
|
|
+
|
|
|
+ for command in commands:
|
|
|
+ connection.privmsg(nick, '!%-10s %-16s %s' % command)
|
|
|
+
|
|
|
def __restart(self, connection):
|
|
|
connection.disconnect('Restarting')
|
|
|
os.execvp(sys.argv[0], sys.argv)
|
|
|
|
|
|
+ def __say(self, connection, nick, arguments):
|
|
|
+ try:
|
|
|
+ channel, message = arguments.split(None, 1)
|
|
|
+
|
|
|
+ connection.privmsg(channel, message)
|
|
|
+ except ValueError:
|
|
|
+ self.__help(connection, nick, True, 'say')
|
|
|
+
|
|
|
def __unknown(self, connection, nick, command):
|
|
|
connection.privmsg(nick, 'unknown command (%s); try "!help"' % command)
|
|
|
|
|
@@ -138,34 +174,12 @@ class LocationBot(ircbot.SingleServerIRCBot):
|
|
|
command = command[1:]
|
|
|
|
|
|
if command == 'help':
|
|
|
- connection.privmsg(nick, 'Command Arguments Description')
|
|
|
-
|
|
|
- commands = [
|
|
|
- ('help', '', 'show this help message'),
|
|
|
- ('login', 'user secret', 'login as user with secret'),
|
|
|
- ('register', 'user secret', 'register as user with secret'),
|
|
|
- ('status', '[user]', 'show where everybody or a user is'),
|
|
|
- ]
|
|
|
-
|
|
|
- if True:
|
|
|
- commands += [
|
|
|
- ('latitude', '[id]', 'shortcut for !set latitude [id]'),
|
|
|
- ('set', '[key [value]]', 'display or set variables'),
|
|
|
- ('unset', 'key', 'unset a variable'),
|
|
|
- ]
|
|
|
-
|
|
|
- if admin:
|
|
|
- commands += [
|
|
|
- ('restart', '', 'quit and join running more up to date code'),
|
|
|
- ]
|
|
|
-
|
|
|
- commands.sort()
|
|
|
-
|
|
|
- for command in commands:
|
|
|
- connection.privmsg(nick, '!%-10s %-16s %s' % command)
|
|
|
+ self.__help(connection, nick, admin, arguments)
|
|
|
elif admin:
|
|
|
if command == 'restart':
|
|
|
self.__restart(connection)
|
|
|
+ elif command == 'say':
|
|
|
+ self.__say(connection, nick, arguments)
|
|
|
else:
|
|
|
self.__unknown(connection, nick, command)
|
|
|
else:
|