Beispiel #1
0
 def dispatch(self, origin, args):
     # origin.sender = nick when PM, else chan
     bytes, event, args = args[0], args[1], args[2:]
     msg = decode(bytes)
     if event == 'KICK' and args[1] == self.nick:
         self.logger('KICKED from ' + args[0])
         self.kicked = True
         self.joinch(args[0])
     elif event == '251':
         self.startup()
     elif event == '366':
         self.logger('joined ' + args[1])
         input = self.input(origin, msg, args)
         input.source = args[1]
         if self.kicked:
             functions.stfu(self, input)
             self.kicked = False
         else:
             functions._greet(self, input)
     elif event == 'PRIVMSG':
         if self.freespeech:
             input = self.input(origin, msg, args)
             if input.priv:
                 input.text = self.nick + ' ' + msg
             functions._freespeech(self, input)
         else:
             input = self.input(origin, msg, args)
             self.checkforvarioustriggers(input, origin, msg, args)
Beispiel #2
0
 def checkforvarioustriggers(self, input, origin, msg, args):
     nickmatch = re.match(self.nick.lower() + '(:|,|\s)', msg, re.I)
     if re.match('(redditron(.*)a bot)|(a bot(.*)redditron)', msg.lower()):
         if self.checkforspam(input):
             functions.detected(self, input)
     elif self.nick.lower() in msg.lower() and 'a bot' in msg.lower():
         if self.checkforspam(input):
             functions.detected(self, input)
     elif 'shut up' in msg or 'stfu' in msg:
         if self.nick in msg:
             if self.checkforspam(input):
                 functions.stfu(self, input)
     elif re.match('(wb|yo|dear|h(ai(l)?|ello|ey(a)?|i))\s' + self.nick,
                   msg, re.I):
         if self.checkforspam(input):
             functions._greet(self, input)
     elif nickmatch or input.priv:
         if self.checkforspam(input):
             if not input.priv:
                 msg = msg[len(self.nick) + 1:].lstrip()
                 input = self.input(origin, msg, args)
             self.checkforcommands(input)
     else:
         return False
     return True
Beispiel #3
0
 def dispatch(self, origin, args):
     # origin.sender = nick when PM, else chan
     bytes, event, args = args[0], args[1], args[2:]
     msg = decode(bytes)
     if event =='KICK' and args[1] == self.nick:
         self.logger('KICKED from '+args[0])
         self.kicked = True
         self.joinch(args[0])
     elif event=='251':
         self.startup()
     elif event=='366':
         self.logger('joined '+args[1])
         input = self.input(origin, msg, args)
         input.source=args[1]
         if self.kicked:
             functions.stfu(self, input)
             self.kicked = False
         else: 
             functions._greet(self, input)
     elif event=='PRIVMSG':
         if self.freespeech:
             input = self.input(origin, msg, args)
             if input.priv:
                 input.text=self.nick+' '+msg
             functions._freespeech(self,input)
         else:
             input = self.input(origin, msg, args)
             self.checkforvarioustriggers(input, origin, msg, args)
Beispiel #4
0
 def checkforvarioustriggers(self, input, origin, msg, args):
     nickmatch = re.match(self.nick.lower()+'(:|,|\s)', msg, re.I)
     if re.match('(redditron(.*)a bot)|(a bot(.*)redditron)', msg.lower()):
         if self.checkforspam(input):
             functions.detected(self,input)
     elif self.nick.lower() in msg.lower() and 'a bot' in msg.lower():
         if self.checkforspam(input):
             functions.detected(self,input)
     elif 'shut up' in msg or 'stfu' in msg:
         if self.nick in msg:
             if self.checkforspam(input):
                 functions.stfu(self,input)
     elif re.match('(wb|yo|dear|h(ai(l)?|ello|ey(a)?|i))\s'+ self.nick, msg, re.I):
         if self.checkforspam(input):
             functions._greet(self,input)
     elif nickmatch or input.priv:
         if self.checkforspam(input):
             if not input.priv:
                 msg=msg[len(self.nick)+1:].lstrip()
                 input =self.input(origin,msg,args)
             self.checkforcommands(input)
     else:
         return False
     return True