def __init__(self, module, source):
        super().__init__(module, source)
        self.c_replay = main.bot.add_command('replay')(self.c_replay)
        plugin_help.add_manual_help_using_command(
            'Create a link to the VOD.'
            'Usage: replay [channel:STR] [time:TIME_DELTA]')(self.c_replay)

        plugin_help.create_topic('replay usage',
                                 'replay [channel:STR] [time:TIME_DELTA]',
                                 section=plugin_help.SECTION_ARGS)
        plugin_help.create_topic(
            'replay channel',
            'Channel to create the replay from. Must be live.',
            section=plugin_help.SECTION_ARGS,
            links=[
                'replay channel:str'
                'replay channel: str'
                'replay channel:STR'
                'replay channel: STR'
            ])
        plugin_help.create_topic('replay time',
                                 'Time to go back in the VOD.',
                                 section=plugin_help.SECTION_ARGS,
                                 links=[
                                     'replay time:time_delta'
                                     'replay time: time_delta'
                                     'replay time:TIME_DELTA'
                                     'replay time: TIME_DELTA'
                                 ])
Example #2
0
 def __init__(self, module, source):
     super().__init__(module, source)
     self.command_wiki = util_bot.bot.add_command('wiki', )(
         self.command_wiki)
     plugin_help.add_manual_help_using_command(
         'Search Wikipedia. Usage: wiki "<search text>" [lang:language name]'
     )(self.command_wiki)
Example #3
0
 def __init__(self, module, source):
     super().__init__(module, source)
     self.hastebin_addr_setting = plugin_manager.Setting(
         owner=self,
         name='hastebin.address',
         default_value='https://hastebin.com/',
         scope=plugin_manager.SettingScope.GLOBAL,
         write_defaults=True)
     self.c_hastebin = main.bot.add_command('hastebin',
                                            cooldown=main.CommandCooldown(
                                                30, 0, 0))(self.c_hastebin)
     plugin_help.add_manual_help_using_command(
         'Create a hastebin of the message you provided.')(self.c_hastebin)
Example #4
0
    def __init__(self, module, source):
        super().__init__(module, source)
        self.expire_lock = threading.Lock()
        main.bot.schedule_event(0.1, 10, self._post_init, (), {})
        self.expire_thread = threading.Thread(target=self._periodically_expire,
                                              args=(),
                                              kwargs={},
                                              daemon=True)
        self.expire_thread.start()
        main.reloadables['blacklist'] = self.reload_blacklist
        decorator = main.bot.add_command(
            'plonk',
            enable_local_bypass=False,
            required_permissions=['blacklist.plonk'])
        self.command_manage_blacklists = decorator(
            self.command_manage_blacklists)
        del decorator

        decorator = plugin_help.add_manual_help_using_command(
            'Manage blacklists. '
            'Usage: plonk [scope:(channel|global)] '
            '(user:(user|everyone)) '
            '(command:(command_name|all)) '
            '[expires:(never|timedelta)]')
        decorator(self.command_manage_blacklists)
Example #5
0
    def __init__(self, module, source):
        super().__init__(module, source)

        self.storage = main.PluginStorage(self, main.bot.storage)

        main.bot.handlers['chat_msg'].append(self.chan_msg_handler)
        if 'ping_optouts' in self.storage:
            self.ping_optouts = self.storage['ping_optouts']
        else:
            self.ping_optouts = {}
            self.storage['ping_optouts'] = self.ping_optouts

        self.c_ping_output = main.bot.add_command('ping_optout')(
            self.c_ping_output)
        plugin_help.add_manual_help_using_command(
            'Opt out from being pinged by the bot.')(self.c_ping_output)
        main.bot.middleware.append(AntiPingMiddleWare(self))
Example #6
0
    def __init__(self, module, source):
        super().__init__(module, source)
        self._issue_linker_channels = []
        self.issue_linker_optin_setting = plugin_manager.Setting(
            self,
            'cancer.issue_linker_optin',
            default_value=[],
            scope=plugin_manager.SettingScope.GLOBAL,
            write_defaults=True
        )

        self.issuelinker_enabled_setting = plugin_manager.Setting(
            self,
            'cancer.issuelinker_enabled',
            default_value=False,
            scope=plugin_manager.SettingScope.PER_CHANNEL,
            write_defaults=True,
            help_='Toggles if the issue linker is enabled in the channel. Also requires user opt-in. '
                  'See _help issuelinker.',
            on_load=self._issuelinker_enabled_setting_on_load
        )

        self.c_issue_optin = util_bot.bot.add_command(
            'issuelinker',
            cooldown=util_bot.CommandCooldown(10, 5, 0)
        )(self.c_issue_optin)
        self.c_issue_optin.limit_to_channels = self._issue_linker_channels  # ref
        plugin_help.add_manual_help_using_command('Add yourself to the list of people who will have links issue '
                                                  'posted when an issue is mentioned. Format is '
                                                  r'(owner/repo|repo_alias)#issue_number. '
                                                  r'CVE-year-number is also linked.'
                                                  'Usage: issuelinker',
                                                  None)(self.c_issue_optin)

        self.c_link_issue = util_bot.bot.add_command(
            'issue link detection',
            cooldown=util_bot.CommandCooldown(5, 1, 0)  # 1s channel cooldown to avoid bots triggering it
        )(self.c_link_issue)
        self.c_link_issue.limit_to_channels = self._issue_linker_channels  # ref
        self.c_link_issue.matcher_function = (
            lambda msg, cmd: (
                    ('#' in msg.text or '@' in msg.text) and ISSUE_PATTERN.search(msg.text)
                    or ('CVE-' and CVE_PATTERN.search(msg.text))
            )
        )
Example #7
0
    def __init__(self, module, source):
        super().__init__(module, source)
        self.c_replay = main.bot.add_command('replay')(self.c_replay)
        self.c_clip = main.bot.add_command(
            'quick_clip',
            available_in_whispers=False,
            cooldown=main.CommandCooldown(30, 10, 2),
        )(self.c_clip)
        self.c_clip.aliases = ['qc']

        plugin_help.add_manual_help_using_command(
            'Create a link to the VOD. '
            'Usage: replay [channel:STR] [time:TIME_DELTA]')(self.c_replay)

        plugin_help.add_manual_help_using_command(
            'Creates a clip quickly, usage: quick_clip', aliases=[
                'qc',
            ])(self.c_clip)

        plugin_help.create_topic(
            'replay channel',
            'Channel to create the replay from. Must be live.',
            section=plugin_help.SECTION_ARGS,
            links=[
                'replay channel:str',
                'replay channel: str',
                'replay channel:STR',
                'replay channel: STR',
            ])
        plugin_help.create_topic('replay time',
                                 'Time to go back in the VOD.',
                                 section=plugin_help.SECTION_ARGS,
                                 links=[
                                     'replay time:time_delta',
                                     'replay time: time_delta',
                                     'replay time:TIME_DELTA',
                                     'replay time: TIME_DELTA',
                                 ])
Example #8
0
    def __init__(self, module, source):
        super().__init__(module, source)
        self.timeout_setting = plugin_manager.Setting(
            self,
            'cancer.waytoodank_timeout',
            default_value=1.2,
            scope=plugin_manager.SettingScope.GLOBAL,
            write_defaults=True)

        self.status_every_frames_setting = plugin_manager.Setting(
            self,
            'cancer.status_every_frames',
            default_value=10,
            scope=plugin_manager.SettingScope.GLOBAL,
            write_defaults=True)
        self.time_before_status_setting = plugin_manager.Setting(
            self,
            'cancer.time_before_status',
            default_value=5,
            scope=plugin_manager.SettingScope.GLOBAL,
            write_defaults=True)

        self._sneeze = (-1, None)
        self.storage = main.PluginStorage(self, main.bot.storage)
        main.bot.handlers['chat_msg'].append(self.chan_msg_handler)

        self.random_ping_setting = plugin_manager.Setting(
            self,
            'cancer.random_pings',
            default_value=['{my pings run out}'],
            scope=plugin_manager.SettingScope.GLOBAL,
            write_defaults=True)

        self.pyramid_enabled_setting = plugin_manager.Setting(
            self,
            'cancer.pyramid_enabled',
            default_value=False,
            scope=plugin_manager.SettingScope.PER_CHANNEL,
            write_defaults=True)

        self.cookie_optin_setting = plugin_manager.Setting(
            self,
            'cancer.cookie_optin',
            default_value=[],
            scope=plugin_manager.SettingScope.GLOBAL,
            write_defaults=True)

        # register commands
        self.command_pyramid = main.bot.add_command(
            'mb.pyramid',
            required_permissions=['cancer.pyramid'],
            enable_local_bypass=True)(self.c_pyramid)
        plugin_help.add_manual_help_using_command(
            'Make a pyramid out of an emote or text',
            None)(self.command_pyramid)

        self.command_braillefy = main.bot.add_command(
            'braillefy',
            enable_local_bypass=True,
            required_permissions=['cancer.braille'])(self.c_braillefy)
        plugin_help.add_manual_help_using_command(
            'Convert an image into braille.', None)(self.command_braillefy)

        # arguments.
        plugin_help.create_topic('braillefy url',
                                 'URL pointing to image you want to convert.',
                                 section=plugin_help.SECTION_ARGS)
        plugin_help.create_topic('braillefy reverse',
                                 'Should the output braille be reversed.',
                                 section=plugin_help.SECTION_ARGS)
        plugin_help.create_topic(
            'braillefy sensitivity',
            'Per-channel sensitivity of the converter. r(ed), g(reen), b(lue), a(lpha)',
            section=plugin_help.SECTION_ARGS,
            links=[
                'braillefy sensitivity_r', 'braillefy sensitivity_g',
                'braillefy sensitivity_b', 'braillefy sensitivity_a'
            ])

        plugin_help.create_topic(
            'braillefy size',
            'Size of the image. Defaults: max_x = 60, pad_y = 60, '
            'size_percent=[undefined]. max_x, pad_y are in pixels.',
            section=plugin_help.SECTION_ARGS,
            links=[
                'braillefy size_percent',
                'braillefy max_x',
                'braillefy pad_y',
            ])

        self.c_cookie_optin = main.bot.add_command('cookie')(
            self.c_cookie_optin)
        plugin_help.add_manual_help_using_command(
            'Add yourself to the list of people who will be reminded to eat '
            'cookies', None)(self.c_cookie_optin)

        main.bot.schedule_repeated_event(0.1, 1, self.waytoodank_timer, (), {})

        plugin_help.create_topic(
            'plugin_cancer',
            'Plugin dedicated to things that shouldn\'t be done '
            '(responding to messages other than commands, spamming).',
            section=plugin_help.SECTION_MISC,
            links=['plugin_cancer.py', 'cancer'])
        warnings.simplefilter('error', Image.DecompressionBombWarning)
Example #9
0
    def __init__(self, module, source):
        super().__init__(module, source)
        warnings.simplefilter('error', Image.DecompressionBombWarning)

        self._sneeze_cooldown = time.time()
        self.storage = main.PluginStorage(self, main.bot.storage)

        # region Settings
        self.timeout_setting = plugin_manager.Setting(
            self,
            'cancer.waytoodank_timeout',
            default_value=1.2,
            scope=plugin_manager.SettingScope.GLOBAL,
            write_defaults=True
        )
        self.random_ping_setting = plugin_manager.Setting(
            self,
            'cancer.random_pings',
            default_value=['{my pings run out}'],
            scope=plugin_manager.SettingScope.GLOBAL,
            write_defaults=True
        )

        self.pyramid_enabled_setting = plugin_manager.Setting(
            self,
            'cancer.pyramid_enabled',
            default_value=False,
            scope=plugin_manager.SettingScope.PER_CHANNEL,
            write_defaults=True,
            help_='Toggles if the mb.pyramid command is enabled in the channel.'
        )

        self.cookie_optin_setting = plugin_manager.Setting(
            self,
            'cancer.cookie_optin',
            default_value=[],
            scope=plugin_manager.SettingScope.GLOBAL,
            write_defaults=True
        )
        self.status_every_frames_setting = plugin_manager.Setting(
            self,
            'cancer.status_every_frames',
            default_value=10,
            scope=plugin_manager.SettingScope.GLOBAL,
            write_defaults=True
        )
        self.time_before_status_setting = plugin_manager.Setting(
            self,
            'cancer.time_before_status',
            default_value=5,
            scope=plugin_manager.SettingScope.GLOBAL,
            write_defaults=True
        )
        # endregion

        # region Register commands
        self.c_cookie_optin = main.bot.add_command(
            'cookie',
            cooldown=main.CommandCooldown(10, 5, 0)
        )(self.c_cookie_optin)

        self.command_pyramid = main.bot.add_command(
            'mb.pyramid',
            required_permissions=['cancer.pyramid'],
            enable_local_bypass=True,
            cooldown=main.CommandCooldown(30, 30, 0)
        )(self.c_pyramid)

        self.command_braillefy = main.bot.add_command(
            'braillefy',
            enable_local_bypass=True,
            required_permissions=['cancer.braille'],
            cooldown=main.CommandCooldown(15, 0, 0)
        )(self.c_braillefy)
        self.command_braillefy.aliases = ['ascii']

        # region Help
        plugin_help.create_topic('braillefy url',
                                 'URL pointing to image you want to convert.',
                                 section=plugin_help.SECTION_ARGS,
                                 links=[
                                     'ascii url'
                                 ])
        plugin_help.create_topic('braillefy emote',
                                 'Emote name (current channel or Twitch emote assumed) or '
                                 '#CHANNEL_NAME:EMOTE_NAME to use an emote from another channel.',
                                 section=plugin_help.SECTION_ARGS)
        plugin_help.create_topic('braillefy sensitivity',
                                 'Per-channel sensitivity of the converter. r(ed), g(reen), b(lue), a(lpha). '
                                 'Usage: sensitivity_(r, g, b or a):NUMBER',
                                 section=plugin_help.SECTION_ARGS,
                                 links=[
                                     'braillefy sensitivity_r',
                                     'braillefy sensitivity_g',
                                     'braillefy sensitivity_b',
                                     'braillefy sensitivity_a',
                                     'ascii sensitivity_r',
                                     'ascii sensitivity_g',
                                     'ascii sensitivity_b',
                                     'ascii sensitivity_a',
                                 ])
        plugin_help.create_topic('braillefy reverse',
                                 'Should the output braille be reversed. '
                                 'Usage: +reverse',
                                 section=plugin_help.SECTION_ARGS)
        plugin_help.create_topic('braillefy size',
                                 'Size of the image. Defaults: max_x = 60, pad_y = 60, '
                                 'size_percent=[undefined]. max_x, pad_y are in pixels. '
                                 'If resize option is set to False (-resize) no resizing will be done. '
                                 'Usages: size_percent:NUMBER, max_x:NUMBER, pad_y:NUMBER',
                                 section=plugin_help.SECTION_ARGS,
                                 links=[
                                     'braillefy size_percent',
                                     'braillefy max_x',
                                     'braillefy pad_y',
                                     'braillefy resize',
                                     'ascii size_percent',
                                     'ascii max_x',
                                     'ascii pad_y',
                                     'ascii resize',
                                 ])
        plugin_help.create_topic('braillefy hastebin',
                                 'Should the ascii be put into a hastebin?'
                                 'Usage: +hastebin',
                                 section=plugin_help.SECTION_ARGS,
                                 links=[
                                     'ascii hastebin'
                                 ])
        plugin_help.create_topic('braillefy sobel',
                                 'Should a edge detection filter be applied before creating the ascii? '
                                 'See Wikipedia:Sobel. Usage: braillefy (...) +sobel')
        plugin_help.create_topic('plugin_cancer',
                                 'Plugin dedicated to things that shouldn\'t be done '
                                 '(responding to messages other than commands, spamming).',
                                 section=plugin_help.SECTION_MISC,
                                 links=[
                                     'plugin_cancer.py',
                                     'cancer'
                                 ])
        plugin_help.add_manual_help_using_command('Add yourself to the list of people who will be reminded to eat '
                                                  'cookies. Usage: cookie', None)(self.c_cookie_optin)
        plugin_help.add_manual_help_using_command('Make a pyramid out of an emote or text. '
                                                  'Usage: pyramid <size> <text...>',
                                                  None)(self.command_pyramid)
        plugin_help.add_manual_help_using_command(
            'Convert an image into braille. '
            'Usage: braillefy (url:URL|emote:EMOTE) [sensitivity_(r|g|b|a):float] '
            '[size_percent:float] [max_x:int] [pad_y:int] [+reverse] [+hastebin] [+sobel] [-resize]',
            None
        )(self.command_braillefy)