async def on_message(message): time_now = int(time.time()) """ do not interact with our own messages """ if message.author.id == client.user.id or message.author.bot == True: return if message.server != None: # Note that the user posted a message. active_map = active_users_map.get(message.server.id) if active_map == None: active_map = {} active_users_map[message.server.id] = active_map active_map[message.author.id] = True # Update player information. ewplayer.player_update(member=message.author, server=message.server) content_tolower = message.content.lower() re_awoo = re.compile('.*![a]+[w]+o[o]+.*') if message.content.startswith( ewcfg.cmd_prefix) or message.server == None or len( message.author.roles) < 2: """ Wake up if we need to respond to messages. Could be: message starts with ! direct message (server == None) user is new/has no roles (len(roles) < 2) """ # tokenize the message. the command should be the first word. try: tokens = shlex.split( message.content ) # it's split with shlex now because shlex regards text within quotes as a single token except: tokens = message.content.split( ' ' ) # if splitting via shlex doesnt work (odd number of quotes), use the old splitting method so it doesnt give an exception tokens_count = len(tokens) cmd = tokens[0].lower() # remove mentions to us mentions = list( filter(lambda user: user.id != client.user.id, message.mentions)) mentions_count = len(mentions) # Create command object cmd_obj = ewcmd.EwCmd(tokens=tokens, message=message, client=client, mentions=mentions) """ Handle direct messages. """ if message.server == None: # Direct message the player their inventory. if ewitem.cmd_is_inventory(cmd): return await ewitem.inventory_print(cmd_obj) elif cmd == ewcfg.cmd_inspect: return await ewitem.item_look(cmd_obj) # FIXME add this back when the help doc is updated. """ else: time_last = last_helped_times.get(message.author.id, 0) # Only send the help doc once every thirty seconds. There's no need to spam it. if (time_now - time_last) > 30: last_helped_times[message.author.id] = time_now await client.send_message(message.channel, 'Check out the guide for help: https://ew.krakissi.net/guide/') """ # Nothing else to do in a DM. return # assign the appropriate roles to a user with less than @everyone, faction, location if len(message.author.roles) < 3: return await ewrolemgr.updateRoles(client=client, member=message.author) # Scold/ignore offline players. if message.author.status == discord.Status.offline: response = "You cannot participate in the ENDLESS WAR while offline." await client.send_message( message.channel, ewutils.formatMessage(message.author, response)) return # Check the main command map for the requested command. global cmd_map cmd_fn = cmd_map.get(cmd) if cmd_fn != None: # Execute found command return await cmd_fn(cmd_obj) # FIXME debug # Test item creation elif debug == True and cmd == '!createtestitem': item_id = ewitem.item_create( item_type='medal', id_user=message.author.id, id_server=message.server.id, item_props={ 'medal_name': 'Test Award', 'medal_desc': '**{medal_name}**: *Awarded to Krak by Krak for testing shit.*' }) ewutils.logMsg('Created item: {}'.format(item_id)) item = EwItem(id_item=item_id) item.item_props['test'] = 'meow' item.persist() item = EwItem(id_item=item_id) await client.send_message( message.channel, ewutils.formatMessage(message.author, ewitem.item_look(item))) # Creates a poudrin elif debug == True and cmd == '!createpoudrin': item_id = ewitem.item_create(item_type=ewcfg.it_slimepoudrin, id_user=message.author.id, id_server=message.server.id) ewutils.logMsg('Created item: {}'.format(item_id)) item = EwItem(id_item=item_id) item.persist() item = EwItem(id_item=item_id) await client.send_message( message.channel, ewutils.formatMessage(message.author, "Poudrin created.")) # Gives the user some slime elif debug == True and cmd == '!getslime': user_data = EwUser(member=message.author) user_data.change_slimes(n=10000) user_data.persist() await client.send_message( message.channel, ewutils.formatMessage(message.author, "You receive 10,000 slime.")) # FIXME debug # Test item deletion elif debug == True and cmd == '!delete': items = ewitem.inventory(id_user=message.author.id, id_server=message.server.id) for item in items: ewitem.item_delete(id_item=item.get('id_item')) await client.send_message( message.channel, ewutils.formatMessage(message.author, 'ok')) # AWOOOOO elif re_awoo.match(cmd): return await ewcmd.cmd_howl(cmd_obj) # Debug command to override the role of a user elif debug == True and cmd == (ewcfg.cmd_prefix + 'setrole'): response = "" if mentions_count == 0: response = 'Set who\'s role?' else: roles_map = ewutils.getRoleMap(message.server.roles) role_target = tokens[1] role = roles_map.get(role_target) if role != None: for user in mentions: await client.replace_roles(user, role) response = 'Done.' else: response = 'Unrecognized role.' await client.send_message( cmd.message.channel, ewutils.formatMessage(message.author, response)) # didn't match any of the command words. else: """ couldn't process the command. bail out!! """ """ bot rule 0: be cute """ randint = random.randint(1, 3) msg_mistake = "ENDLESS WAR is growing frustrated." if randint == 2: msg_mistake = "ENDLESS WAR denies you his favor." elif randint == 3: msg_mistake = "ENDLESS WAR pays you no mind." msg = await client.send_message(cmd_obj.message.channel, msg_mistake) await asyncio.sleep(2) await client.delete_message(msg) elif content_tolower.find(ewcfg.cmd_howl) >= 0 or content_tolower.find( ewcfg.cmd_howl_alt1) >= 0 or re_awoo.match(content_tolower): """ Howl if !howl is in the message at all. """ return await ewcmd.cmd_howl(ewcmd.EwCmd(message=message, client=client))
async def on_message(message): time_now = int(time.time()) """ do not interact with our own messages """ if message.author.id == client.user.id or message.author.bot == True: return if message.server != None: # Note that the user posted a message. active_map = active_users_map.get(message.server.id) if active_map == None: active_map = {} active_users_map[message.server.id] = active_map active_map[message.author.id] = True # Update player information. ewplayer.player_update(member=message.author, server=message.server) content_tolower = message.content.lower() re_awoo = re.compile('.*![a]+[w]+o[o]+.*') if message.content.startswith( ewcfg.cmd_prefix) or message.server == None or len( message.author.roles) < 2: """ Wake up if we need to respond to messages. Could be: message starts with ! direct message (server == None) user is new/has no roles (len(roles) < 2) """ # tokenize the message. the command should be the first word. tokens = message.content.split(' ') tokens_count = len(tokens) cmd = tokens[0].lower() # remove mentions to us mentions = list( filter(lambda user: user.id != client.user.id, message.mentions)) mentions_count = len(mentions) # Create command object cmd_obj = ewcmd.EwCmd(tokens=tokens, message=message, client=client, mentions=mentions) """ reply to DMs with help document """ if message.server == None: # Direct message the player their inventory. if ewitem.cmd_is_inventory(cmd): return await ewitem.inventory_print(cmd_obj) else: time_last = last_helped_times.get(message.author.id, 0) # Only send the help doc once every thirty seconds. There's no need to spam it. if (time_now - time_last) > 30: last_helped_times[message.author.id] = time_now await client.send_message( message.channel, 'Check out the guide for help: https://ew.krakissi.net/guide/' ) # Nothing else to do in a DM. return # common data we'll need roles_map = cmd_obj.roles_map # assign the juveniles role to a user with only 1 or 0 roles. if len(message.author.roles) < 2: role_juvenile = roles_map[ewcfg.role_juvenile] await client.replace_roles(message.author, role_juvenile) return # Scold/ignore offline players. if message.author.status == discord.Status.offline: resp = await ewcmd.start(cmd=cmd_obj) response = "You cannot participate in the ENDLESS WAR while offline." if resp != None: await client.edit_message( resp, ewutils.formatMessage(message.author, response)) else: await client.send_message( message.channel, ewutils.formatMessage(message.author, response)) return # process command words if cmd == ewcfg.cmd_kill or cmd == ewcfg.cmd_shoot: return await ewwep.attack(cmd_obj) # Choose your weapon elif cmd == ewcfg.cmd_equip: return await ewwep.equip(cmd_obj) # Kill yourself to return slime to your general. elif cmd == ewcfg.cmd_suicide: return await ewwep.suicide(cmd_obj) # Spar with an ally elif cmd == ewcfg.cmd_spar: return await ewwep.spar(cmd_obj) # Name your current weapon. elif cmd == ewcfg.cmd_annoint: return await ewwep.annoint(cmd_obj) # move from juvenile to one of the armies (rowdys or killers) elif cmd == ewcfg.cmd_enlist: return await ewjuviecmd.enlist(cmd_obj) # gives slime to the miner (message.author) elif cmd == ewcfg.cmd_mine: return await ewjuviecmd.mine(cmd_obj) # Show the current slime score of a player. elif cmd == ewcfg.cmd_score or cmd == ewcfg.cmd_score_alt1: return await ewcmd.score(cmd_obj) # Show a player's combat data. elif cmd == ewcfg.cmd_data: return await ewcmd.data(cmd_obj) #check what time it is, and the weather elif cmd == ewcfg.cmd_time or cmd == ewcfg.cmd_clock or cmd == ewcfg.cmd_weather: return await ewcmd.weather(cmd_obj) # Show the total of negative slime in the world. elif cmd == ewcfg.cmd_negaslime: return await ewspooky.negaslime(cmd_obj) # revive yourself as a juvenile after having been killed. elif cmd == ewcfg.cmd_revive: return await ewspooky.revive(cmd_obj) # Ghosts can haunt enlisted players to reduce their slime score. elif cmd == ewcfg.cmd_haunt: return await ewspooky.haunt(cmd_obj) # Play slime pachinko! elif cmd == ewcfg.cmd_slimepachinko: return await ewcasino.pachinko(cmd_obj) # Toss the dice at slime craps! elif cmd == ewcfg.cmd_slimecraps: return await ewcasino.craps(cmd_obj) # Pull the lever on a slot machine! elif cmd == ewcfg.cmd_slimeslots: return await ewcasino.slots(cmd_obj) # See what's for sale in the Food Court. elif cmd == ewcfg.cmd_menu: return await ewfood.menu(cmd_obj) # Order refreshing food and drinks! elif cmd == ewcfg.cmd_order: return await ewfood.order(cmd_obj) # Transfer slime between players. Shares a cooldown with investments. elif cmd == ewcfg.cmd_transfer or cmd == ewcfg.cmd_transfer_alt1: return await ewmarket.xfer(cmd_obj) # Invest in the slime market! elif cmd == ewcfg.cmd_invest: return await ewmarket.invest(cmd_obj) # Withdraw your investments! elif cmd == ewcfg.cmd_withdraw: return await ewmarket.withdraw(cmd_obj) # Show the current slime market exchange rate (slime per credit). elif cmd == ewcfg.cmd_exchangerate or cmd == ewcfg.cmd_exchangerate_alt1: return await ewmarket.rate(cmd_obj) # Show the player's slime credit. elif cmd == ewcfg.cmd_slimecredit or cmd == ewcfg.cmd_slimecredit_alt1: return await ewmarket.slimecoin(cmd_obj) # faction leader consumes the mentioned players of their own faction to absorb their slime count # kills the mentioned players elif cmd == ewcfg.cmd_devour: return await ewkingpin.devour(cmd_obj) # rowdy f****r and cop killer (leaders) can give slimes to anybody elif cmd == ewcfg.cmd_giveslime or cmd == ewcfg.cmd_giveslime_alt1: return await ewkingpin.giveslime(cmd_obj) # Remove a megaslime (1 mil slime) from a general. elif cmd == ewcfg.cmd_deadmega: return await ewkingpin.deadmega(cmd_obj) # FIXME debug # Test item creation elif cmd == '!create': item_id = ewitem.item_create( item_type='medal', id_user=message.author.id, id_server=message.server.id, item_props={ 'medal_name': 'Test Award', 'medal_desc': '**{medal_name}**: *Awarded to Krak by Krak for testing shit.*' }) ewutils.logMsg('Created item: {}'.format(item_id)) item = EwItem(id_item=item_id) item.item_props['test'] = 'meow' item.persist() item = EwItem(id_item=item_id) await client.send_message( message.channel, ewutils.formatMessage(message.author, ewitem.item_look(item))) # FIXME debug # Test item deletion elif cmd == '!delete': items = ewitem.inventory(id_user=message.author.id, id_server=message.server.id) for item in items: ewitem.item_delete(id_item=item.get('id_item')) await client.send_message( message.channel, ewutils.formatMessage(message.author, 'ok')) # Direct message the player their inventory. elif ewitem.cmd_is_inventory(cmd): return await ewitem.inventory_print(cmd_obj) # !harvest is not a command elif cmd == ewcfg.cmd_harvest: await client.send_message( message.channel, ewutils.formatMessage( message.author, '**HARVEST IS NOT A COMMAND YOU F*****G IDIOT**')) # AWOOOOO elif cmd == ewcfg.cmd_howl or cmd == ewcfg.cmd_howl_alt1 or re_awoo.match( cmd): return await ewcmd.cmd_howl(cmd_obj) # advertise patch notes elif cmd == ewcfg.cmd_patchnotes: await client.send_message( message.channel, ewutils.formatMessage( message.author, 'Look for the latest patchnotes on the news page: https://ew.krakissi.net/news/' )) # advertise help services elif cmd == ewcfg.cmd_help or cmd == ewcfg.cmd_help_alt1 or cmd == ewcfg.cmd_help_alt2: await client.send_message( message.channel, ewutils.formatMessage( message.author, 'Check out the guide for help: https://ew.krakissi.net/guide/' )) # Debug command to override the role of a user elif debug == True and cmd == (ewcfg.cmd_prefix + 'setrole'): resp = await ewcmd.start(cmd=cmd_obj) response = "" if mentions_count == 0: response = 'Set who\'s role?' else: role_target = tokens[1] role = roles_map.get(role_target) if role != None: for user in mentions: await client.replace_roles(user, role) response = 'Done.' else: response = 'Unrecognized role.' await client.edit_message( resp, ewutils.formatMessage(message.author, response)) # didn't match any of the command words. else: resp = await ewcmd.start(cmd=cmd_obj) """ couldn't process the command. bail out!! """ """ bot rule 0: be cute """ randint = random.randint(1, 3) msg_mistake = "ENDLESS WAR is growing frustrated." if randint == 2: msg_mistake = "ENDLESS WAR denies you his favor." elif randint == 3: msg_mistake = "ENDLESS WAR pays you no mind." await asyncio.sleep(1) await client.edit_message(resp, msg_mistake) await asyncio.sleep(2) await client.delete_message(resp) elif content_tolower.find(ewcfg.cmd_howl) >= 0 or content_tolower.find( ewcfg.cmd_howl_alt1) >= 0 or re_awoo.match(content_tolower): """ Howl if !howl is in the message at all. """ return await ewcmd.cmd_howl(ewcmd.EwCmd(message=message, client=client))
async def on_message(message): time_now = int(time.time()) ewcfg.set_client(client) """ do not interact with our own messages """ if message.author.id == client.user.id or message.author.bot == True: return if message.server != None: # Note that the user posted a message. active_map = active_users_map.get(message.server.id) if active_map == None: active_map = {} active_users_map[message.server.id] = active_map active_map[message.author.id] = True # Update player information. ewplayer.player_update( member = message.author, server = message.server ) content_tolower = message.content.lower() re_awoo = re.compile('.*![a]+[w]+o[o]+.*') # update the player's time_last_action which is used for kicking AFK players out of subzones if message.server != None: try: ewutils.execute_sql_query("UPDATE users SET {time_last_action} = %s WHERE id_user = %s AND id_server = %s".format( time_last_action = ewcfg.col_time_last_action ), ( int(time.time()), message.author.id, message.server.id )) except: ewutils.logMsg('server {}: failed to update time_last_action for {}'.format(message.server.id, message.author.id)) user_data = EwUser(member = message.author) statuses = user_data.getStatusEffects() if ewcfg.status_strangled_id in statuses: strangle_effect = EwStatusEffect(id_status=ewcfg.status_strangled_id, user_data=user_data) source = EwPlayer(id_user=strangle_effect.source, id_server=message.server.id) response = "You manage to break {}'s garrote wire!".format(source.display_name) user_data.clear_status(ewcfg.status_strangled_id) return await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response)) if message.content.startswith(ewcfg.cmd_prefix) or message.server == None or len(message.author.roles) < 2: """ Wake up if we need to respond to messages. Could be: message starts with ! direct message (server == None) user is new/has no roles (len(roles) < 2) """ #Ignore users with weird characters in their name try: message.author.display_name[:3].encode('utf-8').decode('ascii') except UnicodeError: return await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, "We don't take kindly to moon runes around here.")) # tokenize the message. the command should be the first word. try: tokens = shlex.split(message.content) # it's split with shlex now because shlex regards text within quotes as a single token except: tokens = message.content.split(' ') # if splitting via shlex doesnt work (odd number of quotes), use the old splitting method so it doesnt give an exception tokens_count = len(tokens) cmd = tokens[0].lower() if tokens_count >= 1 else "" # remove mentions to us mentions = list(filter(lambda user : user.id != client.user.id, message.mentions)) mentions_count = len(mentions) # Create command object cmd_obj = ewcmd.EwCmd( tokens = tokens, message = message, client = client, mentions = mentions ) """ Handle direct messages. """ if message.server == None: playermodel = ewplayer.EwPlayer(id_user = message.author.id) usermodel = EwUser(id_user=message.author.id, id_server= playermodel.id_server) poi = ewcfg.id_to_poi.get(usermodel.poi) # Direct message the player their inventory. if ewitem.cmd_is_inventory(cmd): return await ewitem.inventory_print(cmd_obj) elif cmd == ewcfg.cmd_inspect: return await ewitem.item_look(cmd_obj) elif poi.is_apartment: return await ewapt.aptCommands(cmd=cmd_obj) else: time_last = last_helped_times.get(message.author.id, 0) # Only send the help doc once every thirty seconds. There's no need to spam it. if (time_now - time_last) > 30: last_helped_times[message.author.id] = time_now await ewutils.send_message(client, message.channel, ewcfg.generic_help_response) # Nothing else to do in a DM. return # assign the appropriate roles to a user with less than @everyone, faction, location if len(message.author.roles) < 3: await ewrolemgr.updateRoles(client = client, member = message.author) user_data = EwUser(member = message.author) if user_data.arrested: return mutations = user_data.get_mutations() # Scold/ignore offline players. if message.author.status == discord.Status.offline: if ewcfg.mutation_id_chameleonskin not in mutations or cmd not in ewcfg.offline_cmds: response = "You cannot participate in the ENDLESS WAR while offline." return await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response)) if user_data.time_lastoffline > time_now - ewcfg.time_offline: if ewcfg.mutation_id_chameleonskin not in mutations or cmd not in ewcfg.offline_cmds: response = "You are too paralyzed by ENDLESS WAR's judgemental stare to act." return await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response)) # Ignore stunned players if ewcfg.status_stunned_id in statuses: return # Check the main command map for the requested command. global cmd_map cmd_fn = cmd_map.get(cmd) if user_data.poi in ewcfg.tutorial_pois: return await ewdungeons.tutorial_cmd(cmd_obj) elif cmd_fn != None: # Execute found command return await cmd_fn(cmd_obj) # FIXME debug # Test item creation elif debug == True and cmd == (ewcfg.cmd_prefix + 'createtestitem'): item_id = ewitem.item_create( item_type = 'medal', id_user = message.author.id, id_server = message.server.id, item_props = { 'medal_name': 'Test Award', 'medal_desc': '**{medal_name}**: *Awarded to Krak by Krak for testing shit.*' } ) ewutils.logMsg('Created item: {}'.format(item_id)) item = EwItem(id_item = item_id) item.item_props['test'] = 'meow' item.persist() item = EwItem(id_item = item_id) await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, ewitem.item_look(item))) # Creates a poudrin elif debug == True and cmd == (ewcfg.cmd_prefix + 'createpoudrin'): for item in ewcfg.item_list: if item.context == "poudrin": ewitem.item_create( item_type = ewcfg.it_item, id_user = message.author.id, id_server = message.server.id, item_props = { 'id_item': item.id_item, 'context': item.context, 'item_name': item.str_name, 'item_desc': item.str_desc, } ), ewutils.logMsg('Created item: {}'.format(item.id_item)) item = EwItem(id_item = item.id_item) item.persist() else: pass await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, "Poudrin created.")) # Gives the user some slime elif debug == True and cmd == (ewcfg.cmd_prefix + 'getslime'): user_data = EwUser(member = message.author) user_initial_level = user_data.slimelevel response = "You get 100,000 slime!" levelup_response = user_data.change_slimes(n = 100000) was_levelup = True if user_initial_level < user_data.slimelevel else False if was_levelup: response += " {}".format(levelup_response) user_data.persist() await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response)) elif debug == True and cmd == (ewcfg.cmd_prefix + 'getcoin'): user_data = EwUser(member=message.author) user_data.change_slimecoin(n=1000000000, coinsource=ewcfg.coinsource_spending) response = "You get 1,000,000,000 slimecoin!" user_data.persist() await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response)) # Deletes all items in your inventory. elif debug == True and cmd == (ewcfg.cmd_prefix + 'clearinv'): user_data = EwUser(member = message.author) ewitem.item_destroyall(id_server = message.server.id, id_user = message.author.id) response = "You destroy every single item in your inventory." user_data.persist() await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response)) elif debug == True and cmd == (ewcfg.cmd_prefix + 'createapple'): item_id = ewitem.item_create( id_user = message.author.id, id_server = message.server.id, item_type = ewcfg.it_food, item_props = { 'id_food': "direapples", 'food_name': "Dire Apples", 'food_desc': "This sure is a illegal Dire Apple!", 'recover_hunger': 500, 'str_eat': "You chomp into this illegal Dire Apple.", 'time_expir': int(time.time() + ewcfg.farm_food_expir) } ) ewutils.logMsg('Created item: {}'.format(item_id)) item = EwItem(id_item = item_id) item.item_props['test'] = 'meow' item.persist() await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, "Apple created.")) elif debug == True and cmd == (ewcfg.cmd_prefix + 'createhat'): patrician_rarity = 20 patrician_smelted = random.randint(1, patrician_rarity) patrician = False if patrician_smelted == 1: patrician = True items = [] for cosmetic in ewcfg.cosmetic_items_list: if patrician and cosmetic.rarity == ewcfg.rarity_patrician: items.append(cosmetic) elif not patrician and cosmetic.rarity == ewcfg.rarity_plebeian: items.append(cosmetic) item = items[random.randint(0, len(items) - 1)] item_id = ewitem.item_create( item_type = ewcfg.it_cosmetic, id_user = message.author.id, id_server = message.server.id, item_props = { 'id_cosmetic': item.id_cosmetic, 'cosmetic_name': item.str_name, 'cosmetic_desc': item.str_desc, 'rarity': item.rarity, 'adorned': 'false' } ) ewutils.logMsg('Created item: {}'.format(item_id)) item = EwItem(id_item = item_id) item.item_props['test'] = 'meow' item.persist() await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, "Hat created.")) elif debug == True and cmd == (ewcfg.cmd_prefix + 'createfood'): item = ewcfg.food_list[random.randint(0, len(ewcfg.food_list) - 1)] item_id = ewitem.item_create( item_type = ewcfg.it_food, id_user = message.author.id, id_server = message.server.id, item_props = { 'id_food': item.id_food, 'food_name': item.str_name, 'food_desc': item.str_desc, 'recover_hunger': item.recover_hunger, 'str_eat': item.str_eat, 'time_expir': item.time_expir } ) ewutils.logMsg('Created item: {}'.format(item_id)) item = EwItem(id_item = item_id) item.item_props['test'] = 'meow' item.persist() await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, "Food created.")) # FIXME debug # Test item deletion elif debug == True and cmd == (ewcfg.cmd_prefix + 'delete'): items = ewitem.inventory( id_user = message.author.id, id_server = message.server.id ) for item in items: ewitem.item_delete( id_item = item.get('id_item') ) await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, 'ok')) # AWOOOOO elif re_awoo.match(cmd): return await ewcmd.cmd_howl(cmd_obj) # Debug command to override the role of a user elif debug == True and cmd == (ewcfg.cmd_prefix + 'setrole'): response = "" if mentions_count == 0: response = 'Set who\'s role?' else: roles_map = ewutils.getRoleMap(message.server.roles) role_target = tokens[1] role = roles_map.get(role_target) if role != None: for user in mentions: try: await client.replace_roles(user, role) except: ewutils.logMsg('Failed to replace_roles for user {} with {}.'.format(user.display_name, role.name)) response = 'Done.' else: response = 'Unrecognized role.' await ewutils.send_message(client, cmd.message.channel, ewutils.formatMessage(message.author, response)) elif debug == True and cmd == (ewcfg.cmd_prefix + 'getrowdy'): response = "You get rowdy. F**k. YES!" user_data = EwUser(member=message.author) user_data.life_state = ewcfg.life_state_enlisted user_data.faction = ewcfg.faction_rowdys user_data.time_lastenlist = time_now + ewcfg.cd_enlist user_data.persist() await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response)) elif debug == True and cmd == (ewcfg.cmd_prefix + 'getkiller'): response = "You uh... 'get' killer. Sure." user_data = EwUser(member=message.author) user_data.life_state = ewcfg.life_state_enlisted user_data.faction = ewcfg.faction_killers user_data.time_lastenlist = time_now + ewcfg.cd_enlist user_data.persist() await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response)) # Toggles rain on and off elif debug == True and cmd == (ewcfg.cmd_prefix + 'toggledownfall'): market_data = EwMarket(id_server=message.server.id) if market_data.weather == ewcfg.weather_bicarbonaterain: newweather = ewcfg.weather_sunny market_data.weather = newweather response = "Bicarbonate rain turned OFF. Weather was set to {}.".format(newweather) else: market_data.weather = ewcfg.weather_bicarbonaterain response = "Bicarbonate rain turned ON." market_data.persist() await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response)) elif debug == True and cmd == (ewcfg.cmd_prefix + 'dayforward'): market_data = EwMarket(id_server=message.server.id) market_data.day += 1 market_data.persist() response = "Time has progressed 1 day forward manually." if ewutils.check_fursuit_active(market_data.id_server): response += "\nIt's a full moon!" await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response)) elif debug == True and cmd == (ewcfg.cmd_prefix + 'hourforward'): market_data = EwMarket(id_server=message.server.id) market_data.clock += 1 response = "Time has progressed 1 hour forward manually." if market_data.clock >= 24 or market_data.clock < 0: market_data.clock = 0 market_data.day += 1 response += "\nMidnight has come. 1 day progressed forward." if ewutils.check_fursuit_active(market_data.id_server): response += "\nIt's a full moon!" market_data.persist() await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response)) # didn't match any of the command words. else: """ couldn't process the command. bail out!! """ """ bot rule 0: be cute """ randint = random.randint(1,3) msg_mistake = "ENDLESS WAR is growing frustrated." if randint == 2: msg_mistake = "ENDLESS WAR denies you his favor." elif randint == 3: msg_mistake = "ENDLESS WAR pays you no mind." msg = await ewutils.send_message(client, cmd_obj.message.channel, msg_mistake) await asyncio.sleep(2) try: await client.delete_message(msg) except: pass elif content_tolower.find(ewcfg.cmd_howl) >= 0 or content_tolower.find(ewcfg.cmd_howl_alt1) >= 0 or re_awoo.match(content_tolower): """ Howl if !howl is in the message at all. """ return await ewcmd.cmd_howl(ewcmd.EwCmd( message = message, client = client ))