예제 #1
0
    def _add_fake_commands(self):
        # region Fake Commands

        self._honeydetected = main.bot.add_command(
            'honydetected reconnected',
            cooldown=main.CommandCooldown(0, 120, 0)
        )(self._honeydetected)
        self._honeydetected.limit_to_channels = ['supinic', 'mm2pl']
        self._honeydetected.matcher_function = (
            lambda msg, cmd: (
                    msg.user in ['supibot', 'mm2pl']
                    and (msg.text == 'ppCircle'
                         or msg.text == 'HONEYDETECTED RECONNECTED')
            )
        )

        self._cookie = main.bot.add_command(
            'cookie detection',
            cooldown=main.CommandCooldown(0, 0, 0)
        )(self._cookie)
        self._cookie.matcher_function = (
            lambda msg, cmd: (msg.channel in ['supinic', 'mm2pl']
                              and msg.user in ['thepositivebot', 'mm2pl']
                              and msg.text.startswith('\x01ACTION [Cookies]'))
        )
        self._ps_sneeze = main.bot.add_command(
            '[ps sneeze integration]',
            cooldown=main.CommandCooldown(30, 0, 0)
        )(self._ps_sneeze)
        self._ps_sneeze.limit_to_channels = ['supinic', 'mm2pl']
        self._ps_sneeze.matcher_function = (
            lambda msg, cmd: (
                    msg.user in ('supibot', 'mm2pl')
                    and msg.text.endswith('Playsound has been played correctly on stream.')
            )
        )
        self.c_asd = main.bot.add_command(
            'asd',
            cooldown=main.CommandCooldown(15, 5, 0)
        )(self.c_asd)
        self.c_asd.limit_to_channels = ['simon36']
        self.c_asd.matcher_function = (
            lambda msg, cmd: (
                msg.text.startswith('asd')
            )
        )
예제 #2
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)
예제 #3
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',
                                 ])
예제 #4
0
        'downtime',
        'title'
    ]
}
log = main.make_log_function(NAME)
UPTIME_CACHE_EXPIRATION_TIME = 60
cache_data_lock = asyncio.Lock()
cached_stream_data: Dict[str, Dict[str, Union[float, Dict[str, str], None]]] = {
    # 'channel': {
    #     'expire': time.monotonic(),
    #     'data': {
    #         'started_at': "%Y-%m-%dT%H:%M:%SZ"
    #     }
    # }
}
COOLDOWN = main.CommandCooldown(15, 5, 0)


@main.bot.add_command('title', available_in_whispers=False, cooldown=COOLDOWN)
async def command_title(msg: twitchirc.ChannelMessage):
    data = await _fetch_stream_data(msg.channel)
    if 'data' in data and len(data['data']):
        return f'@{msg.user}, {data["data"][0]["title"]}'
    else:
        return f'@{msg.user}, Stream not found'


async def _fetch_stream_data(channel, no_refresh=False) -> dict:
    async with aiohttp.request('get', 'https://api.twitch.tv/helix/streams', params={'user_login': channel},
                               headers={
                                   'Authorization': f'Bearer {twitch_auth.json_data["access_token"]}',
예제 #5
0
    def __init__(self, module, source):
        super().__init__(module, source)
        self.MailboxGame = mailbox_game.get(main.Base)
        self.game_enabled_setting = plugin_manager.Setting(
            self,
            'mailbox_game.enabled',
            default_value=False,
            scope=plugin_manager.SettingScope.PER_CHANNEL,
            write_defaults=True,
            on_load=self._load_from_settings,
            help_=
            'Toggles whether or not the mailbox guessing game is enabled in the channel.'
        )

        self.after_game_timeout_length = plugin_manager.Setting(
            self,
            'mailbox_game.timeout_after',
            default_value=-1,
            scope=plugin_manager.SettingScope.PER_CHANNEL,
            write_defaults=True,
            help_=
            'Sets how big is the timeout for guessing after the mail minigame has stopped accepting guesses.'
        )

        self.after_game_timeout_message = plugin_manager.Setting(
            self,
            'mailbox_game.timeout_message',
            default_value=
            'Your guess was late. To prevent spam you have been timed out.',
            scope=plugin_manager.SettingScope.PER_CHANNEL,
            write_defaults=True,
            help_=
            'Sets the timeout message for timeouts after the mail minigame has stopped accepting guesses.'
        )
        self.default_no_game_timeout_reason = plugin_manager.Setting(
            self,
            'mailbox_game.no_game_timeout_message',
            default_value=
            'There is no mail minigame running. Please don\'t spam.',
            scope=plugin_manager.SettingScope.PER_CHANNEL,
            write_defaults=True,
            help_=
            'Sets the timeout message for semi-manual timeouts. See help for "mailgame timeout"'
        )
        self.mailbox_games = {}
        self.command_mailbox = main.bot.add_command(
            'mailbox',
            limit_to_channels=[],
            available_in_whispers=False,
            required_permissions=['mailbox.manage'],
            enable_local_bypass=True)(self.command_mailbox)
        self.command_mailbox.aliases.append('mailgame')

        self.command_delete_guesses_after_stop = main.bot.add_command(
            '[plugin_mailboxgame:remove_guesses_after_stop]',
            available_in_whispers=False,
            cooldown=main.CommandCooldown(0, 0, 0, True)  # no cooldowns,
        )(self.command_delete_guesses_after_stop)
        self.command_delete_guesses_after_stop.limit_to_channels = []
        self.command_delete_guesses_after_stop.matcher_function = self._delete_guesses_matcher

        main.reloadables['mailbox_channels'] = self._reload_channels

        plugin_help.create_topic(
            'mailbox', 'Manage the mailbox game. Subcommands: mailbox start, '
            'mailbox stop, mailbox draw, mailbox cancel.',
            section=plugin_help.SECTION_COMMANDS,
            links=['mailgame'])

        plugin_help.create_topic(
            'mailbox stop',
            'Stop accepting new guesses into the minigame. This subcommand takes no arguments.',
            section=plugin_help.SECTION_ARGS,
            links=['mailgame stop'])

        plugin_help.create_topic(
            'mailbox draw',
            'Draw winner(s) of the minigame. Syntax: mailbox draw NN NN NN, '
            'where NN is a number, numbers need to be separated by spaces, '
            'they don\'t need leading zeros',
            section=plugin_help.SECTION_ARGS,
            links=['mailgame draw'])

        plugin_help.create_topic(
            'mailbox start',
            'Start the mailbox minigame. Possible arguments are guesses, '
            'find_best, winners. Help for these is at "mailbox start ARGUMENT_NAME"',
            section=plugin_help.SECTION_ARGS,
            links=['mailgame start'])
        plugin_help.create_topic(
            'mailbox cancel',
            'Cancels the ongoing mailbox minigame. This subcommand takes no arguments.',
            section=plugin_help.SECTION_ARGS,
            links=['mailgame cancel'])
        plugin_help.create_topic(
            'mailbox timeout',
            'Sets up manual timeouts for guesses. This subcommand takes one optional argument: '
            'the timeout reason, a multi-word string.',
            section=plugin_help.SECTION_ARGS,
            links=['mailgame timeout'])

        plugin_help.create_topic(
            'mailbox start guesses',
            'How many guesses should people have. Use guesses:NUMBER to change. Default: 1.',
            section=plugin_help.SECTION_ARGS,
            links=['mailgame start guesses'])
        plugin_help.create_topic(
            'mailbox start find_best',
            'Should the best matches be shown. If false only shows full matches. '
            'Use -find_best to disable that behaviour. Default: true',
            section=plugin_help.SECTION_ARGS,
            links=['mailgame start find_best'])
        plugin_help.create_topic(
            'mailbox start winners',
            'Highest amount of names shown when drawing winner(s). Full natches are always shown. '
            'Use winners:NUMBER to change this number. Default: 3',
            section=plugin_help.SECTION_ARGS,
            links=['mailgame start winners'])
        plugin_help.create_topic(
            'mailbox start punish_more',
            'Punish users for guessing more than they are allowed to. '
            'This will make the users guesses worth zero points. '
            'Use -punish_more to disable this. If disabled the first guess will be used. '
            'Duplicating the same guess will never cause disqualification. '
            'Default: true',
            section=plugin_help.SECTION_ARGS,
            links=['mailgame start punish_more'])
예제 #6
0
        if wl:
            return f' {len(wl)} commands whitelisted in this channel.'
        else:
            return f' {len(plugin_manager.blacklist[channel])} commands blacklisted in this channel.'
    else:
        return ''


def _channel_info():
    if main.debug:
        return f' Running on channel debug.'
    else:
        return ''


current_process = psutil.Process()


@plugin_help.add_manual_help_using_command(
    'Show that the bot is running, how long has it been running for, '
    'the amount of registered commands and if possible how many commands are '
    'blacklisted')
@main.bot.add_command('ping', cooldown=main.CommandCooldown(10, 5, 0))
def command_ping_simple(msg: twitchirc.ChannelMessage):
    return (
        f'@{msg.user} PONG! Bot has been running for '
        f'{datetime.timedelta(seconds=round(main.uptime().total_seconds()))} and is using '
        f'{current_process.memory_info().rss/1_000_000:.2f}MB of ram, '
        f'{len(main.bot.commands)} '
        f'commands registered.{_blacklist_info(msg.channel)}{_channel_info()}')
예제 #7
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)