1
### This file is part of KoFooBot and is licensed under BSD-license according to the   ###
2
### LICENSE file in the base directory.                                                ###
3
### Code in this file is contributed by:                                               ###
4
###    Krister Svanlund <krister.svanlund gmail.com>                                   ###
5
6
status_settings = { }
7
8
do_status_command = {'description': "Display current stats about the bot",
9
                     'long help': """\
10
Display information that could be of interest about current variable state in the bot.
11
""",
12
                     'public': False,
13
                     'level': 20}
14
15
def do_status(self, server, sender, target, args):
16
    print "Show information about the bot."
17
    channel_string = ""
18
    user_string = ""
19
    stat_string = ""
20
    trigger_string = ""
21
    for channel in self.settings.bot_channel_list:
22
        channel_string += "  %s\n" % channel
23
    for user, level in self.settings.bot_user_list.iteritems():
24
        user_string += "  %s  %d\n" % (user, level)
25
    stat_string = """\
26
Nickname: %(nick)s
27
Quit message: %(quit)s
28
Server: %(server)s
29
Channels:
30
%(channels)s
31
Users:
32
%(users)s""" % \
33
        {'nick': self.settings.bot_nick_name,
34
         'quit': self.settings.bot_quit_message,
35
         'server': "%s : %d" % (self.settings.bot_irc_server, self.settings.bot_irc_port),
36
         'channels': channel_string,
37
         'users': user_string}
38
    self.respond(server, sender, target, stat_string)    
39
40
41
### Handle CTCP requests according to: http://www.irchelp.org/irchelp/rfc/ctcpspec.html ###
42
def status_ctcp_handler(bot, server, sender, msg):
43
    from irclib import nm_to_n
44
    sender_nick = nm_to_n(sender)
45
    args = msg.split()
46
    print "Got CTCP request '%s'." % args[0]
47
    if args[0] == "ACTION":
48
        pass
49
    elif args[0] == "VERSION":
50
        #server.ctcp(sender, "VERSION", "KoFoBot:0.0.1:Ubuntu")
51
        version_string = "VERSION %s %s" % ("KoFoBot", bot.globals.bot_version)
52
        server.ctcp_reply(sender_nick, version_string)
53
        print " + Return version"
54
    elif args[0] == "FINGER":
55
        finger_string = "FINGER %s %s" % ("KoFoBot", "http://gitorious.org/kofoobot")
56
        server.ctcp_reply(sender_nick, finger_string)
57
        print " + Return finger info"
58
    elif args[0] == "CLIENTINFO":
59
        info_string = "CLIENTINFO %s" % "VERSION FINGER"
60
        server.ctcp_reply(sender_nick, info_string)
61
        print " + Sending clientinfo"
62
    else:
63
        error_string = "ERRMSG %s" % "Unknown query"
64
        server.ctcp_reply(sender_nick, error_string)
65
        print " + Could not answer to query."