Changeset 25 for trunk/amazonbot


Ignore:
Timestamp:
02/16/07 13:09:02 (17 years ago)
Author:
atzm
Message:
  • Add reload command and fixed a bug occured when config has invalid regexp
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/amazonbot/amazonbot.py

    r23 r25  
    246246                continue 
    247247 
    248             match = re.search(unicoding(config.get(action, 'input_pattern')), msg) 
     248            pattern = unicoding(config.get(action, 'input_pattern')) 
     249            match   = None 
     250            try: 
     251                match = re.search(pattern, msg) 
     252            except: 
     253                _debug('Invalid regexp: %s', pattern) 
     254                continue 
     255 
    249256            if not match: 
    250257                continue 
     
    298305        return 'AmazonBot by %s, based on python-irclib' % __author__ 
    299306 
     307    def onmsg_reload(self, c, e, to, args): 
     308        """Syntax: !reload 
     309        """ 
     310        _debug('in reload command: %s', str(args)) 
     311        config.read() 
     312        c.notice(to, 'reloaded config') 
     313        return True 
     314 
    300315    def onmsg_lt(self, c, e, to, args): return self.onmsg_localtime(c, e, to, args) 
    301316    def onmsg_localtime(self, c, e, to, args): 
Note: See TracChangeset for help on using the changeset viewer.