def on_message(message): command = message.content.lower() if message.author == client.user: return elif command == '&': yield from message.channel.send( '<@{0}>, No command has been passed.'.format(message.author.id)) elif command == '&help': yield from message.channel.send(Command.help()) elif command == '&hello': yield from message.channel.send(Command.hello(message.author.id)) elif command.startswith('&factory create'): parts = command.replace('&factory create', '').split('&') if len(parts) != 2: response = '''No has usado bien el comando. Hay que usar: `&factory create <Nombre fabrica>&<Nombre producto>` Por ejemplo: `&factory create mi fabrica de tomates&tomate` ''' else: response = Command.createFactory(message.author.id, parts[0].strip(), parts[1].strip()) yield from message.channel.send(response) elif command == '&factory delete': yield from message.channel.send( Command.deleteFactory(message.author.id)) elif command == '&factory list': yield from message.channel.send(Command.listFactory()) elif command == '&inventory': yield from message.channel.send(Command.inventory(message.author.id)) elif command == '&tft random_classes': yield from message.channel.send( Command.tftRandomClasses(message.author.id)) elif command == '&tft hidden_quest help': responses = Command.tftHiddenQuestHelp() yield from message.channel.send(responses[0]) yield from message.channel.send(responses[1]) elif command.startswith('&tft hidden_quest create'): parts = command.split(' ') if len(parts) == 3: yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.create(message.author, message.channel))) elif len(parts) == 4: yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.create(message.author, message.channel, parts[3]))) else: yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.create(message.author, message.channel, parts[3], parts[4]))) elif command.startswith('&tft hidden_quest join'): parts = command.split(' ') if len(parts) < 4: yield from message.channel.send( 'Es necesario especificar el ID de la sala a la que te quieres unir. Por ejemplo, `&tft hidden_quest join patata-18`.' ) else: yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.join(message.author, parts[3]))) elif command.startswith('&tft hidden_quest destroy'): yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.destroy(message.author))) elif command.startswith('&tft hidden_quest leave'): yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.leave(message.author))) elif command.startswith('&tft hidden_quest reroll'): yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.reroll(message.author))) elif command.startswith('&tft hidden_quest ready'): yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.ready(message.author))) elif command.startswith('&tft hidden_quest start'): yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.start(message.author))) elif command.startswith('&tft hidden_quest end'): parts = command.split(' ') if len(parts) < 5: yield from message.channel.send( 'Es necesario especificar la posición en la que has quedado y si has cumplido tu misión (y) o no (n). Por ejemplo, si has quedado 5º y has fracasado en tu misión secreta, deberías poner: `&tft hidden_quest end 3 n`.' ) else: yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.end(message.author, parts[3], parts[4]))) elif command.startswith('&tft hidden_quest status'): response = TFTHiddenQuestsCommands.status(message.author) if response is not None: yield from message.channel.send('{0}'.format(response)) elif command.startswith('&leet'): response = Command.leet_speak(command.replace('&leet', '')) yield from message.channel.send('{0}'.format(response))
def on_message(message): command = applyShortcuts(message.content.lower()) if message.author == client.user: return elif isinstance(message.channel, discord.DMChannel): Command.givePresentInvisibleFriend(message) elif command == '&': yield from message.channel.send( '<@{0}>, No command has been passed.'.format(message.author.id)) elif command == '&help': yield from message.channel.send(Command.help()) elif command == '&hello': yield from message.channel.send(Command.hello(message.author.id)) elif command.startswith('&factory create'): parts = command.replace('&factory create', '').split('&') if len(parts) != 2: response = '''No has usado bien el comando. Hay que usar: `&factory create <Nombre fabrica>&<Nombre producto>` Por ejemplo: `&factory create mi fabrica de tomates&tomate` ''' else: response = Command.createFactory(message.author.id, parts[0].strip(), parts[1].strip()) yield from message.channel.send(response) elif command == '&factory delete': yield from message.channel.send( Command.deleteFactory(message.author.id)) elif command == '&factory list': yield from message.channel.send(Command.listFactory()) elif command == '&inventory': yield from message.channel.send(Command.inventory(message.author.id)) elif command.startswith('&invisible_friend h'): responses = Command.invisibleFriendHelp() yield from message.channel.send( '<@{0}>, te he enviado un mensaje privado.'.format( message.author.id)) yield from message.author.send(responses[0]) yield from message.author.send(responses[1]) return elif command.startswith('&invisible_friend'): isSecretTarget = False isSecretGiver = False isPrivateGiver = False isPrivatePresent = False parts = command.split(' ') for part in parts: if part == 'secret_target' or part == 'st': isSecretTarget = True if part == 'secret_giver' or part == 'sg': isSecretGiver = True if part == 'private_giver' or part == 'pg': isPrivateGiver = True if part == 'private_present' or part == 'pp': isPrivatePresent = True Command.invisibleFriend(message, isSecretTarget, isSecretGiver, isPrivateGiver, isPrivatePresent) elif command.startswith('&russe_roulette'): parts = command.split(' ') size = 6 bullets = 1 if len(parts) >= 2: try: size = int(parts[1]) except: yield from message.channel.send( '"{0}" no es un número válido para la capacidad de la pistola.' .format(parts[1])) return if len(parts) >= 3: try: bullets = int(parts[2]) except: yield from message.channel.send( '"{0}" no es una cantidad válida de balas de la pistola.'. format(parts[2])) return Command.russeRoulette(message.channel, size, bullets) elif command == '&alaputa': yield from message.channel.send(Command.alaputa()) #ADD BY FranciscoJavierValero 28/3/20 2:21 elif command.startswith('&roll'): parts = command.split(' ') yield from message.channel.send(Command.roll(parts[1])) #END ADD elif command == '&tft random_classes': yield from message.channel.send( Command.tftRandomClasses(message.author.id)) elif command == '&tft hidden_quest help': responses = Command.tftHiddenQuestHelp() yield from message.channel.send(responses[0]) yield from message.channel.send(responses[1]) elif command == '&tft hidden_quest commands': yield from message.channel.send(Command.tftHiddenQuestCommands()) elif command.startswith('&tft hidden_quest create'): parts = command.split(' ') if len(parts) == 3: yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.create(message.author, message.channel))) elif len(parts) == 4: yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.create(message.author, message.channel, parts[3]))) else: yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.create(message.author, message.channel, parts[3], parts[4]))) elif command.startswith('&tft hidden_quest join'): parts = command.split(' ') if len(parts) < 4: yield from message.channel.send( 'Es necesario especificar el ID de la sala a la que te quieres unir. Por ejemplo, `&tft hidden_quest join patata-18`.' ) else: yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.join(message.author, parts[3]))) elif command.startswith('&tft hidden_quest destroy'): yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.destroy(message.author))) elif command.startswith('&tft hidden_quest leave'): yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.leave(message.author))) elif command.startswith('&tft hidden_quest reroll'): yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.reroll(message.author))) elif command.startswith('&tft hidden_quest ready'): yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.ready(message.author))) elif command.startswith('&tft hidden_quest start'): yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.start(message.author))) elif command.startswith('&tft hidden_quest end'): parts = command.split(' ') if len(parts) < 5: yield from message.channel.send( 'Es necesario especificar la posición en la que has quedado y si has cumplido tu misión (y) o no (n). Por ejemplo, si has quedado 5º y has fracasado en tu misión secreta, deberías poner: `&tft hidden_quest end 3 n`.' ) else: yield from message.channel.send('{0}'.format( TFTHiddenQuestsCommands.end(message.author, parts[3], parts[4]))) elif command.startswith('&tft hidden_quest status'): response = TFTHiddenQuestsCommands.status(message.author) if response is not None: yield from message.channel.send('{0}'.format(response)) elif random.randint(0, 2000) == 1000: yield from message.add_reaction('<:Gartu:689953022285185089>') elif random.randint(0, 1000) == 1000: yield from message.add_reaction(random.choice(client.emojis)) elif random.randint(0, 1000) == 1000: yield from message.add_reaction(random.choice(emojis)) elif random.randint(0, 2000) == 1000: yield from message.add_reaction('✅')