Spaces:
Paused
Paused
teamx-cloner
commited on
Commit
·
ebf59f1
1
Parent(s):
df39a9a
Delete plugins/chatbot.py
Browse files- plugins/chatbot.py +0 -89
plugins/chatbot.py
DELETED
@@ -1,89 +0,0 @@
|
|
1 |
-
# Ultroid - UserBot
|
2 |
-
# Copyright (C) 2021-2023 TeamUltroid
|
3 |
-
#
|
4 |
-
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
5 |
-
# PLease read the GNU Affero General Public License in
|
6 |
-
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
7 |
-
|
8 |
-
from . import get_help
|
9 |
-
|
10 |
-
__doc__ = get_help("help_chatbot")
|
11 |
-
|
12 |
-
|
13 |
-
from pyUltroid.fns.tools import get_chatbot_reply
|
14 |
-
|
15 |
-
from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd
|
16 |
-
|
17 |
-
|
18 |
-
@ultroid_cmd(pattern="repai")
|
19 |
-
async def im_lonely_chat_with_me(event):
|
20 |
-
if event.reply_to:
|
21 |
-
message = (await event.get_reply_message()).message
|
22 |
-
else:
|
23 |
-
try:
|
24 |
-
message = event.text.split(" ", 1)[1]
|
25 |
-
except IndexError:
|
26 |
-
return await eod(event, get_string("tban_1"), time=10)
|
27 |
-
reply_ = await get_chatbot_reply(message=message)
|
28 |
-
await event.eor(reply_)
|
29 |
-
|
30 |
-
|
31 |
-
@ultroid_cmd(pattern="addai")
|
32 |
-
async def add_chatBot(event):
|
33 |
-
await chat_bot_fn(event, type_="add")
|
34 |
-
|
35 |
-
|
36 |
-
@ultroid_cmd(pattern="remai")
|
37 |
-
async def rem_chatBot(event):
|
38 |
-
await chat_bot_fn(event, type_="remov")
|
39 |
-
|
40 |
-
|
41 |
-
@ultroid_cmd(pattern="listai")
|
42 |
-
async def lister(event):
|
43 |
-
key = udB.get_key("CHATBOT_USERS") or {}
|
44 |
-
users = key.get(event.chat_id, [])
|
45 |
-
if not users:
|
46 |
-
return await event.eor(get_string("chab_2"), time=5)
|
47 |
-
msg = "**Total List Of AI Enabled Users In This Chat :**\n\n"
|
48 |
-
for i in users:
|
49 |
-
try:
|
50 |
-
user = await event.client.get_entity(int(i))
|
51 |
-
user = inline_mention(user)
|
52 |
-
except BaseException:
|
53 |
-
user = f"`{i}`"
|
54 |
-
msg += f"• {user}\n"
|
55 |
-
await event.eor(msg, link_preview=False)
|
56 |
-
|
57 |
-
|
58 |
-
async def chat_bot_fn(event, type_):
|
59 |
-
if event.reply_to:
|
60 |
-
user_ = (await event.get_reply_message()).sender
|
61 |
-
else:
|
62 |
-
temp = event.text.split(maxsplit=1)
|
63 |
-
try:
|
64 |
-
user_ = await event.client.get_entity(await event.client.parse_id(temp[1]))
|
65 |
-
except BaseException as er:
|
66 |
-
LOGS.exception(er)
|
67 |
-
user_ = event.chat if event.is_private else None
|
68 |
-
if not user_:
|
69 |
-
return await eod(
|
70 |
-
event,
|
71 |
-
get_string("chab_1"),
|
72 |
-
)
|
73 |
-
key = udB.get_key("CHATBOT_USERS") or {}
|
74 |
-
chat = event.chat_id
|
75 |
-
user = user_.id
|
76 |
-
if type_ == "add":
|
77 |
-
if key.get(chat):
|
78 |
-
if user not in key[chat]:
|
79 |
-
key[chat].append(user)
|
80 |
-
else:
|
81 |
-
key.update({chat: [user]})
|
82 |
-
elif type_ == "remov":
|
83 |
-
if key.get(chat):
|
84 |
-
if user in key[chat]:
|
85 |
-
key[chat].remove(user)
|
86 |
-
if chat in key and not key[chat]:
|
87 |
-
del key[chat]
|
88 |
-
udB.set_key("CHATBOT_USERS", key)
|
89 |
-
await event.eor(f"**ChatBot:**\n{type_}ed {inline_mention(user_)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|