~aj00200/bbottheircbot/bbottheircbot8

« back to all changes in this revision

Viewing changes to modules/BBot.py

  • Committer: AJ00200
  • Date: 2011-04-18 21:52:14 UTC
  • Revision ID: aj0020020@live.com-20110418215214-hrmup0i4gftafijs
BBot 7.0.2 - Added a quit command with a customizable message, quit-message in the config file, and added it to the bbot-makeconf file.
Also fixed a bug in statusbot.py causing it to not properly handle nicks with non-lowercase characters.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    dict = {}
24
24
 
25
25
class Module(api.Module):
 
26
    # Setup module constants
26
27
    goog_str = 'https://encrypted.google.com/search?q=%s'
27
28
    wiki_str = 'https://secure.wikimedia.org/wikipedia/en/wiki/%s'
28
29
    stop_words = [
32
33
        ' was ', ' are ', ' am '
33
34
    ]
34
35
 
 
36
    # Load settings from the config file
 
37
    quit_message = api.get_config_str('main', 'quit-message')
 
38
 
35
39
    def __init__(self, server):
36
40
        super(Module, self).__init__(server)
37
41
 
49
53
        api.hook_command('wiki', self.wiki, server)
50
54
        # Hook Superuser Commands
51
55
        api.hook_command('join', self.su_join, server, su = True)
 
56
        api.hook_command('quit', self.su_quit, server, su = True)
 
57
        api.hook_command('part', self.su_part, server, su = True)
52
58
        api.hook_command('writedb', self.su_writedb, server, su = True)
53
59
        api.hook_command('raw', self.su_raw, server, su = True)
54
 
        api.hook_command('part', self.su_part, server, su = True)
55
60
        api.hook_command('add', self.su_add, server, su = True)
56
61
        api.hook_command('load', self.su_load, server, su = True)
57
62
        api.hook_command('reload', self.su_reload, server, su = True)
198
203
        else:
199
204
            self.msg(channel, '%s: you need to specify a channel' % nick)
200
205
 
 
206
    def su_quit(self, nick, channel, param = None):
 
207
        '''Quit; Parameters: an optional quit message'''
 
208
        if param:
 
209
            self.raw('QUIT :%s' % param)
 
210
        else:
 
211
            self.raw('QUIT :%s' % self.quit_message)
 
212
 
201
213
    def su_add(self, nick, channel, param = None):
202
214
        '''Add a factoid; Parameters: a factoid name and a factoid body seperated by ":::" - For example, ?add test:::%n: it works!'''
203
215
        if param: