|
| 1 | +from config import Config |
| 2 | +from banner import Banner |
| 3 | +from discord.ext import commands |
| 4 | +from colorama import Fore, Style, init |
| 5 | +import asyncio |
| 6 | +import random |
| 7 | +import json |
| 8 | +import re |
| 9 | +import datetime |
| 10 | +import os |
| 11 | + |
| 12 | +init() |
| 13 | +current_datetime = datetime.datetime.now() |
| 14 | +timestamp = current_datetime.strftime("%Y-%m-%d %H:%M:%S") |
| 15 | + |
| 16 | +def find_word(words, user_input): |
| 17 | + for word in words: |
| 18 | + if len(word) != len(user_input): |
| 19 | + continue |
| 20 | + match = True |
| 21 | + for i in range(len(word)): |
| 22 | + if user_input[i] != '_' and user_input[i] != word[i]: |
| 23 | + match = False |
| 24 | + break |
| 25 | + if match: |
| 26 | + return word |
| 27 | + return None |
| 28 | + |
| 29 | +def print_banner(): |
| 30 | + os.system('cls' if os.name == 'nt' else 'clear') |
| 31 | + print(Fore.YELLOW, Banner.get_banner(), Style.RESET_ALL) |
| 32 | + |
| 33 | +def start(): |
| 34 | + bot = commands.Bot(command_prefix='!') |
| 35 | + |
| 36 | + async def send_message(channel_id, message): |
| 37 | + try: |
| 38 | + channel = bot.get_channel(int(channel_id)) |
| 39 | + await channel.send(message) |
| 40 | + except Exception as e: |
| 41 | + print(f"{Fore.RED}Error in send_message: {e}{Style.RESET_ALL}") |
| 42 | + |
| 43 | + @bot.event |
| 44 | + async def on_ready(): |
| 45 | + print_banner() |
| 46 | + print(f'[{timestamp}] [INFO] - {Fore.LIGHTGREEN_EX}Logged on as {bot.user}{Style.RESET_ALL}') |
| 47 | + print(f'[{timestamp}] [INFO] - {Fore.LIGHTGREEN_EX}Bot Is Ready...{Style.RESET_ALL}') |
| 48 | + print(f'[{timestamp}] [INFO] - Start Spamming...') |
| 49 | + pause = False |
| 50 | + while True: |
| 51 | + if not pause: |
| 52 | + timer = random.uniform(1.5, 3) |
| 53 | + await send_message(Config.spam_channel, 'Buy Premuim Version Only 10$ <@1118077275330596957>') |
| 54 | + await asyncio.sleep(timer) |
| 55 | + else: |
| 56 | + await asyncio.sleep(5) |
| 57 | + pause = False |
| 58 | + |
| 59 | + @bot.event |
| 60 | + async def on_message(message): |
| 61 | + try: |
| 62 | + poketwo = 716390085896962058 |
| 63 | + |
| 64 | + if message.channel.id == int(Config.spawn_channel): |
| 65 | + if message.author.id == int(poketwo): |
| 66 | + if message.embeds: |
| 67 | + embed_title = message.embeds[0].title |
| 68 | + if 'wild pokémon has appeared!' in embed_title: |
| 69 | + timer = random.uniform(1.5, 3) |
| 70 | + await asyncio.sleep(timer) |
| 71 | + await message.channel.send('<@716390085896962058> h') |
| 72 | + pause = True |
| 73 | + |
| 74 | + if message.author.id == int(poketwo) and message.channel.id == int(Config.spawn_channel): |
| 75 | + if message.content.startswith('The pokémon is '): |
| 76 | + extracted_word = message.content[len('The pokémon is '):].strip('.').strip().replace('\\', '') |
| 77 | + print(f'[{timestamp}] [HINT] - {Fore.YELLOW}Pokemon Hint: {Style.RESET_ALL}{extracted_word}') |
| 78 | + result = find_word(words, extracted_word) |
| 79 | + if result: |
| 80 | + await message.channel.send(f'<@716390085896962058> c {result}') |
| 81 | + print(f"[{timestamp}] [HINT] - {Fore.LIGHTGREEN_EX}Search Result: {Style.RESET_ALL}{result}") |
| 82 | + else: |
| 83 | + print(f"[{timestamp}] [ERROR] - {Fore.RED}Pokemon Not Founded In Database{Style.RESET_ALL}") |
| 84 | + |
| 85 | + if message.author.id == int(poketwo) and message.channel.id == int(Config.spawn_channel): |
| 86 | + if message.content.startswith('Congratulations'): |
| 87 | + match = re.search(r'Congratulations <@\d+>! (.+)', message.content) |
| 88 | + if match: |
| 89 | + extracted_message = match.group(1) |
| 90 | + print(f'[{timestamp}] [INFO] - {Fore.LIGHTGREEN_EX}{extracted_message}{Style.RESET_ALL}') |
| 91 | + elif message.content.startswith('That is the wrong pokémon!'): |
| 92 | + print(f'[{timestamp}] [INFO] - {Fore.RED}That is the wrong pokémon!{Style.RESET_ALL}') |
| 93 | + |
| 94 | + except Exception as e: |
| 95 | + print(f"[{timestamp}] [ERROR] - {Fore.RED}Error in on_message: {Style.RESET_ALL}{e}") |
| 96 | + |
| 97 | + |
| 98 | + with open('pokemon.json', 'r', encoding='utf-8') as f: |
| 99 | + words = json.load(f) |
| 100 | + |
| 101 | + bot.run(Config.token) |
| 102 | + |
| 103 | +start() |
0 commit comments