-
Notifications
You must be signed in to change notification settings - Fork 2
/
bot.py
230 lines (202 loc) · 10.8 KB
/
bot.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
from pyrogram import Client, filters
from pyrogram.types import *
from pymongo import MongoClient
from metaapi import META
import requests
import aiohttp
import asyncio
import os
meta = META()
video_group = 3
photo_group = 4
# 😂 Asewsome Module Made By Moezilla 😉
# Fun Fact - Moezilla Is Gay
# Copyright By MetaVoid
API_ID = os.environ.get("API_ID")
API_HASH = os.environ.get("API_HASH")
BOT_TOKEN = os.environ.get("BOT_TOKEN")
MONGO_URL = os.environ.get("MONGO_URL")
LOG = os.environ.get("LOG_CHANNEL")
app = Client(
"Sfw" ,
api_id = API_ID ,
api_hash = API_HASH ,
bot_token = BOT_TOKEN
)
regex_video = r"^((?i)slap|bully|cuddle|cry|hug|kiss|smile|pat|kill|bite|kick|happy|dance|cringe)$"
regex_photo = r"^((?i)waifu|neko|awoo|shinobu|megumin)$"
async def is_admins(chat_id: int):
return [
member.user.id
async for member in app.iter_chat_members(
chat_id, filter="administrators"
)
]
@app.on_message(
filters.command("togglesfw", prefixes=["/", ".", "?", "-"])
& ~filters.private)
async def levelsystem(_, message):
sfwdb = MongoClient(MONGO_URL)
toggle = sfwdb["SfwDb"]["Sfw"]
if message.from_user:
user = message.from_user.id
chat_id = message.chat.id
if user not in (
await is_admins(chat_id)
):
return await message.reply_text(
"You are not admin"
)
is_sfw = toggle.find_one({"chat_id": message.chat.id})
if not is_sfw:
toggle.insert_one({"chat_id": message.chat.id})
await message.reply_text("Sfw System Enable")
await app.send_message(LOG, f"#SFW-ENABLE\nCHAT - @{message.chat.username}\n ADMIN - [{message.from_user.first_name}](tg://user?id={message.from_user.id})")
else:
toggle.delete_one({"chat_id": message.chat.id})
await message.reply_text("Sfw System Disable")
await app.send_message(LOG, f"#SFW-DISABLE\nCHAT - @{message.chat.username}\n ADMIN - [{message.from_user.first_name}](tg://user?id={message.from_user.id})")
@app.on_message(
filters.text
& filters.reply
& filters.regex(regex_video),
group=video_group,
)
async def video(client, message):
Msg = message.text
sfwdb = MongoClient(MONGO_URL)
mainuser = sfwdb["SfwDb"][f"{Msg}"]
toggle = sfwdb["SfwDb"]["Sfw"]
otheruser = sfwdb["UserSfwDb"][f"{Msg}"]
replyuser = message.reply_to_message.from_user.id
user = message.from_user.id
is_sfw = toggle.find_one({"chat_id": message.chat.id})
if is_sfw:
k = mainuser.find_one({"user": replyuser, "chat_id": message.chat.id})
n = otheruser.find_one({"user": user, "chat_id": message.chat.id})
if not message.reply_to_message.from_user.is_bot:
if k is None:
x = requests.get(f"https://api.waifu.pics/sfw/{Msg}").json()
x = x['url']
if not n:
input = {"user": replyuser, "chat_id": message.chat.id, "time": 1}
input1 = {"user": user, "chat_id": message.chat.id, "time": 1}
mainuser.insert_one(input)
otheruser.insert_one(input1)
await message.reply_video(video=x, caption=f"{message.from_user.mention} is giving {message.reply_to_message.from_user.mention} a {Msg}!\n {message.reply_to_message.from_user.mention} has been {Msg} 1 times and {message.from_user.mention} has {Msg} others 1 times")
if n:
input = {"user": replyuser, "chat_id": message.chat.id, "time": 1}
mainuser.insert_one(input)
t = n["time"] + 1
otheruser.update_one({"user": user, "chat_id": message.chat.id}, {
"$set": {"time": t}})
await message.reply_video(video=x, caption=f"{message.from_user.mention} is giving {message.reply_to_message.from_user.mention} a {Msg}!\n {message.reply_to_message.from_user.mention} has been {Msg} 1 times and {message.from_user.mention} has {Msg} others {t} times")
else:
if not n:
t = k["time"] + 1
x = requests.get(f"https://api.waifu.pics/sfw/{Msg}").json()
x = x['url']
input = {"user": replyuser, "chat_id": message.chat.id, "time": 1}
mainuser.insert_one(input)
otheruser.update_one({"user": user, "chat_id": message.chat.id}, {
"$set": {"time": t}})
time = t
await message.reply_video(video=x, caption=f"{message.from_user.mention} is giving {message.reply_to_message.from_user.mention} a {Msg}!\n {message.reply_to_message.from_user.mention} has been {Msg} {time} times and {message.from_user.mention} has {Msg} others 1 times")
if n:
t = k["time"] + 1
t1 = n["time"] + 1
x = requests.get(f"https://api.waifu.pics/sfw/{Msg}").json()
x = x['url']
mainuser.update_one({"user": replyuser, "chat_id": message.chat.id}, {
"$set": {"time": t}})
otheruser.update_one({"user": user, "chat_id": message.chat.id}, {
"$set": {"time": t1}})
time = t
await message.reply_video(video=x, caption=f"{message.from_user.mention} is giving {message.reply_to_message.from_user.mention} a {Msg}!\n {message.reply_to_message.from_user.mention} has been {Msg} {time} times and {message.from_user.mention} has {Msg} others {t1} times")
@app.on_message(
filters.text
& filters.reply
& filters.regex(regex_photo),
group=photo_group,
)
async def image(client, message):
Msg = message.text
sfwdb = MongoClient(MONGO_URL)
mainuser = sfwdb["SfwDb"][f"{Msg}"]
toggle = sfwdb["SfwDb"]["Sfw"]
otheruser = sfwdb["UserSfwDb"][f"{Msg}"]
replyuser = message.reply_to_message.from_user.id
user = message.from_user.id
is_sfw = toggle.find_one({"chat_id": message.chat.id})
if is_sfw:
k = mainuser.find_one({"user": replyuser, "chat_id": message.chat.id})
n = otheruser.find_one({"user": user, "chat_id": message.chat.id})
if not message.reply_to_message.from_user.is_bot:
if k is None:
x = requests.get(f"https://api.waifu.pics/sfw/{Msg}").json()
x = x['url']
if not n:
input = {"user": replyuser, "chat_id": message.chat.id, "time": 1}
input1 = {"user": user, "chat_id": message.chat.id, "time": 1}
mainuser.insert_one(input)
otheruser.insert_one(input1)
await message.reply_photo(photo=x, caption=f"{message.from_user.mention} is giving {message.reply_to_message.from_user.mention} a {Msg}!\n {message.reply_to_message.from_user.mention} has been {Msg} 1 times and {message.from_user.mention} has {Msg} others 1 times")
if n:
input = {"user": replyuser, "chat_id": message.chat.id, "time": 1}
mainuser.insert_one(input)
otheruser.update_one({"user": user, "chat_id": message.chat.id}, {
"$set": {"time": t}})
t = n["time"] + 1
await message.reply_photo(photo=x, caption=f"{message.from_user.mention} is giving {message.reply_to_message.from_user.mention} a {Msg}!\n {message.reply_to_message.from_user.mention} has been {Msg} 1 times and {message.from_user.mention} has {Msg} others {t} times")
else:
if not n:
t = k["time"] + 1
x = requests.get(f"https://api.waifu.pics/sfw/{Msg}").json()
x = x['url']
input = {"user": replyuser, "chat_id": message.chat.id, "time": 1}
mainuser.insert_one(input)
otheruser.update_one({"user": user, "chat_id": message.chat.id}, {
"$set": {"time": t}})
time = t
await message.reply_photo(photo=x, caption=f"{message.from_user.mention} is giving {message.reply_to_message.from_user.mention} a {Msg}!\n {message.reply_to_message.from_user.mention} has been {Msg} {time} times and {message.from_user.mention} has {Msg} others 1 times")
if n:
t = k["time"] + 1
t1 = n["time"] + 1
x = requests.get(f"https://api.waifu.pics/sfw/{Msg}").json()
x = x['url']
mainuser.update_one({"user": replyuser, "chat_id": message.chat.id}, {
"$set": {"time": t}})
otheruser.update_one({"user": user, "chat_id": message.chat.id}, {
"$set": {"time": t1}})
time = t
await message.reply_photo(photo=x, caption=f"{message.from_user.mention} is giving {message.reply_to_message.from_user.mention} a {Msg}!\n {message.reply_to_message.from_user.mention} has been {Msg} {time} times and {message.from_user.mention} has {Msg} others {t1} times")
@app.on_message(
filters.command("check", prefixes=["/", ".", "?", "-"])
& filters.reply)
async def hi(client, message):
sfwdb = MongoClient(MONGO_URL)
Msg = message.command[1]
toggle = sfwdb["SfwDb"]["Sfw"]
mainuser = sfwdb["SfwDb"][f"{Msg}"]
otheruser = sfwdb["UserSfwDb"][f"{Msg}"]
user = message.reply_to_message.from_user.id
is_sfw = toggle.find_one({"chat_id": message.chat.id})
if is_sfw:
k = mainuser.find_one({"user": replyuser, "chat_id": message.chat.id})
n = otheruser.find_one({"user": user, "chat_id": message.chat.id})
if not message.reply_to_message.from_user.is_bot:
if k is None:
if not n:
await message.reply_text("Nothing Data")
if n:
t = n["time"]
await message.reply_text(f"{message.reply_to_message.from_user.mention} has {Msg} others {t} times")
else:
if not n:
t = k["time"]
await message.reply_text(f"{message.reply_to_message.from_user.mention} has been {Msg} {t} times")
if n:
t = k["time"]
t1 = n["time"]
await message.reply_text(f"{message.reply_to_message.from_user.mention} has been {Msg} {t} times and {message.reply_to_message.from_user.mention} has {Msg} others {t1} times")
app.run()