def response(self, nick, args, kwargs): message = encode(args[0]) if kwargs['addressed']: match = score_request_re.search(message) if match is not None: start, end = match.groups() # asking for a username if end is None and start is not None: return self.memebot.get_scores(name=start) start = ((int(start) if start is not None and start.isdigit() else None) or 1) - 1 end = ( (int(end) if end is not None and end.isdigit() else None) or start + 10) - 1 if start < 0: start = 0 if end < start: end = start return self.memebot.get_scores(range=(start, end)) match = url_re.search(message) if match is not None: url = decode(match.group(1)) return self.memebot.process_url(url, nick, kwargs['channel'])
def logpublic(self, channel, line): logdir = os.path.join(self.base, 'log', 'public') if not os.path.exists(logdir): os.makedirs(logdir) filename = ['public', channel.replace('#', '')] if settings.LOG_BY_DATE: filename.append(time.strftime('%F')) logfile = os.path.join(logdir, '-'.join(filename) + '.log') with open(logfile, 'a') as fp: print >> fp, '%s %s' % (time.strftime('%T'), encode(line))
def response(self, nick, args, kwargs): message = encode(args[0]) if kwargs['addressed']: match = score_request_re.search(message) if match is not None: start, end = match.groups() # asking for a username if end is None and start is not None: return self.memebot.get_scores(name=start) start = ((int(start) if start is not None and start.isdigit() else None) or 1) - 1 end = ((int(end) if end is not None and end.isdigit() else None) or start + 10) - 1 if start < 0: start = 0 if end < start: end = start return self.memebot.get_scores(range=(start, end)) match = url_re.search(message) if match is not None: url = decode(match.group(1)) return self.memebot.process_url(url, nick, kwargs['channel'])
def protocol_output(self, message, req=None): """Override with protocol-specific output method""" print encode(message, sys.stdout.encoding)
def protocol_output(self, message, req=None): """Protocol-specific output method""" if req is not None and req.colorize is True: message = self.colorlib.rainbow(message) print encode(message)