Newer
Older
# guppy Copyright (C) 2010-2011 guppy team members.
#
# This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
# This is free software, and you are welcome to redistribute it
# under certain conditions; type `show c' for details.
# Provides a help command that lists all commands and functions ~Nat (DrKabob)
@plugin
class Help(object):
'''help module, no params'''
def __init__(self, server):
self.server = server
self.commands = [ "help" ]
self.server.handle("command", self.handle_command, self.commands)
self.server.handle("join", self.handle_join)
def handle_command(self, channel, user, cmd, args):
if cmd == "help":
print(args) # ['FIRST', 'SECOND']
if args == []:
self.server.doMessage(user, "All commands can be sent in a private message to the bot, or a channel message beginning with "
+ self.server.config["comchar"] + " or " + self.server.config["nickname"] + ":")
self.server.doMessage(user, "Commands are:")
lines = (len(self.server.handlers["command"]) / 10) + 1
commandlines = []
commands = list(self.server.handlers["command"].keys())
i = 0
while (i < lines):
line = ""
j = 0
while (j < 10):
try:
command = commands.pop()
line = line + command + " "
j += 1
except IndexError:
break
commandlines.append(line)
i += 1
for commandline in commandlines:
self.server.doMessage(user, commandline)
def handle_join(self, channel, user):
self.server.doNotice(user, "Hello! My name is " + self.server.config["nickname"] + ". If you want a list of commands, type " +
self.server.config["comchar"] + "help")