forked from TeamUltroid/UltroidAddons
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwaifu.py
More file actions
125 lines (109 loc) · 3.15 KB
/
waifu.py
File metadata and controls
125 lines (109 loc) · 3.15 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
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
# Ultroid - UserBot
# Copyright (C) 2023-2024 @TeamUltroid
#
# This file is a part of < https://github.com/ufoptg/UltroidBackup/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/ufoptg/UltroidBackup/blob/main/LICENSE/>.
# By @TrueSaiyan
"""
❍ Commands Available -
• `{i}waifu` or {i}waifu <type>
Send sfw waifu or select.
• `{i}waifu2` or {i}waifu2 <type>
Send a nsfw waifu.
~ NSFW: `waifu` `neko` `trap` `blowjob`
~ SFW: `waifu` `neko` `shinobu` `megumin`
`bully` `cuddle` `cry` `hug` `awoo`
`kiss` `lick` `pat` `smug` `bonk`
`blush` `smile` `wave` `highfive`
`nom` `bite` `glomp` `slap` `kill`
`kick` `happy` `wink` `poke` `dance`
`cringe` `handhold` `yeet`
"""
import asyncio
import random
import requests
from telethon.errors.rpcerrorlist import MessageIdInvalidError
from . import ultroid_bot, ultroid_cmd
class WaifuApiUrl:
def __init__(
self,
url: str = "api.waifu.pics",
method: str = None,
parameter: str = None,
allow_web: str = "https",
):
self.url = url
self.method = method
self.parameter = parameter
self.allow_web = allow_web
def checking(self):
api_url = f"{self.allow_web}://{self.url}/{self.method}/{self.parameter}"
return api_url
@ultroid_cmd(
pattern=r"waifu(|2)(?:\s|$)([\s\S]*)",
)
async def _(event):
raw_text = event.raw_text.split(" ", 1)
try:
load = await event.eor("Getting Data")
except MessageIdInvalidError:
pass
cat = None
# Create an instance of the PrivateApiUrl class
private_api = WaifuApiUrl()
# Set the method and parameter based on the command
if event.pattern_match.group(1) == "2":
private_api.method = "nsfw"
if len(raw_text) < 2:
cat = ["waifu", "neko", "trap", "blowjob"]
else:
cat = raw_text[1].split()
elif cat is None:
private_api.method = "sfw"
if len(raw_text) < 2:
cat = [
"waifu",
"neko",
"shinobu",
"megumin",
"bully",
"cuddle",
"cry",
"hug",
"awoo",
"kiss",
"lick",
"pat",
"smug",
"bonk",
"yeet",
"blush",
"smile",
"wave",
"highfive",
"handhold",
"nom",
"bite",
"glomp",
"slap",
"kill",
"kick",
"happy",
"wink",
"poke",
"dance",
"cringe",
]
else:
cat = raw_text[1].split()
cat_phrase = random.choice(cat)
private_api.parameter = cat_phrase
api_url = private_api.checking()
response = requests.get(api_url)
image_url = response.json()["url"]
await asyncio.sleep(1)
await load.delete()
await event.client.send_file(
event.chat_id, image_url, reply_to=event.reply_to_msg_id
)