-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
91 lines (68 loc) · 2.14 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
# project info
# author : https://github.com/spencexd7
# discord : https://discord.gg/gpqMWg5PAY
import discord
from discord.ext import commands
import dhash
import csv
from io import BytesIO
import requests
from PIL import Image
token = ""
client = commands.Bot(command_prefix='autocatch')
client._skip_check = lambda x, y: False
@client.event
async def on_message(message):
def check(m):
return m.channel == message.channel and m.author != client.user and "A new wild pokémon has appeared!" in m.content
global hint
embeds = message.embeds
if not embeds:
await client.process_commands(message)
return
title = embeds[0].to_dict().get('title')
if message.attachments:
for attachment in message.attachments:
# Check if the message is sent by Poketwo
if message.author.name == 'Pokétwo':
image_link = attachment.url
# Download the image
response = requests.get(image_link)
image = Image.open(BytesIO(response.content))
# Calculate the dhash of the image
hash_value = dhash.dhash_int(image)
# Save the hash in a CSV file
with open('hashes.csv', 'a') as csvfile:
writer = csv.writer(csvfile)
writer.writerow([hash_value])
async def wait_for_response(message, channel, check):
await channel.send(message)
response = await client.wait_for('message', check=check, timeout=60)
return response
async def send(message, channel):
await channel.send(message)
def get(val):
val = val.lower()
while "\_" in val:
val = val.replace("\_", "-")
length = len(val)
l = list(val)
with open('pokes.txt') as f:
lines = [line.rstrip() for line in f]
new_names = []
for i in lines:
if len(i) == length:
new_names.append(i)
final_list = []
for i in new_names:
name_list = list(i)
index = 0
flag = False
for k in l:
if name_list[index] != k and k != "-":
flag = True
index = index+1
if not flag:
final_list.append(i)
return final_list
client.run(token)