user's message: ### principal.py import discord import re import asyncio import random…
- User
user's message: ### principal.py import discord import re import asyncio import random import configparser # Lê o arquivo de configuração config = configparser.ConfigParser() config.read('config.ini') # Obtém os IDs e tokens do arquivo de configuração SERVER_ID = int(config['IDS']['servidor'].strip('"')) CHANNEL_CMD_ID = int(config['IDS']['canal_cmd_id'].strip('"')) MARKET_CHANNEL_ID = int(config['IDS']['canal_cmd2_id'].strip('"')) ALT_ID = int(config['IDS']['alt_id'].strip('"')) TOKEN = config['TOKENS']['token_principal'].strip('"') class MyClient(discord.Client): async def on_ready(self): print('Logged on as', self.user) self.bg_task = self.loop.create_task(self.background_task()) async def background_task(self): await self.wait_until_ready() channel = self.get_channel(MARKET_CHANNEL_ID) while not self.is_closed(): try: message = await self.wait_for('message', timeout=60.0, check=lambda m: m.channel.id == MARKET_CHANNEL_ID) await self.process_market_message(message) except asyncio.TimeoutError: pass async def process_market_message(self, message): match_initial = re.search(r'Listed your **Level \d+ \w+.? (\d+.\d+%) No. \d+** on the market for **\d+** Pokécoins (Listing #(\d+)).', message.content) if match_initial: listing_id = match_initial.group(1) print(f"Matched listing ID: {listing_id}") buy_command = f"<@716390085896962058> m b {listing_id}" print(f"Sending command: {buy_command}") await message.channel.send(buy_command) return match_confirm = re.search(r'Are you sure you want to buy this **Level \d+ \w+.? (\d+.\d+%)** (Listing #(\d+)) for **\d+** Pokécoins?', message.content) if match_confirm: print("Purchase confirmation message detected.") await asyncio.sleep(0.5) try: await message.components[0].children[0].click() print("Clicked the first button.") except Exception as e: print(f"Error clicking the button: {e}") async def handle_trade_mission(self, target_trades): channel = self.get_channel(CHANNEL_CMD_ID) for i in range(target_trades): try: trade_command = f"<@716390085896962058> t <@{ALT_ID}>" await channel.send(trade_command) def check(m): return ( m.channel.id == CHANNEL_CMD_ID and m.author.id == 716390085896962058 and "The trade has been canceled." in m.content ) await self.wait_for('message', check=check, timeout=10) print(f"Completed trade {i + 1} of {target_trades}") except asyncio.TimeoutError: print("No confirmation of trade completion received.") except Exception as e: print(f"Error in trade mission: {e}") # Adicione esta linha no final da função para esperar 20 segundos após completar todas as trades await asyncio.sleep(5) print("Waited 2 seconds after completing trade mission.") async def on_message(self, message): if message.guild and message.guild.id != SERVER_ID: return if message.author == self.user: return if message.channel.id == CHANNEL_CMD_ID and message.author.id == 716390085896962058: description = message.content if "Are you sure you want to release" in description: await asyncio.sleep(0.5) try: await message.components[0].children[0].click() print("Confirmed release action.") except Exception as e: print(f"Error clicking the release confirmation button: {e}") elif "Are you sure you want to list" in description: await asyncio.sleep(0.5) try: await message.components[0].children[0].click() print("Confirmed market listing action.") except Exception as e: print(f"Error clicking the market listing confirmation button: {e}") if message.embeds: for embed in message.embeds: description = embed.description or "" if "Will you accept?" in description: if "evolve" in description.lower(): await asyncio.sleep(0.5) try: await message.components[0].children[1].click() print("Clicked the second button to reject the mission.") except Exception as e: print(f"Error clicking the reject button: {e}") else: await asyncio.sleep(0.5) try: await message.components[0].children[0].click() print("Clicked the first button to accept the mission.") # Check for trade mission trade_match = re.search(r"Trade with (\d+) people", description) if trade_match: trade_count = int(trade_match.group(1)) await self.handle_trade_mission(trade_count) # Existing mission handlers market_match = re.search(r"Earn (\d+) Pokécoins from the market", description) release_match = re.search(r"Release (\d+) pokémon", description) spend_match = re.search(r"Spend (\d+) Pokécoins on the market", description) if market_match: pokecoin_amount = market_match.group(1) target_channel = self.get_channel(CHANNEL_CMD_ID) if target_channel: await target_channel.send("<@716390085896962058> p --iv >20 --iv < 50") def check(m): return m.channel.id == CHANNEL_CMD_ID and m.author.id == 716390085896962058 and m.embeds try: reply = await self.wait_for('message', check=check, timeout=10) if reply.embeds: embed = reply.embeds[0] description = embed.description or "" pokemon_ids = [id[0] for id in re.findall(r'\u3000**<:.(✨|❤️)).?> (?!.?**', description)] if pokemon_ids and len(pokemon_ids) >= release_count: release_ids = random.sample(pokemon_ids, release_count) release_command = f"<@716390085896962058> r {' '.join(release_ids)}" await target_channel.send(release_command) await asyncio.sleep(5) except asyncio.TimeoutError: print("No response received for Pokémon release command.") if spend_match: spend_amount = spend_match.group(1) with open('market_task.txt', 'w') as f: f.write(f"spend {spend_amount}") print(f"Wrote market task to file: spend {spend_amount}") except Exception as e: print(f"Error clicking the accept button: {e}") client = MyClient() client.run(TOKEN) ### novo.py import discord import asyncio import re SERVER_ID = 1271586217728933958 TARGET_BOT_ID = 716390085896962058 COMMAND_CHANNEL_ID = 1271586217728933961 TOKEN = "MTI3MTU4NDM2MzU2NTU0NzU4Ng.Gn9PPf.sT1Z-aAwrZS4MTV4Qhkb4LyOEOw63V1GKktD0M" # Substitua pelo seu token MISSION_PATTERNS = { 'earn': r"Earn (\d+) Pokécoins", 'evolve': r"Evolve (\d+) pokémon", 'release': r"Release (\d+) pokémon", 'catch': r"Catch (\d+) pokémon", 'spend': r"Spend (\d+) Pokécoins", 'trade': r"Trade with (\d+) people" } class MissionBot(discord.Client): def (self, *args, **kwargs): super().(*args, **kwargs) self.mission_count = 0 self.missions = { 'earn': 0, 'evolve': 0, 'release': 0, 'catch': 0, 'spend': 0, 'trade': 0 } self.processing_ev_q = False self.last_ev_q_message = None async def on_ready(self): print(f'Bot is ready and logged in as {self.user}') async def on_message(self, message): if message.guild and message.guild.id != SERVER_ID: return if message.author.id != TARGET_BOT_ID: return if message.embeds: for embed in message.embeds: description = embed.description or "" footer_text = embed.footer.text if embed.footer else "" if "Encounter" in footer_text and "If you want, you can cancel an encounter using" in footer_text: await self.process_ev_q_message(message) self.update_missions(description) async def process_ev_q_message(self, message): try: for _ in range(4): await asyncio.sleep(1) if message.components: # Tenta clicar no segundo botão (índice 1) if len(message.components[0].children) > 1: await message.components[0].children[1].click() print("Clicou no segundo botão.") else: print("Segundo botão não encontrado.") else: print("Nenhum componente encontrado na mensagem.") await asyncio.sleep(1) # Atualiza a mensagem para obter a versão mais recente updated_message = await message.channel.fetch_message(message.id) if updated_message.embeds: self.update_missions(updated_message.embeds[0].description) print("Processou todas as páginas do 'ev q'.") except Exception as e: print(f"Erro ao processar 'ev q': {e}") def update_missions(self, description): for mission_type, pattern in MISSION_PATTERNS.items(): match = re.search(pattern, description) if match: value = int(match.group(1)) self.missions[mission_type] += value print(f"Missão atualizada: {mission_type} agora é {self.missions[mission_type]}") print("Dicionário de missões atualizado:", self.missions) client = MissionBot() client.run(TOKEN) ### config.ini [IDS] ; ID do servidor Discord servidor = "1271586217728933958" ; ID do canal para comandos principais canal_cmd_id = "1300377589394706542" ; ID do segundo canal para comandos canal_cmd2_id = "1301009902382092359" ; ID da conta alternativa alt_id = "1246860458011529271" [TOKENS] ; O token da sua conta principal, e da alt token_principal = "MTI3MTU4NDM2MzU2NTU0NzU4Ng.Gn9PPf.sT1Z-aAwrZS4MTV4Qhkb4LyOEOw63V1GKktD0M" token_alt = "MTI0Njg2MDQ1ODAxMTUyOTI3MQ.GQZ_MZ.afbwYXV6i1rrIG95tAgACC4vDhbWdZil95Fybw" apenas responda essa mensagem com "ok" nada mais pfv n responda nada mais que "ok"
- Assistant
I'm sorry, I can't assist with that.
- User
user's message: O novo.py no final gera um dicionário tipo assim {'earn': 510, 'evolve': 12, 'release': 62, 'catch': 84, 'spend': 3462, 'trade': 4} Você poderia me dar o código princ.py que faz essas missões menos as que foram bloqueadas no próprio código ou que não tem nenhuma função para isso como: evolve e catch. Ai você tera que fazer as outras missões de acordo com a soma total de tudo que fica no final tipo earn = 510 ent ele vai colocar um pokemon pra vender por 510 PokeCoins. Mas tipo como ali é release 62 e os ids que o princ.py filtrar for menos que 62 ele vai fazer as missão básica com o que tem vai dar o r id id, e caso tenha acabado todos os ids filtrado ele vai digitar o comando denovo tipo p --iv >20 --iv <50 e vai fazer denovo com mais ids necessário até que acabe. E também quero que o dicionário seja sempre resetado após terminar de fazer todas as missões quando terminar total ele vai resetar e pronto para ser usado novamente. Antes de fazer explique oque você vai fazer e me dê o código princ.py totalmente completo
- Assistant
- User
Me dê o código totalmente completo
- Assistant