python类send_cmd_help()的实例源码

karma.py 文件源码 项目:Squid-Plugins 作者: tekulvw 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def karma(self, ctx):
        """Checks a user's karma, requires @ mention

           Example: !karma @Red"""
        if len(ctx.message.mentions) != 1:
            await send_cmd_help(ctx)
            return
        member = ctx.message.mentions[0]
        if self.scores.get(member.id, 0) != 0:
            member_dict = self.scores[member.id]
            await self.bot.say(member.name + " has " +
                               str(member_dict["score"]) + " points!")
            reasons = self._fmt_reasons(member_dict.get("reasons", []))
            if reasons:
                await self.bot.send_message(ctx.message.author, reasons)
        else:
            await self.bot.say(member.name + " has no karma!")
mod.py 文件源码 项目:Shallus-Bot 作者: cgropp 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def modset(self, ctx):
        """Manages server administration settings."""
        if ctx.invoked_subcommand is None:
            server = ctx.message.server
            await send_cmd_help(ctx)
            roles = settings.get_server(server).copy()
            _settings = {**self.settings[server.id], **roles}
            if "delete_delay" not in _settings:
                _settings["delete_delay"] = -1
            msg = ("Admin role: {ADMIN_ROLE}\n"
                   "Mod role: {MOD_ROLE}\n"
                   "Mod-log: {mod-log}\n"
                   "Delete repeats: {delete_repeats}\n"
                   "Ban mention spam: {ban_mention_spam}\n"
                   "Delete delay: {delete_delay}\n"
                   "".format(**_settings))
            await self.bot.say(box(msg))
mod.py 文件源码 项目:Shallus-Bot 作者: cgropp 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def modlog(self, ctx, channel : discord.Channel=None):
        """Sets a channel as mod log

        Leaving the channel parameter empty will deactivate it"""
        server = ctx.message.server
        if channel:
            self.settings[server.id]["mod-log"] = channel.id
            await self.bot.say("Mod events will be sent to {}"
                               "".format(channel.mention))
        else:
            if self.settings[server.id]["mod-log"] is None:
                await send_cmd_help(ctx)
                return
            self.settings[server.id]["mod-log"] = None
            await self.bot.say("Mod log deactivated.")
        dataIO.save_json("data/mod/settings.json", self.settings)
mod.py 文件源码 项目:Shallus-Bot 作者: cgropp 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def banmentionspam(self, ctx, max_mentions : int=False):
        """Enables auto ban for messages mentioning X different people

        Accepted values: 5 or superior"""
        server = ctx.message.server
        if max_mentions:
            if max_mentions < 5:
                max_mentions = 5
            self.settings[server.id]["ban_mention_spam"] = max_mentions
            await self.bot.say("Autoban for mention spam enabled. "
                               "Anyone mentioning {} or more different people "
                               "in a single message will be autobanned."
                               "".format(max_mentions))
        else:
            if self.settings[server.id]["ban_mention_spam"] is False:
                await send_cmd_help(ctx)
                return
            self.settings[server.id]["ban_mention_spam"] = False
            await self.bot.say("Autoban for mention spam disabled.")
        dataIO.save_json("data/mod/settings.json", self.settings)
mod.py 文件源码 项目:Shallus-Bot 作者: cgropp 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def filter_add(self, ctx, *words: str):
        """Adds words to the filter

        Use double quotes to add sentences
        Examples:
        filter add word1 word2 word3
        filter add \"This is a sentence\""""
        if words == ():
            await send_cmd_help(ctx)
            return
        server = ctx.message.server
        added = 0
        if server.id not in self.filter.keys():
            self.filter[server.id] = []
        for w in words:
            if w.lower() not in self.filter[server.id] and w != "":
                self.filter[server.id].append(w.lower())
                added += 1
        if added:
            dataIO.save_json("data/mod/filter.json", self.filter)
            await self.bot.say("Words added to filter.")
        else:
            await self.bot.say("Words already in the filter.")
mod.py 文件源码 项目:Shallus-Bot 作者: cgropp 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def filter_remove(self, ctx, *words: str):
        """Remove words from the filter

        Use double quotes to remove sentences
        Examples:
        filter remove word1 word2 word3
        filter remove \"This is a sentence\""""
        if words == ():
            await send_cmd_help(ctx)
            return
        server = ctx.message.server
        removed = 0
        if server.id not in self.filter.keys():
            await self.bot.say("There are no filtered words in this server.")
            return
        for w in words:
            if w.lower() in self.filter[server.id]:
                self.filter[server.id].remove(w.lower())
                removed += 1
        if removed:
            dataIO.save_json("data/mod/filter.json", self.filter)
            await self.bot.say("Words removed from filter.")
        else:
            await self.bot.say("Those words weren't in the filter.")
welcome.py 文件源码 项目:Dumb-Cogs 作者: irdumbs 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def welcomeset(self, ctx):
        """Sets welcome module settings"""
        server = ctx.message.server
        if server.id not in self.settings:
            self.settings[server.id] = deepcopy(default_settings)
            self.settings[server.id]["CHANNEL"] = server.default_channel.id
            dataIO.save_json(settings_path, self.settings)
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
            msg = "```"
            msg += "Random GREETING: {}\n".format(rand_choice(self.settings[server.id]["GREETING"]))
            msg += "CHANNEL: #{}\n".format(self.get_welcome_channel(server))
            msg += "ON: {}\n".format(self.settings[server.id]["ON"])
            msg += "WHISPER: {}\n".format(self.settings[server.id]["WHISPER"])
            msg += "BOTS_MSG: {}\n".format(self.settings[server.id]["BOTS_MSG"])
            msg += "BOTS_ROLE: {}\n".format(self.settings[server.id]["BOTS_ROLE"])
            msg += "```"
            await self.bot.say(msg)
repl.py 文件源码 项目:Dumb-Cogs 作者: irdumbs 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def replset_print_file(self, ctx, choice=None):
        """write results to a file, optionally opening in subl/atom

        Choices: nothing | subl | subl.exe | atom | atom.exe"""
        author = ctx.message.author
        choices = ['subl', 'subl.exe', 'atom', 'atom.exe']
        if choice not in choices + [None, 'nothing']:
            await send_cmd_help(ctx)
            return
        if choice is None:
            msg = ("You chose to print to file. What would you like to open it with?\n"
                   "Choose between:  {}".format(' | '.join(choices + ['nothing'])))
            choice = await self.user_choice(author, msg, choices)
        msg = "repl overflow will now go to file and "
        if choice not in choices:
            msg += "I won't open it after writing to {}".format(self.output_file)
            choice = None
        else:
            msg += ("the output will be opened with: `{} "
                    "{}`".format(choice, self.output_file))
        self.settings['OPEN_CMD'] = choice
        self.settings["OUTPUT_REDIRECT"] = "file"
        dataIO.save_json("data/repl/settings.json", self.settings)
        await self.bot.say(msg)
economytrickle.py 文件源码 项目:Dumb-Cogs 作者: irdumbs 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def trickleset(self, ctx):
        """Changes economy trickle settings
        Trickle amount:
            base amount + (# active users - 1) x multiplier + bonus pot
        Every active user gets the trickle amount. 
        It is not distributed between active users.
        """
        server = ctx.message.server
        settings = self.settings.setdefault(server.id,
                                            deepcopy(DEFAULT_SETTINGS))
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
            msg = "```"
            for k, v in settings.items():
                if k == 'CHANNELS':
                    v = ['#' + c.name if c else 'deleted-channel'
                         for c in (server.get_channel(cid) for cid in v)]
                    v = ', '.join(v)
                v = {True: 'On', False: 'Off'}.get(v, v)
                msg += str(k) + ": " + str(v) + "\n"
            msg += "```"
            await self.bot.say(msg)
bouncer.py 文件源码 项目:Maselkov-Cogs 作者: Maselkov 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def bouncerset_roles(self, ctx, before_after: str, role: discord.Role=None):
        """For first parameter use before or after. For roles with space with them,
        use \"double quotes\"

        Before: role assigned to users when they join the server but don't accept
        the rules yet, will be stripped after accepting the rules. Can be left empty.

        After: Role assigned after accepting the rules
        """
        server = ctx.message.server
        valid_options = ["before", "after"]
        selection = before_after.lower()
        if selection not in valid_options:
            await send_cmd_help(ctx)
            return
        if selection == "before":
            await self.bot.say("Role assigned at join will be: {}".format(role))
            self.settings[server.id]["role_before"] = role.id
        elif role is not None:
            await self.bot.say("Role assigned after accepting rules will be: {}".format(role))
            self.settings[server.id]["role_after"] = role.id
        else:
            self.bot.say("After role can't be empty")
            return
        dataIO.save_json('data/bouncer/settings.json', self.settings)
streams.py 文件源码 项目:KeekoBot 作者: DavidNeon 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def mention(self, ctx, *, mention_type : str):
        """Sets mentions for stream alerts

        Types: everyone, here, none"""
        server = ctx.message.server
        mention_type = mention_type.lower()

        if mention_type in ("everyone", "here"):
            self.settings[server.id]["MENTION"] = "@" + mention_type
            await self.bot.say("When a stream is online @\u200b{} will be "
                               "mentioned.".format(mention_type))
        elif mention_type == "none":
            self.settings[server.id]["MENTION"] = ""
            await self.bot.say("Mentions disabled.")
        else:
            await self.bot.send_cmd_help(ctx)

        dataIO.save_json("data/streams/settings.json", self.settings)
mod.py 文件源码 项目:KeekoBot 作者: DavidNeon 项目源码 文件源码 阅读 44 收藏 0 点赞 0 评论 0
def modset(self, ctx):
        """Manages server administration settings."""
        if ctx.invoked_subcommand is None:
            server = ctx.message.server
            await send_cmd_help(ctx)
            roles = settings.get_server(server).copy()
            _settings = {**self.settings[server.id], **roles}
            if "delete_delay" not in _settings:
                _settings["delete_delay"] = -1
            msg = ("Admin role: {ADMIN_ROLE}\n"
                   "Mod role: {MOD_ROLE}\n"
                   "Mod-log: {mod-log}\n"
                   "Delete repeats: {delete_repeats}\n"
                   "Ban mention spam: {ban_mention_spam}\n"
                   "Delete delay: {delete_delay}\n"
                   "".format(**_settings))
            await self.bot.say(box(msg))
mod.py 文件源码 项目:KeekoBot 作者: DavidNeon 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def modlog(self, ctx, channel : discord.Channel=None):
        """Sets a channel as mod log

        Leaving the channel parameter empty will deactivate it"""
        server = ctx.message.server
        if channel:
            self.settings[server.id]["mod-log"] = channel.id
            await self.bot.say("Mod events will be sent to {}"
                               "".format(channel.mention))
        else:
            if self.settings[server.id]["mod-log"] is None:
                await send_cmd_help(ctx)
                return
            self.settings[server.id]["mod-log"] = None
            await self.bot.say("Mod log deactivated.")
        dataIO.save_json("data/mod/settings.json", self.settings)
mod.py 文件源码 项目:KeekoBot 作者: DavidNeon 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _filter(self, ctx):
        """Adds/removes words from filter

        Use double quotes to add/remove sentences
        Using this command with no subcommands will send
        the list of the server's filtered words."""
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
            server = ctx.message.server
            author = ctx.message.author
            if server.id in self.filter:
                if self.filter[server.id]:
                    words = ", ".join(self.filter[server.id])
                    words = "Filtered in this server:\n\n" + words
                    try:
                        for page in pagify(words, delims=[" ", "\n"], shorten_by=8):
                            await self.bot.send_message(author, page)
                    except discord.Forbidden:
                        await self.bot.say("I can't send direct messages to you.")
mod.py 文件源码 项目:KeekoBot 作者: DavidNeon 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def filter_add(self, ctx, *words: str):
        """Adds words to the filter

        Use double quotes to add sentences
        Examples:
        filter add word1 word2 word3
        filter add \"This is a sentence\""""
        if words == ():
            await send_cmd_help(ctx)
            return
        server = ctx.message.server
        added = 0
        if server.id not in self.filter.keys():
            self.filter[server.id] = []
        for w in words:
            if w.lower() not in self.filter[server.id] and w != "":
                self.filter[server.id].append(w.lower())
                added += 1
        if added:
            dataIO.save_json("data/mod/filter.json", self.filter)
            await self.bot.say("Words added to filter.")
        else:
            await self.bot.say("Words already in the filter.")
mod.py 文件源码 项目:KeekoBot 作者: DavidNeon 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def filter_remove(self, ctx, *words: str):
        """Remove words from the filter

        Use double quotes to remove sentences
        Examples:
        filter remove word1 word2 word3
        filter remove \"This is a sentence\""""
        if words == ():
            await send_cmd_help(ctx)
            return
        server = ctx.message.server
        removed = 0
        if server.id not in self.filter.keys():
            await self.bot.say("There are no filtered words in this server.")
            return
        for w in words:
            if w.lower() in self.filter[server.id]:
                self.filter[server.id].remove(w.lower())
                removed += 1
        if removed:
            dataIO.save_json("data/mod/filter.json", self.filter)
            await self.bot.say("Words removed from filter.")
        else:
            await self.bot.say("Those words weren't in the filter.")
warn.py 文件源码 项目:KeekoBot 作者: DavidNeon 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _warnset(self, ctx):
        if ctx.message.server.id not in self.riceCog2:
            self.riceCog2[ctx.message.server.id] = {}
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
            server = ctx.message.server
            try:
                msg = self.riceCog2[server.id]["warn_message"]
            except:
                msg = default_warn
            try:
                kick = self.riceCog2[server.id]["kick_message"]
            except:
                kick = default_kick
            try:
                _max = self.riceCog2[server.id]["max"]
            except:
                _max = default_max
            message =  "```\n"
            message += "Warn Message - {}\n"
            message += "Kick Message - {}\n"
            message += "Warn Limit   - {}\n"
            message += "```"
            await self.bot.say(message.format(msg, kick, _max))
warn.py 文件源码 项目:KeekoBot 作者: DavidNeon 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _warnset(self, ctx):
        if ctx.message.server.id not in self.riceCog2:
            self.riceCog2[ctx.message.server.id] = {}
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
            server = ctx.message.server
            try:
                msg = self.riceCog2[server.id]["warn_message"]
            except:
                msg = default_warn
            try:
                kick = self.riceCog2[server.id]["kick_message"]
            except:
                kick = default_kick
            try:
                _max = self.riceCog2[server.id]["max"]
            except:
                _max = default_max
            message =  "```\n"
            message += "Warn Message - {}\n"
            message += "Kick Message - {}\n"
            message += "Warn Limit   - {}\n"
            message += "```"
            await self.bot.say(message.format(msg, kick, _max))
google.py 文件源码 项目:KeekoBot 作者: DavidNeon 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def _googlesettings(self, ctx, maxresults: int=0):
        """Set the amount of results appearing"""

        if not self.maxresults:  # If statement incase someone removes it or sets it to 0
            self.maxresults = 3

        if maxresults == 0:
            message = box(
                "Current max search result is {}".format(self.maxresults))
            await send_cmd_help(ctx)
        elif maxresults > 10:
            await self.bot.say('`Cannot set max search results higher then 10`')
            return
        elif maxresults < 1:
            await self.bot.say('`Cannot set max search results lower then 0`')
            return
        else:
            self.maxresults = maxresults
            self.settings['MAXRESULTS'] = self.maxresults
            dataIO.save_json('data/google/settings.json', self.settings)
            message = '`Changed max search results to {} `'.format(
                self.maxresults)
        await self.bot.say(message)
radioharu.py 文件源码 项目:GrandeCogs 作者: HarukiGrande 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def radioharu(self, ctx):
        """Radio Haru"""
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
            await self.bot.say("https://radioharu.pw/")
googl.py 文件源码 项目:GrandeCogs 作者: HarukiGrande 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def googl(self, ctx):
        """Googl"""
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
webserver.py 文件源码 项目:GrandeCogs 作者: HarukiGrande 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def webserver(self, ctx):
        """Webserver"""
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
notebook.py 文件源码 项目:GrandeCogs 作者: HarukiGrande 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def notebook(self, ctx):
        """Notebook"""
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
dio.py 文件源码 项目:GrandeCogs 作者: HarukiGrande 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def dio(self, ctx):
        """Discord.io"""
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
cookie.py 文件源码 项目:Jumper-Cogs 作者: Redjumpman 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def setcookie(self, ctx):
        """Cookie settings group command"""

        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
lottery.py 文件源码 项目:Jumper-Cogs 作者: Redjumpman 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def lottery(self, ctx):
        """Lottery Group Command"""

        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
lottery.py 文件源码 项目:Jumper-Cogs 作者: Redjumpman 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def setlottery(self, ctx):
        """Lottery Settings"""

        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
russianroulette.py 文件源码 项目:Jumper-Cogs 作者: Redjumpman 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def setrussian(self, ctx):
        """Russian Roulette Settings"""

        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
shop.py 文件源码 项目:Jumper-Cogs 作者: Redjumpman 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def shop(self, ctx):
        """Shop Commands. Use !help Shop for other command groups"""

        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
shop.py 文件源码 项目:Jumper-Cogs 作者: Redjumpman 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def pending(self, ctx):
        """Pending list commands"""

        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)


问题


面经


文章

微信
公众号

扫码关注公众号