def main(): basebot.run_main(NowBot)
def main(): basebot.run_main(TumbleWeed, sys.argv[1:])
def __init__(self, *args, **kwds): basebot.ThreadedBot.__init__(self, *args, **kwds) self.stats = {} self.nickname = 'lmddgtfyBot' def handle_chat(self, info, message): # Handle standard commands (returns True if actually handled). if self.handle_commands(info, message, short_help='I help you Google with privacy. !lmddgtfy keywords.'): return content = info['content'] reply_id = info['id'] sender = info['sender'] if content.startswith("!lmddgtfy "): self.reply(content[10:], reply_id) elif content.startswith("!lmgtfy "): self.reply(content[8:], reply_id, True) def reply(self, keyword, reply_id, google=False): if google: self.send_chat('With privacy : https://lmddgtfy.net/?q={}'.format(keyword), reply_id) else: self.send_chat('https://lmddgtfy.net/?q={}'.format(keyword), reply_id) if __name__ == '__main__': basebot.run_main(LetMeBot, sys.argv[1:])
def main(): basebot.run_main(TumbleWeed)
self.stats[to_u] = self.stats[from_u] del self.stats[from_u] def print_stats(self, reply_id, user=''): if user != '': if user in self.stats: #send user stat self.send_chat('@{} has send {} messages.'.format(user, self.stats[user]), reply_id) else: self.send_chat('@{} has not participated yet.'.format(user), reply_id) return #send top-10 ts = time.time(); response = 'Stats collected since {} ({})\n'.format( format_datetime(self.starttime), format_delta(ts - self.starttime)) sorted_list = sorted(self.stats.items(), key=operator.itemgetter(1)) sorted_list = sorted_list[::-1] top = min( len(sorted_list), 11) for index in range(0, top): info = sorted_list[index] num = ':trophy:' if index == 0 else index+1 response = response + '{} - {} has posted {} messages.\n'.format( num, info[0], info[1]) self.send_chat(response, reply_id) if __name__ == '__main__': basebot.run_main(StatBot, sys.argv[1:])