Exemplo n.º 1
0
 def __init__(self, token_analysis_filename, channels, update_interval=60):
     self._token_analysis_filename = token_analysis_filename
     self._channels = channels
     self._update_interval = update_interval
     self._last_button_labels = frozenset()
     self._last_timestamp = None
     self._limiter = Limiter(30)
Exemplo n.º 2
0
    def __init__(self, bot, help_text, database, config, alert_channels=None):
        self._bot = bot
        self._help_text = help_text
        self._database = database
        self._config = config
        self._recent_messages_for_regex = collections.defaultdict(lambda: collections.deque(maxlen=100))
        self._last_message = {}
        self._spam_limiter = Limiter(min_interval=10)
        self._regex_server = RegexServer()
        #self._token_notifier = TokenNotifier(
        #    config.get('token_notify_filename'),
        #    config.get('token_notify_channels'),
        #    config.get('token_notify_interval', 60)
        #)
        self._tellnext_generator = None
        self._alert_channels = frozenset(alert_channels or ())

        self._food_current = ""
        self._food_next = ""

        self._food_current_updated = None
        self._food_next_updated = None

        self._mail_disabled_channels = config.get('mail_disabled_channels')
        #    self._tellnext_generator = TellnextGenerator(config['tellnext_database'])

        bot.register_message_handler('pubmsg', self._collect_recent_message)
        bot.register_message_handler('action', self._collect_recent_message)
        #bot.register_command(r's/(.+/.*)', self._regex_command)
        #bot.register_command(r'(?i)!double(team)?($|\s.*)', self._double_command)
        bot.register_command(r'(?i)!(groudonger)?help($|\s.*)', self._help_command)
        bot.register_command(r'(?i)!groudon(ger)?($|\s.*)', self._roar_command)
        #bot.register_command(r'(?i)!hypestats($|\s.*)', self._hype_stats_command)
        bot.register_command(r'(?i)!klappa($|\s.*)', self._klappa_command)
        #bot.register_command(r'(?i)!(mail|post)($|\s.*)$', self._mail_command)
        #bot.register_command(r'(?i)!(mail|post)status($|\s.*)', self._mail_status_command)
        #bot.register_command(r'(?i)!pick\s+(.*)', self._pick_command)
        #bot.register_command(r'(?i)!praise($|\s.{,100})$', self._praise_command)
        #bot.register_command(r'(?i)!(?:shuffle|scramble)($|\s.*)', self._shuffle_command)
        #bot.register_command(r'(?i)!song($|\s.{,50})$', self._song_command)
        #bot.register_command(r'(?i)!sort($|\s.*)', self._sort_command)
        #bot.register_command(r'(?i)!rand(?:om)?case($|\s.*)', self._rand_case_command)
        #bot.register_command(r'(?i)!release($|\s.{,100})$', self._release_command)
        #bot.register_command(r'(?i)!riot($|\s.{,100})$', self._riot_command)
        #bot.register_command(r'(?i)!rip($|\s.{,100})$', self._rip_command)
        #bot.register_command(r'(?i)!gen(?:erate)?match($|\s.*)$', self._generate_match_command)
        #bot.register_command(r'(?i)!(xd|minglee|chfoo)($|\s.*)', self._xd_command)
        # Temporary disabled. interferes with rate limit
        # bot.register_command(r'.*\b[xX][dD] +MingLee\b.*', self._xd_rand_command)
        #bot.register_command(r'(?i)!(wow)($|\s.*)', self._wow_command)
        bot.register_command(r'(?i)!foodcurrent($|\s.*)', self._food_current_command)
        bot.register_command(r'(?i)!foodnext($|\s.*)', self._food_next_command)

        self._reseed_rng_sched()
Exemplo n.º 3
0
    def __init__(self, bot: Bot, help_text: str, database: Database,
                 config: dict):
        self._bot = bot
        self._help_text = help_text
        self._database = database
        self._config = config
        self._recent_messages_for_regex = collections.defaultdict(
            lambda: collections.deque(maxlen=100))
        self._last_message = {}
        self._spam_limiter = Limiter(min_interval=10)
        self._password_api_limiter = Limiter(min_interval=2)
        self._user_list = collections.defaultdict(set)
        self._regex_server = RegexServer()
        self._token_notifier = TokenNotifier(
            config.get('token_notify_filename'),
            config.get('token_notify_channels'),
            config.get('token_notify_interval', 60))
        self._tellnext_generator = None

        if os.path.isfile(config.get('tellnext_database', '')):
            self._tellnext_generator = TellnextGenerator(
                config['tellnext_database'])

        self._match_generator = None

        if os.path.isfile(config.get('veekun_pokedex_database', '')):
            self._match_generator = MatchGenerator(
                config['veekun_pokedex_database'])
            self._battlebot = BattleBot(config['veekun_pokedex_database'],
                                        self._bot)

            bot.register_message_handler('pubmsg',
                                         self._battlebot.message_callback)
            bot.register_message_handler('whisper',
                                         self._battlebot.message_callback)

        self._mail_disabled_channels = config.get('mail_disabled_channels')
        self._avoid_pikalaxbot = config.get('avoid_pikalaxbot')

        bot.register_message_handler('pubmsg', self._collect_recent_message)
        bot.register_message_handler('action', self._collect_recent_message)
        bot.register_command(r'!?s/(.+/.*)', self._regex_command)
        bot.register_command(r'(?i)!caw($|\s.*)', self._caw_command)
        bot.register_command(r'(?i)!countdown($|\s.*)',
                             self._countdown_command)
        bot.register_command(r'(?i)!debugecho\s+(.*)',
                             self._debug_echo_command)
        bot.register_command(r'(?i)!double(team)?($|\s.*)',
                             self._double_command)
        bot.register_command(r'(?i)!(set)?greet(ing)?($|\s.*)$',
                             self._greeting_command)
        bot.register_command(r'(?i)!(groudonger)?(help|commands)($|\s.*)',
                             self._help_command)
        bot.register_command(r'(?i)!groudon(ger)?($|\s.*)', self._roar_command)
        bot.register_command(r'(?i)!huffle($|\s.*)', self._huffle_command)
        bot.register_command(r'(?i)!hypestats($|\s.*)',
                             self._hype_stats_command)
        bot.register_command(r'(?i)!klappa($|\s.*)', self._klappa_command)
        bot.register_command(r'(?i)!(mail|post)($|\s.*)$', self._mail_command)
        bot.register_command(r'(?i)!(mail|post)status($|\s.*)',
                             self._mail_status_command)
        bot.register_command(r'(?i)!mute($|\s.*)',
                             self._mute_command,
                             ignore_rate_limit=True)
        bot.register_command(r'(?i)!normalize($|\s.*)',
                             self._normalize_command)
        bot.register_command(r'(?i)!password\s+(.*)', self._password_command)
        bot.register_command(r'(?i)!pick\s+(.*)', self._pick_command)
        bot.register_command(r'(?i)!praise($|\s.{,100})$',
                             self._praise_command)
        bot.register_command(r'(?i)!schedule($|\s.*)', self._schedule_command)
        bot.register_command(r'(?i)!(word)?(?:shuffle|scramble)($|\s.*)',
                             self._shuffle_command)
        bot.register_command(r'(?i)!song($|\s.{,50})$', self._song_command)
        bot.register_command(r'(?i)!sort($|\s.*)', self._sort_command)
        bot.register_command(r'(?i)!spellchat(?:ot)?($|\s.*)',
                             self._spell_chatot_command)
        bot.register_command(r'(?i)!racc(?:attack)?($|\s\S*)',
                             self._raccattack_command)
        bot.register_command(r'(?i)!rand(?:om)?case($|\s.*)',
                             self._rand_case_command)
        bot.register_command(r'(?i)!release($|\s.{,100})$',
                             self._release_command)
        bot.register_command(r'(?i)!reverse($|\s.*)', self._reverse_command)
        bot.register_command(r'(?i)!riot($|\s.{,100})$', self._riot_command)
        bot.register_command(r'(?i)!rip($|\s.{,100})$', self._rip_command)
        bot.register_command(r'(?i)!roomsize?($|\s.*)',
                             self._room_size_command)
        bot.register_command(r'(?i)!gen(?:erate)?match($|\s.*)$',
                             self._generate_match_command)
        bot.register_command(r'(?i)!(xd|minglee)($|\s.*)', self._xd_command)
        # bot.register_command(r'(?i)!(set)?{}($|\s.*)'.format(username), self._username_command)
        # Temporary disabled. interferes with rate limit
        # bot.register_command(r'.*\b[xX][dD] +MingLee\b.*', self._xd_rand_command)
        bot.register_command(r'(?i)!(wow)($|\s.*)', self._wow_command)
        bot.register_command(
            r'(?i)(?:has )?(?:just )?donate(?:d|s)? [^0-9]{0,5}([0-9][0-9,.]*)',
            self._donation_trigger)

        bot.register_message_handler('join', self._join_callback)
        bot.register_message_handler('part', self._part_callback)

        self._reseed_rng_sched()
        self._token_notify_sched()
        self._discord_presence_sched()