async def hogtie(cmd): if not cmd.message.author.guild_permissions.administrator: return await ewutils.fake_failed_command(cmd) else: if cmd.mentions_count == 1: target_data = EwUser(member=cmd.mentions[0]) target_status = target_data.getStatusEffects() if ewcfg.status_hogtied_id in target_status: target_data.clear_status(id_status=ewcfg.status_hogtied_id) response = "Whew-whee! She's buckin' so we gotta let 'er go." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: target_data.applyStatus(ewcfg.status_hogtied_id) response = "Boy howdy! Looks like we lasso'd up a real heifer there! A dang ol' big'un." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def cast(cmd): time_now = round(time.time()) has_reeled = False user_data = EwUser(member = cmd.message.author) market_data = EwMarket(id_server = cmd.message.author.server.id) statuses = user_data.getStatusEffects() if cmd.message.author.id not in fishers.keys(): fishers[cmd.message.author.id] = EwFisher() fisher = fishers[cmd.message.author.id] # Ghosts cannot fish. if user_data.life_state == ewcfg.life_state_corpse: response = "You can't fish while you're dead. Try {}.".format(ewcfg.cmd_revive) # Players who are already cast a line cannot cast another one. elif fisher.fishing == True: response = "You've already cast a line." # Only fish at The Pier elif cmd.message.channel.name in [ewcfg.channel_tt_pier, ewcfg.channel_jp_pier, ewcfg.channel_cl_pier, ewcfg.channel_afb_pier, ewcfg.channel_vc_pier, ewcfg.channel_se_pier, ewcfg.channel_ferry]: if user_data.hunger >= ewutils.hunger_max_bylevel(user_data.slimelevel): response = "You're too hungry to fish right now." else: has_fishingrod = False if user_data.weapon >= 0: weapon_item = EwItem(id_item = user_data.weapon) weapon = ewcfg.weapon_map.get(weapon_item.item_props.get("weapon_type")) if weapon.id_weapon == "fishingrod": has_fishingrod = True if ewcfg.status_high_id in statuses: fisher.high = True fisher.current_fish = gen_fish(market_data, cmd, has_fishingrod) fisher.fishing = True fisher.bait = False fisher.pier = user_data.poi item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) author = cmd.message.author server = cmd.message.server item_sought = ewitem.find_item(item_search = item_search, id_user = author.id, id_server = server.id) if item_sought: item = EwItem(id_item = item_sought.get('id_item')) if item.item_type == ewcfg.it_food: str_name = item.item_props['food_name'] id_food = item.item_props.get('id_food') fisher.bait = True if id_food in ewcfg.plebe_bait: fisher.current_fish = "plebefish" elif id_food == "doublestuffedcrust": if random.randrange(5) == 3: fisher.current_fish = "doublestuffedflounder" elif id_food in ["chickenbucket", "familymeal"]: if random.randrange(5) == 3: fisher.current_fish = "seacolonel" elif id_food in ["steakvolcanoquesomachorito", "nachosupreme"]: if random.randrange(5) == 3: fisher.current_fish = "marlinsupreme" elif id_food in ["blacklimes", "blacklimesour"]: if random.randrange(2) == 1: fisher.current_fish = "blacklimesalmon" elif id_food in ["pinkrowddishes", "pinkrowdatouille"]: if random.randrange(2) == 1: fisher.current_fish = "thrash" elif id_food in ["purplekilliflowercrustpizza", "purplekilliflower"]: if random.randrange(2) == 1: fisher.current_fish = "dab" elif id_food == "kingpincrab": if random.randrange(5) == 1: fisher.current_fish = "uncookedkingpincrab" elif float(item.time_expir if item.time_expir is not None else 0) < time.time(): if random.randrange(2) == 1: fisher.current_fish = "plebefish" ewitem.item_delete(item_sought.get('id_item')) if fisher.current_fish == "item": fisher.current_size = "item" else: fisher.current_size = gen_fish_size(has_fishingrod) if fisher.bait == False: response = "You cast your fishing line into the " else: response = "You attach your {} to the hook as bait and then cast your fishing line into the ".format(str_name) if cmd.message.channel.name in [ewcfg.channel_afb_pier, ewcfg.channel_vc_pier, ewcfg.channel_se_pier, ewcfg.channel_ferry]: response += "vast Slime Sea." else: response += "glowing Slime Lake." user_data.hunger += ewcfg.hunger_perfish * ewutils.hunger_cost_mod(user_data.slimelevel) user_data.persist() await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) bite_text = gen_bite_text(fisher.current_size) # User has a 1/10 chance to get a bite fun = 100 if fisher.bait == True: # Bait attatched, user has a 1/7 chance to get a bite fun = 70 bun = 0 while not ewutils.TERMINATE: if fun <= 0: fun = 1 else: damp = random.randrange(fun) if not fisher.high: await asyncio.sleep(60) else: await asyncio.sleep(30) user_data = EwUser(member=cmd.message.author) if user_data.poi != fisher.pier: fisher.fishing = False return if user_data.life_state == ewcfg.life_state_corpse: fisher.fishing = False return if fisher.fishing == False: return if damp > 10: await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, random.choice(ewcfg.nobite_text))) fun -= 2 bun += 1 if bun >= 5: fun -= 1 if bun >= 15: fun -= 1 continue else: break fisher.bite = True await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, bite_text)) await asyncio.sleep(8) if fisher.bite != False: fisher.fishing = False fisher.bite = False fisher.current_fish = "" fisher.current_size = "" fisher.bait = False return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "The fish got away...")) else: has_reeled = True else: response = "You can't fish here. Go to a pier." # Don't send out a response if the user actually reeled in a fish, since that gets sent by the reel command instead. if has_reeled == False: await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def data(cmd): response = "" user_data = None member = None resp_cont = ewutils.EwResponseContainer(id_server=cmd.message.server.id) if len(cmd.tokens) > 1 and cmd.mentions_count == 0: user_data = EwUser(member=cmd.message.author) soughtenemy = " ".join(cmd.tokens[1:]).lower() enemy = find_enemy(soughtenemy, user_data) if enemy != None: if enemy.attacktype != ewcfg.enemy_attacktype_unarmed: response = "{} is a level {} enemy. They have {} slime, and attack with their {}.".format( enemy.display_name, enemy.level, enemy.slimes, enemy.attacktype) else: response = "{} is a level {} enemy. They have {} slime.".format( enemy.display_name, enemy.level, enemy.slimes) else: response = "ENDLESS WAR didn't understand that name." resp_cont.add_channel_response(cmd.message.channel.name, response) elif cmd.mentions_count == 0: user_data = EwUser(member=cmd.message.author) slimeoid = EwSlimeoid(member=cmd.message.author) mutations = user_data.get_mutations() cosmetics = ewitem.inventory(id_user=cmd.message.author.id, id_server=cmd.message.server.id, item_type_filter=ewcfg.it_cosmetic) adorned_cosmetics = [] for cosmetic in cosmetics: cos = EwItem(id_item=cosmetic.get('id_item')) if cos.item_props['adorned'] == 'true': hue = ewcfg.hue_map.get(cos.item_props.get('hue')) adorned_cosmetics.append((hue.str_name + " " if hue != None else "") + cosmetic.get('name')) poi = ewcfg.id_to_poi.get(user_data.poi) if poi != None: response = "You find yourself {} {}. ".format( poi.str_in, poi.str_name) # return my data if user_data.life_state == ewcfg.life_state_corpse: response += "You are a level {} deadboi.".format( user_data.slimelevel) else: response += "You are a level {} slimeboi.".format( user_data.slimelevel) coinbounty = int(user_data.bounty / ewcfg.slimecoin_exchangerate) weapon_item = EwItem(id_item=user_data.weapon) weapon = ewcfg.weapon_map.get( weapon_item.item_props.get("weapon_type")) if weapon != None: response += " {} {}{}.".format( ewcfg.str_weapon_married_self if user_data.weaponmarried == True else ewcfg.str_weapon_wielding_self, ("" if len(weapon_item.item_props.get("weapon_name")) == 0 else "{}, ".format(weapon_item.item_props.get("weapon_name"))), weapon.str_weapon) if user_data.weaponskill >= 5: response += " {}".format( weapon.str_weaponmaster_self.format( rank=(user_data.weaponskill - 4))) trauma = ewcfg.weapon_map.get(user_data.trauma) # if trauma is not gathered from weapon_map, get it from attack_type_map if trauma == None: trauma = ewcfg.attack_type_map.get(user_data.trauma) if trauma != None: response += " {}".format(trauma.str_trauma_self) response_block = "" for mutation in mutations: mutation_flavor = ewcfg.mutations_map[mutation] response_block += "{} ".format(mutation_flavor.str_describe_self) if len(response_block) > 0: response += "\n\n" + response_block resp_cont.add_channel_response(cmd.message.channel.name, response) response = "" response_block = "" user_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_kills) enemy_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_pve_kills) if user_kills > 0 and enemy_kills > 0: response_block += "You have {:,} confirmed kills, and {:,} confirmed hunts. ".format( user_kills, enemy_kills) elif user_kills > 0: response_block += "You have {:,} confirmed kills. ".format( user_kills) elif enemy_kills > 0: response_block += "You have {:,} confirmed hunts. ".format( enemy_kills) if coinbounty != 0: response_block += "SlimeCorp offers a bounty of {:,} SlimeCoin for your death. ".format( coinbounty) if len(adorned_cosmetics) > 0: response_block += "You have a {} adorned. ".format( ewutils.formatNiceList(adorned_cosmetics, 'and')) if user_data.hunger > 0: response_block += "You are {}% hungry. ".format( round(user_data.hunger * 100.0 / user_data.get_hunger_max(), 1)) if user_data.busted and user_data.life_state == ewcfg.life_state_corpse: response_block += "You are busted and therefore cannot leave the sewers until your next !haunt. " statuses = user_data.getStatusEffects() for status in statuses: status_effect = EwStatusEffect(id_status=status, user_data=user_data) if status_effect.time_expire > time.time( ) or status_effect.time_expire == -1: status_flavor = ewcfg.status_effects_def_map.get(status) if status_flavor is not None: response_block += status_flavor.str_describe_self + " " if (slimeoid.life_state == ewcfg.slimeoid_state_active) and ( user_data.life_state != ewcfg.life_state_corpse): response_block += "You are accompanied by {}, a {}-foot-tall Slimeoid. ".format( slimeoid.name, str(slimeoid.level)) if len(response_block) > 0: response += "\n" + response_block response += "\n\nhttps://ew.krakissi.net/stats/player.html?pl={}".format( user_data.id_user) resp_cont.add_channel_response(cmd.message.channel.name, response) else: member = cmd.mentions[0] resp_cont = gen_data_text(id_user=member.id, id_server=member.server.id, display_name=member.display_name, channel_name=cmd.message.channel.name) # Send the response to the player. resp_cont.format_channel_response(cmd.message.channel.name, cmd.message.author) await resp_cont.post() await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author) if member != None: await ewrolemgr.updateRoles(client=cmd.client, member=member)
def gen_data_text(id_user=None, id_server=None, display_name=None, channel_name=None): resp_cont = ewutils.EwResponseContainer(id_server=id_server) response = "" user_data = EwUser(id_user=id_user, id_server=id_server) slimeoid = EwSlimeoid(id_user=id_user, id_server=id_server) mutations = user_data.get_mutations() cosmetics = ewitem.inventory(id_user=user_data.id_user, id_server=user_data.id_server, item_type_filter=ewcfg.it_cosmetic) adorned_cosmetics = [] for cosmetic in cosmetics: cos = EwItem(id_item=cosmetic.get('id_item')) if cos.item_props['adorned'] == 'true': hue = ewcfg.hue_map.get(cos.item_props.get('hue')) adorned_cosmetics.append((hue.str_name + " " if hue != None else "") + cosmetic.get('name')) if user_data.life_state == ewcfg.life_state_grandfoe: poi = ewcfg.id_to_poi.get(user_data.poi) if poi != None: response = "{} is {} {}.".format(display_name, poi.str_in, poi.str_name) else: response = "You can't discern anything useful about {}.".format( display_name) resp_cont.add_channel_response(channel_name, response) else: # return somebody's score if user_data.life_state == ewcfg.life_state_corpse: response = "{} is a level {} deadboi.".format( display_name, user_data.slimelevel) else: response = "{} is a level {} slimeboi.".format( display_name, user_data.slimelevel) coinbounty = int(user_data.bounty / ewcfg.slimecoin_exchangerate) weapon_item = EwItem(id_item=user_data.weapon) weapon = ewcfg.weapon_map.get( weapon_item.item_props.get("weapon_type")) if weapon != None: response += " {} {}{}.".format( ewcfg.str_weapon_married if user_data.weaponmarried == True else ewcfg.str_weapon_wielding, ("" if len(weapon_item.item_props.get("weapon_name")) == 0 else "{}, ".format(weapon_item.item_props.get("weapon_name"))), weapon.str_weapon) if user_data.weaponskill >= 5: response += " {}".format( weapon.str_weaponmaster.format( rank=(user_data.weaponskill - 4))) trauma = ewcfg.weapon_map.get(user_data.trauma) # if trauma is not gathered from weapon_map, get it from attack_type_map if trauma == None: trauma = ewcfg.attack_type_map.get(user_data.trauma) if trauma != None: response += " {}".format(trauma.str_trauma) response_block = "" for mutation in mutations: mutation_flavor = ewcfg.mutations_map[mutation] response_block += "{} ".format(mutation_flavor.str_describe_other) if len(response_block) > 0: response += "\n\n" + response_block resp_cont.add_channel_response(channel_name, response) response = "" response_block = "" user_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_kills) enemy_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_pve_kills) if user_kills > 0 and enemy_kills > 0: response_block += "They have {:,} confirmed kills, and {:,} confirmed hunts. ".format( user_kills, enemy_kills) elif user_kills > 0: response_block += "They have {:,} confirmed kills. ".format( user_kills) elif enemy_kills > 0: response_block += "They have {:,} confirmed hunts. ".format( enemy_kills) if coinbounty != 0: response_block += "SlimeCorp offers a bounty of {:,} SlimeCoin for their death. ".format( coinbounty) if len(adorned_cosmetics) > 0: response_block += "They have a {} adorned. ".format( ewutils.formatNiceList(adorned_cosmetics, 'and')) statuses = user_data.getStatusEffects() for status in statuses: status_effect = EwStatusEffect(id_status=status, user_data=user_data) if status_effect.time_expire > time.time( ) or status_effect.time_expire == -1: status_flavor = ewcfg.status_effects_def_map.get(status) if status_flavor is not None: response_block += status_flavor.str_describe + " " if (slimeoid.life_state == ewcfg.slimeoid_state_active) and ( user_data.life_state != ewcfg.life_state_corpse): response_block += "They are accompanied by {}, a {}-foot-tall Slimeoid.".format( slimeoid.name, str(slimeoid.level)) if len(response_block) > 0: response += "\n" + response_block response += "\n\nhttps://ew.krakissi.net/stats/player.html?pl={}".format( id_user) resp_cont.add_channel_response(channel_name, response) return resp_cont
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 ))
async def cast(cmd): time_now = round(time.time()) has_reeled = False user_data = EwUser(member = cmd.message.author) if user_data.life_state == ewcfg.life_state_shambler: response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0]) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if ewutils.channel_name_is_poi(cmd.message.channel.name) == False: return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "You must {} in a zone's channel.".format(cmd.tokens[0]))) market_data = EwMarket(id_server = cmd.message.author.guild.id) statuses = user_data.getStatusEffects() if cmd.message.author.id not in fishers.keys(): fishers[cmd.message.author.id] = EwFisher() fisher = fishers[cmd.message.author.id] # Ghosts cannot fish. if user_data.life_state == ewcfg.life_state_corpse: response = "You can't fish while you're dead. Try {}.".format(ewcfg.cmd_revive) # Players who are already cast a line cannot cast another one. elif fisher.fishing == True: response = "You've already cast a line." # Only fish at The Pier elif user_data.poi in ewcfg.piers: poi = ewcfg.id_to_poi.get(user_data.poi) district_data = EwDistrict(district = poi.id_poi, id_server = user_data.id_server) if district_data.is_degraded(): response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0]) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if user_data.hunger >= ewutils.hunger_max_bylevel(user_data.slimelevel): response = "You're too hungry to fish right now." else: has_fishingrod = False if user_data.weapon >= 0: weapon_item = EwItem(id_item = user_data.weapon) weapon = ewcfg.weapon_map.get(weapon_item.item_props.get("weapon_type")) if weapon.id_weapon == "fishingrod": has_fishingrod = True #if user_data.sidearm >= 0: # sidearm_item = EwItem(id_item=user_data.sidearm) # sidearm = ewcfg.weapon_map.get(sidearm_item.item_props.get("weapon_type")) # if sidearm.id_weapon == "fishingrod": # has_fishingrod = True if ewcfg.status_high_id in statuses: fisher.high = True fisher.fishing = True fisher.bait = False fisher.pier = ewcfg.id_to_poi.get(user_data.poi) fisher.current_fish = gen_fish(market_data, fisher, has_fishingrod) high_value_bait_used = False global fishing_counter fishing_counter += 1 current_fishing_id = fisher.fishing_id = fishing_counter item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) author = cmd.message.author server = cmd.guild item_sought = ewitem.find_item(item_search = item_search, id_user = author.id, id_server = server.id) if item_sought: item = EwItem(id_item = item_sought.get('id_item')) if item.item_type == ewcfg.it_food: str_name = item.item_props['food_name'] id_food = item.item_props.get('id_food') fisher.bait = True if id_food in ewcfg.plebe_bait: fisher.current_fish = "plebefish" elif id_food == "doublestuffedcrust": if random.randrange(5) == 3: fisher.current_fish = "doublestuffedflounder" elif id_food in ["chickenbucket", "familymeal"]: if random.randrange(5) == 3: fisher.current_fish = "seacolonel" elif id_food in ["steakvolcanoquesomachorito", "nachosupreme"]: if random.randrange(5) == 3: fisher.current_fish = "marlinsupreme" elif id_food in ["blacklimes", "blacklimesour"]: if random.randrange(2) == 1: fisher.current_fish = "blacklimesalmon" elif id_food in ["pinkrowddishes", "pinkrowdatouille"]: if random.randrange(2) == 1: fisher.current_fish = "thrash" elif id_food in ["purplekilliflowercrustpizza", "purplekilliflower"]: if random.randrange(2) == 1: fisher.current_fish = "dab" elif id_food == "kingpincrab": if random.randrange(5) == 1: fisher.current_fish = "uncookedkingpincrab" elif id_food == "masterbait": high_value_bait_used = True elif float(item.time_expir if item.time_expir is not None else 0) < time.time(): if random.randrange(2) == 1: fisher.current_fish = "plebefish" ewitem.item_delete(item_sought.get('id_item')) if fisher.current_fish == "item": fisher.current_size = "item" else: fisher.current_size = gen_fish_size(has_fishingrod) if fisher.bait == False: response = "You cast your fishing line into the " else: response = "You attach your {} to the hook as bait and then cast your fishing line into the ".format(str_name) if fisher.pier.pier_type == ewcfg.fish_slime_saltwater: response += "vast Slime Sea." else: response += "glowing Slime Lake." user_data.hunger += ewcfg.hunger_perfish * ewutils.hunger_cost_mod(user_data.slimelevel) user_data.persist() await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) bite_text = gen_bite_text(fisher.current_size) # User has a 1/10 chance to get a bite fun = 100 if fisher.bait == True: # Bait attatched, chance to get a bite increases from 1/10 to 1/7 fun -= 30 if fisher.pier == ewcfg.poi_id_ferry: # Fisher is on the ferry, chance to get a bite increases from 1/10 to 1/8 fun -= 20 if high_value_bait_used: fun = 5 bun = 0 while not ewutils.TERMINATE: if fun <= 0: fun = 1 else: damp = random.randrange(fun) if fisher.high: await asyncio.sleep(30) elif high_value_bait_used: await asyncio.sleep(5) else: await asyncio.sleep(60) # Cancel if fishing was interrupted if current_fishing_id != fisher.fishing_id: return if fisher.fishing == False: return user_data = EwUser(member=cmd.message.author) if fisher.pier == "" or user_data.poi != fisher.pier.id_poi: fisher.stop() return if user_data.life_state == ewcfg.life_state_corpse: fisher.stop() return if damp > 10: await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, random.choice(ewcfg.nobite_text))) fun -= 2 bun += 1 if bun >= 5: fun -= 1 if bun >= 15: fun -= 1 continue else: break fisher.bite = True await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, bite_text)) await asyncio.sleep(8) if fisher.bite != False: fisher.stop() return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "The fish got away...")) else: has_reeled = True else: response = "You can't fish here. Go to a pier." # Don't send out a response if the user actually reeled in a fish, since that gets sent by the reel command instead. if has_reeled == False: await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))