def __init__(self, args, ftp): Command.__init__(self, args, ftp) self.error_message = "Usage : cat [OPTION] <filename>"
""" grabs a random inspirational image from the inspirobot website. """ import discord import requests from modules.Command import Command from master import handler name = "inspire" group = "fun" description = "gets a random inspirational image from http://inspirobot.me" @handler.command(Command(name, group, description)) async def inspire(bot, msg, args): request = requests.get("http://inspirobot.me/api?generate=true") if not request.status_code == 200: await bot.send_message( msg.channel, "inspirobot failed to generate an inspirational image.") return embed = discord.Embed(type="rich") embed.set_footer(text="retrieved from http://inspirobot.me", icon_url="https://i.imgur.com/Qds5KNu.png") embed.set_image(url=request.text) await bot.send_message(msg.channel, embed=embed)
def __init__(self, args, ftp): Command.__init__(self, args, ftp)
async def on_message(message: Message): if message.author != client.user and message.content.startswith('$'): try: command = Command.instantiate(message.content) except ValueError as e: if str(e).endswith('SubWeapon'): text = '' for it in SubWeapon: text += str(it.value) + '\n' await message.channel.send( f'サブウェポンの名前が違うかも:thinking:\n```{text}```') elif str(e).endswith('Category'): text = '' for it in Category: text += str(it.value) + '\n' await message.channel.send( f'ブキ種の名前が違うかも:thinking:\n```{text}```') elif str(e).endswith('SpecialWeapon'): text = '' for it in SpecialWeapon: text += str(it.value) + '\n' await message.channel.send( f'スペシャルウェポンの名前が違うかも:thinking:\n```{text}```') elif str(e).endswith('Custom'): text = '' for it in Custom: text += str(it.value) + '\n' await message.channel.send(f'そのカスタムは知らないです...\n```{text}```') else: await message.channel.send( f'パラメータの変換に失敗しました:man_bowing::man_bowing::man_bowing:\n```{e}```' ) return weapons = command.execute() if len(weapons) <= 0: await message.channel.send( f'{message.author.mention} ソンナブキ(ヾノ・∀・`)ナイナイ') elif command.func is Function.give_me: if len(weapons) <= 1: await message.channel.send( f'{message.author.mention} (っ\'-\')╮ =͟͟͞͞ **{weapons[0].name}** ブォン' ) else: weapon = weapons[random.randrange(0, len(weapons) - 1)] await message.channel.send( f'{message.author.mention} (っ\'-\')╮ =͟͟͞͞ **{weapon.name}** ブォン' ) elif command.func is Function.give: for channel in message.guild.voice_channels: # type: VoiceChannel for member in channel.members: # type: Member if len(weapons) <= 1: await message.channel.send( f'{message.author.mention} (っ\'-\')╮ =͟͟͞͞ **{weapons[0].name}** ブォン' ) else: weapon = weapons[random.randrange(0, len(weapons) - 1)] await message.channel.send( f'{member.mention}(っ\'-\')╮ =͟͟͞͞ **{weapon.name}** ブォン' ) elif command.func is Function.help: await message.channel.send( f'ブキくじ\n' f'---- commands ----\n' f'`$give` : ボイスチャンネル接続中の全員に武器をわたす\n' f'`$give-me` : 自分にだけ武器をわたす\n' f'`$help` : ヘルプの表示\n\n' f'---- options ----\n' f'`--cat` , `--category` : 武器種をきめる ex: `$give --cat=シューター` \n' f'`--sub` : サブウェポンをきめる ex: `$give --sub=スプラッシュボム` \n' f'`--special` : スペシャルウェポンをきめる ex: `$give --special=スーパーチャクチ` \n' f'`--custom` : カスタムをきめる ex: `$give --custom=ブキチセレクション` `$give --custom=無印`\n' f'`--with-replica` : レプリカ系を含める(デフォルトは無効) ex: `$give --with-replica`\n' f'`--not` : 他のoptionと一緒に使うとnot検索(対象に含めず)ができるようになるぞ\n' f':warning: いずれも正式名称じゃないと動かないので注意 :warning:\n' f':heart: オプションは併用できます(同一オプションはOR、他オプションはAND) :heart:\n\n' f'Powered by GhostServer JP\n' f'ソースコード : https://github.com/DenpaGhost/discord-bukikujibot')
def __init__(self, args, ftp): Command.__init__(self, args, ftp) self.total_size = []