forked from swatv3nub/Redevil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwaifu.py
235 lines (209 loc) · 11.1 KB
/
waifu.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
from userbot import CMD_HELP, bot
from userbot.utils import admin_cmd
from telethon.events import ChatAction
#made by shivam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
from userbot import bot, CMD_HELP
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
from userbot.utils import register
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
from userbot import TEMP_DOWNLOAD_DIRECTORY
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
import os,re, bs4, requests, io
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Shivam#Made#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
from telethon import events
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
from pathlib import Path
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Sh1vam
from os import remove
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
from bs4 import BeautifulSoup
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
from re import findall
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
from urllib.parse import quote_plus
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
from requests import get
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
#Made by Sh1vam
#Made by Sh1vam#Made by Sh1vam#Made#Made by Sh1vam#Made by Sh1vam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
from PIL import Image
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
from telethon.tl.types import MessageMediaPhoto
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
import urllib
from userbot import bot as borg
import os
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
from bs4 import BeautifulSoup
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
opener = urllib.request.build_opener() ; useragent = 'Mozilla/5.0 (Linux; Android 9; SM-G960F Build/PPR1.180610.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.70 Mobile Safari/537.36' ; opener.addheaders = [('User-agent', useragent)]
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
from userbot.legend import MASTER
LEGENDX = MASTER
WAFU_CHATID=int(os.environ.get("WAFU_CHATID",-1001230114424))
async def ParseSauce(googleurl):
source = opener.open(googleurl).read()
soup = BeautifulSoup(source, 'html.parser')
results = {'similar_images': '', 'best_guess': ''}
try:
for similar_image in soup.findAll('input', {'class': 'gLFyf'}):
url = 'https://www.google.com/search?tbm=isch&q=' + \
urllib.parse.quote_plus(similar_image.get('value'))
results['similar_images'] = url
except BaseException:
pass
for best_guess in soup.findAll('div', attrs={'class': 'r5a77d'}):
results['best_guess'] = best_guess.get_text()
return results
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
async def scam(results, lim):
single = opener.open(results['similar_images']).read()
decoded = single.decode('utf-8')
imglinks = []
counter = 0
pattern = r'^,\[\"(.*[!png|!jpg|!jpeg])\",[0-9]+,[0-9]+\]$'
oboi = re.findall(pattern, decoded, re.I | re.M)
for imglink in oboi:
counter += 1
if not counter >= int(lim):
imglinks.append(imglink)
else:
break
return imglinks
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
async def chrome(chrome_options=None):
if chrome_options is None:
chrome_options = await options()
if not os.path.isdir(TEMP_DOWNLOAD_DIRECTORY):
os.mkdir(TEMP_DOWNLOAD_DIRECTORY)
prefs = {'download.default_directory': TEMP_DOWNLOAD_DIRECTORY}
chrome_options.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(executable_path=CHROME_DRIVER,
options=chrome_options)
return driver
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
#Made by Shivam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam
@bot.on(events.NewMessage(incoming=True))
async def on_new_message(event):
name = event.raw_text
snip = """appeared!
Add them to your harem by sending /protecc character name"""
pattern = r"( |^|[^\w])" + re.escape(snip) + r"( |$|[^\w])"
if re.search(pattern, name, flags=re.IGNORECASE):
try:
photo = io.BytesIO()
await event.client.download_media(event.media, photo)
image = Image.open(photo)
name = "okgoogle.png"
image.save(name, "PNG")
image.close()
searchUrl = 'https://www.google.com/searchbyimage/upload'
multipart = {
'encoded_image': (name, open(name, 'rb')),
'image_content': ''
}
response = requests.post(searchUrl,
files=multipart,
allow_redirects=False)
fetchUrl = response.headers['Location']
match = await ParseSauce(fetchUrl +"&preferences?hl=en&fg=1#languages")
guess = match['best_guess']
guesss = guess[12:]
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
try:
from userbot.modules.sql_helper.autowafu_sql import get_current_wafu_settings
from userbot.modules.sql_helper.autowafu_sql import update_previous_wafu
except AttributeError:
return
cws = get_current_wafu_settings(event.chat_id)
if cws:
await event.reply( f"/protecc {guesss}")
else:
await borg.send_message( WAFU_CHATID,f"/protecc {guesss}")
except Exception as e:
pass
#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made by Sh1vam#Made#Made by Shivam
#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam#Made by Shivam
'''@bot.on(ChatAction)
async def wafu_to_chat(event):
try:
from userbot.plugins.sql_helper.autowaifu_sql import get_current_wafu_settings
from userbot.plugins.sql_helper.autowaifu_sql import update_previous_wafu
except AttributeError:
return
cws = get_current_wafu_settings(event.chat_id)
if cws:'''
@register(outgoing=True, pattern=r"^.savewaifu(?: |$)(.*)")
async def save_wafu(event):
try:
from userbot.plugins.sql_helper.autowaifu_sql import add_wafu_setting
except AttributeError:
return await event.edit("`Running on Non-SQL mode!`")
string = """appeared!
Add them to your harem by sending /protecc character name"""
msg_id = None
if add_wafu_setting(event.chat_id, 0,string, msg_id) is True:
await event.edit('Auto wafu mode on')
else:
await event.edit(f"`{LEGENDX}`: **auto wafu already present**")
@register(outgoing=True, pattern="^.checkwaifu$")
async def show_wafu(event):
try:
from userbot.plugins.sql_helper.autowaifu_sql import get_current_wafu_settings
except AttributeError:
await event.edit("`Running on Non-SQL mode!`")
return
cws = get_current_wafu_settings(event.chat_id)
if not cws:
await event.edit(f"`{LEGENDX}`: **auto wafu not on.**")
return
else:
await event.edit(f"`{LEGENDX}`: **auto wafu on.**")
@register(outgoing=True, pattern="^.clearwaifu$")
async def del_wafu(event):
try:
from userbot.plugins.sql_helper.autowaifu_sql import rm_wafu_setting
except AttributeError:
await event.edit("`Running on Non-SQL mode!`")
return
if rm_wafu_setting(event.chat_id) is True:
await event.edit(f"`{LEGENDX}`: **auto wafu stops**")
else:
await event.edit(f"`{LEGENDX}`: ** no auto wafu on. **")