forked from TeamUltroid/UltroidAddons
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautowaifu.py
More file actions
69 lines (63 loc) · 2.06 KB
/
autowaifu.py
File metadata and controls
69 lines (63 loc) · 2.06 KB
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
# Ultroid - UserBot
# Copyright (C) 2020 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
#Fixes by Github/ArnabXD | Telegram/Arnab431
"""
✘ Commands Available -
•`{i} autowaifu on/off`
This auto show result for @loli_harem_bot.
"""
import os
import requests
from asyncio import sleep
from bs4 import BeautifulSoup as bs
from . import *
XX = "A qt waifu appeared!"
@ultroid_cmd(pattern="autowaifu ?(.*)")
async def _(e):
args = e.pattern_match.group(1)
uff = await eor(e,"`Processing...`")
if args:
if args == "on":
udB.set("WAIFU","TRUE")
return await uff.edit("AutoWaifu - ON")
if args == "off":
udB.set("WAIFU","FALSE")
return await uff.edit("AutoWaifu - OFF")
waifu = udB.get("WAIFU")
status = "ON" if waifu == "TRUE" else "OFF"
return await uff.edit(f"AutoWaifu - {status}")
@ultroid_bot.on(events.NewMessage(incoming=True))
async def reverse(event):
if not event.media:
return
if not XX in event.text:
return
if not event.sender_id == 792028928:
return
if Redis("WAIFU")!="TRUE":
return
dl = await ultroid_bot.download_media(event.media, "resources/")
file = {"encoded_image": (dl, open(dl, "rb"))}
grs = requests.post(
"https://www.google.com/searchbyimage/upload", files=file, allow_redirects=False
)
loc = grs.headers.get("Location")
response = requests.get(
loc,
headers={
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0"
},
)
xx = bs(response.text, "html.parser")
div = xx.find_all("div", {"class": "r5a77d"})[0]
alls = div.find("a")
text = alls.text
send = await ultroid_bot.send_message(event.chat_id, f"/protecc {text}")
await sleep(2)
await send.delete()
os.remove(dl)
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})