示例#1
0
    async def subsys(self, ctx):
        for msg in utils.paginate(self.bot.reaction_listener.callbacks,
                                  prefix="**Reactions registrations:**\n",
                                  suffix="\n"):
            await ctx.send(msg)
        for msg in utils.paginate(self.bot.timers.jobs,
                                  prefix="**Timer registrations:**\n",
                                  suffix="\n"):
            await ctx.send(msg)
        for msg in utils.paginate(self.bot.dm_listener.callbacks,
                                  prefix="**DM Listeners:**\n",
                                  suffix="\n"):
            await ctx.send(msg)

        await ctx.invoke(self.bot.get_command("disable list"))
示例#2
0
文件: dsc.py 项目: KDanny41/Geckarbot
    async def dsc_winners(self, ctx):
        c = self.get_api_client()
        winners = c.get(Config.get(self)['winners_range'])

        w_msgs = []
        regex = re.compile(r"\d+")
        for w in winners[1:]:
            if w[0] is None or not w[0]:
                continue

            m0 = regex.findall(w[0])
            m2 = regex.findall(w[2])
            no = m0[0]
            dt = datetime(int(m0[2]), int(m0[1]), 1)
            participator_coutn = m0[3]
            winner_name = w[1]
            pts_winner = int(m2[0])
            pts_max = int(m2[1])
            pts_percentage = round(pts_winner / pts_max * 100)

            w_msgs.append(Lang.lang(self, 'winner_msg', no, winner_name, pts_winner, pts_max, pts_percentage,
                                    participator_coutn, dt.month, dt.year))

        for m in utils.paginate(w_msgs, Lang.lang(self, 'winner_prefix')):
            await ctx.send(m)
示例#3
0
    async def helpcmd(self, ctx, *args):
        # !help
        if len(args) == 0:
            # build ordering lists
            first = []
            middle = []
            last = []
            for cat in self._categories:
                line = cat.single_line()
                if cat.order == CategoryOrder.FIRST:
                    first.append(line)
                elif cat.order == CategoryOrder.LAST:
                    last.append(line)
                else:
                    middle.append(line)

            lines = first + middle + last
            for msg in paginate(lines,
                                prefix=Lang.lang(self, "help_pre_text") +
                                "\n\n",
                                msg_prefix="```",
                                msg_suffix="```"):
                await ctx.send(msg)
            return

        # !help args
        else:
            # find command that was specified
            cmd = None
            for arg in args:
                cmd = self.find_command(arg, cmd)
            if cmd is not None:
                await self.full_cmd_help(ctx, cmd)
示例#4
0
    async def cmd_list(self, ctx, full=""):
        cmds = []
        suffix = Lang.lang(self, 'list_suffix') if full else ""

        for k in self.commands.keys():
            if full:
                arg_lens = []
                for t in self.commands[k].texts:
                    arg_list = arg_list_re.findall(t)
                    arg_lens.append(len(arg_list))
                cmds.append(
                    Lang.lang(self, 'list_full_data', k,
                              len(self.commands[k].texts), max(arg_lens)))

            else:
                cmds.append(k)

        if not cmds:
            await ctx.send(Lang.lang(self, 'list_no_cmds'))
            return

        cmds.sort(key=str.lower)
        cmd_msgs = utils.paginate(cmds, delimiter=", ", suffix=suffix)
        for msg in cmd_msgs:
            await ctx.send(msg)
示例#5
0
文件: mod.py 项目: KDanny41/Geckarbot
    async def plugins(self, ctx):
        """Returns registered plugins"""
        coreplugins = [c.name for c in self.bot.plugins if c.type == ConfigurableType.COREPLUGIN]
        plugins = [c.name for c in self.bot.plugins if c.type == ConfigurableType.PLUGIN]
        subsys = []
        for modname in pkgutil.iter_modules(subsystems.__path__):
            subsys.append(modname.name)

        for msg in utils.paginate(coreplugins,
                                  prefix=Lang.lang(self, 'plugins_loaded_cp', len(coreplugins)), delimiter=", "):
            await ctx.send(msg)
        for msg in utils.paginate(plugins,
                                  prefix=Lang.lang(self, 'plugins_loaded_pl', len(coreplugins)), delimiter=", "):
            await ctx.send(msg)
        for msg in utils.paginate(subsys,
                                  prefix=Lang.lang(self, 'plugins_loaded_ss', len(coreplugins)), delimiter=", "):
            await ctx.send(msg)
示例#6
0
    async def delivering_phase(self):
        for target in self.participants:
            todo = []
            for el in self.participants:
                if el.assigned != target:
                    todo.append(el.to_msg(show_assignees=self.show_assignees))

            for msg in utils.paginate(todo,
                                      prefix=Lang.lang(self, "list_title")):
                await target.send(msg)
        await self.channel.send(Lang.lang(self, "done"))
        self.cleanup()
        self.statemachine.state = State.IDLE
示例#7
0
 async def cmd_raw(self, ctx, cmd_name):
     cmd_name = cmd_name.lower()
     if cmd_name in self.commands:
         creator = self.bot.get_user(self.commands[cmd_name].creator_id)
         for msg in utils.paginate(self.commands[cmd_name].get_raw_texts(),
                                   delimiter="\n",
                                   prefix=Lang.lang(
                                       self, 'raw_prefix', self.prefix,
                                       cmd_name,
                                       utils.get_best_username(creator))):
             await ctx.send(msg)
     else:
         await ctx.send(Lang.lang(self, "raw_doesnt_exists", cmd_name))
示例#8
0
    async def configdump(self, ctx, name):
        plugin = converter.get_plugin_by_name(self.bot, name)
        if plugin is None:
            await ctx.message.add_reaction(Lang.CMDERROR)
            await ctx.send("Plugin {} not found.".format(name))
            return
        await ctx.message.add_reaction(Lang.CMDSUCCESS)

        dump = pprint.pformat(Config.get(plugin), indent=4).split("\n")
        prefix = ""
        if not Config.has_structure(plugin):
            prefix = "**Warning: plugin {} does not have a config structure.** " \
                     "This is the default config.".format(name)
        for el in utils.paginate(dump,
                                 prefix=prefix,
                                 msg_prefix="```",
                                 msg_suffix="```"):
            await ctx.send(el)
示例#9
0
    async def spoilercmd(self, ctx):
        # State check
        error = None
        if self.statemachine.state != State.IDLE:
            error = "show_running"

        elif not self.participants:
            error = "show_not_found"

        elif ctx.author in [x.user for x in self.participants]:
            error = "no_spoiler"

        if error is not None:
            await ctx.message.add_reaction(Lang.CMDERROR)
            await ctx.send(Lang.lang(self, error))
            return

        await ctx.message.add_reaction(Lang.CMDSUCCESS)
        for msg in utils.paginate(self.participants,
                                  prefix=Lang.lang(self,
                                                   "participants_last_round"),
                                  f=lambda x: x.to_msg()):
            await ctx.author.send(msg)
示例#10
0
    async def update_news(self, channel, version=None):
        """
        Sends release notes to channel.
        :param channel: Channel to send the release notes to.
        :param version: Release version that the news should be about.
        """
        if version is None:
            version = Config().VERSION
        ver = None
        body = None
        for el in self.get_releases():
            ver = sanitize_version_s(el["tag_name"])
            logging.getLogger(__name__).debug(
                "Comparing versions: {} and {}".format(Config().VERSION, ver))
            if is_equal(sanitize_version_s(version), ver):
                body = el["body"]
                break

        if body is None:
            await channel.send(lang["err_no_news_for_version"].format(version))
            return

        # Make headlines great again!
        lines = []
        p = re.compile(r"\s*#+\s*(.*)")
        for el in body.split("\n"):
            m = p.match(el)
            if m:
                el = "**{}**".format(m.groups()[0])
            lines.append(el)

        for page in utils.paginate(lines,
                                   prefix="**Version {}:**\n".format(ver),
                                   msg_prefix="_ _\n",
                                   delimiter=""):
            await channel.send(page)
示例#11
0
文件: mod.py 项目: KDanny41/Geckarbot
 async def write_list(itype: IgnoreType, prefix):
     ilist = self.bot.ignoring.get_ignore_list(itype)
     if len(ilist) > 0:
         for msg in utils.paginate(ilist, prefix=prefix, f=get_item_msg):
             await ctx.send(msg)