This repository has been archived by the owner on May 19, 2024. It is now read-only.
forked from sterling-tenn/poketwo-autocatcher
-
Notifications
You must be signed in to change notification settings - Fork 41
/
main.py
executable file
·128 lines (116 loc) · 5.03 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import re, asyncio, json, random, string
from discord.ext import commands
from discord.ext import tasks
version = 'v2.7.4'
with open('data/config.json', 'r') as file:
info = json.loads(file.read())
user_token = info['user_token']
spam_id = info['spam_id']
catch_id = info['catch_id']
with open('data/pokemon', 'r', encoding='utf8') as file:
pokemon_list = file.read()
with open('data/legendary', 'r') as file:
legendary_list = file.read()
with open('data/mythical', 'r') as file:
mythical_list = file.read()
with open('data/level', 'r') as file:
to_level = file.readline()
num_pokemon = 0
shiny = 0
legendary = 0
mythical = 0
poketwo = 716390085896962058
bot = commands.Bot(command_prefix="->", self_bot=True)
intervals = [1.5, 1.6, 1.7, 1.8, 1.9]
def solve(message):
hint = []
for i in range(15,len(message) - 1):
if message[i] != '\\':
hint.append(message[i])
hint_string = ''
for i in hint:
hint_string += i
hint_replaced = hint_string.replace('_', '.')
solution = re.findall('^'+hint_replaced+'$', pokemon_list, re.MULTILINE)
return solution
@tasks.loop(seconds=random.choice(intervals))
async def spam():
channel = bot.get_channel(int(spam_id))
await channel.send("".join(random.choices(string.ascii_uppercase + string.ascii_lowercase, k=random.randint(12, 24))))
@spam.before_loop
async def before_spam():
await bot.wait_until_ready()
spam.start()
@bot.event
async def on_ready():
print(f'Logged into account: {bot.user.name}')
@bot.event
async def on_message(message):
channel = bot.get_channel(int(catch_id))
if message.channel.id == int(catch_id):
if message.author.id == poketwo:
if message.embeds:
embed_title = message.embeds[0].title
if 'wild pokémon has appeared!' in embed_title:
spam.cancel()
await asyncio.sleep(1)
await channel.send('p!h')
elif "Congratulations" in embed_title:
embed_content = message.embeds[0].description
if 'now level' in embed_content:
split = embed_content.split(' ')
a = embed_content.count(' ')
level = int(split[a].replace('!', ''))
if level == 100:
await channel.send(f"p!s {to_level}")
with open('data/level', 'r') as fi:
data = fi.read().splitlines(True)
with open('data/level', 'w') as fo:
fo.writelines(data[1:])
else:
content = message.content
if 'The pokémon is ' in content:
if not len(solve(content)):
print('Pokemon not found.')
else:
for i in solve(content):
await asyncio.sleep(1)
await channel.send(f'p!c {i}')
check = random.randint(1, 240)
if check == 1:
await asyncio.sleep(900)
spam.start()
else:
await asyncio.sleep(1)
spam.start()
elif 'Congratulations' in content:
global shiny
global legendary
global num_pokemon
global mythical
num_pokemon += 1
split = content.split(' ')
pokemon = split[7].replace('!','')
if 'seem unusual...' in content:
shiny += 1
print(f'Shiny Pokémon caught! Pokémon: {pokemon}')
print(f'Shiny: {shiny} | Legendary: {legendary} | Mythical: {mythical}')
elif re.findall('^'+pokemon+'$', legendary_list, re.MULTILINE):
legendary += 1
print(f'Legendary Pokémon caught! Pokémon: {pokemon}')
print(f'Shiny: {shiny} | Legendary: {legendary} | Mythical: {mythical}')
elif re.findall('^'+pokemon+'$', mythical_list, re.MULTILINE):
mythical += 1
print(f'Mythical Pokémon caught! Pokémon: {pokemon}')
print(f'Shiny: {shiny} | Legendary: {legendary} | Mythical: {mythical}')
else:
print(f'Total Pokémon Caught: {num_pokemon}')
elif 'human' in content:
spam.cancel()
print('Captcha detected; autocatcher paused. Press enter to restart, after solving captcha manually.')
input()
await channel.send('p!h')
if not message.author.bot:
await bot.process_commands(message)
print(f'Pokétwo Autocatcher {version}\nA second gen free and open-source Pokétwo autocatcher by devraza\nEvent Log:')
bot.run(f"{user_token}")