Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 59 additions & 52 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ async def is_admins(chat_id: int):
& ~filters.private)
async def addchat(_, message):
kukidb = MongoClient(MONGO_URL)
kuki = kukidb["KukiDb"]["Kuki"]

kuki = kukidb["KukiDb"]["Kuki"]
Comment on lines -38 to +39
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function addchat refactored with the following changes:

if message.from_user:
user = message.from_user.id
chat_id = message.chat.id
Expand All @@ -46,21 +46,20 @@ async def addchat(_, message):
return await message.reply_text(
"You are not admin"
)
is_kuki = kuki.find_one({"chat_id": message.chat.id})
if not is_kuki:
if is_kuki := kuki.find_one({"chat_id": message.chat.id}):
await message.reply_text(f"Already Setup Kuki Chatbot of this Group Is @{message.chat.username}")
else:
kuki.insert_one({"chat_id": message.chat.id})
await message.reply_text(f"✅ | Successfully\nKuki Chatbot of this Group is set to @{message.chat.username}\n Requested by [{message.from_user.first_name}](tg://user?id={message.from_user.id})\n© @MetaVoid")
else:
await message.reply_text(f"Already Setup Kuki Chatbot of this Group Is @{message.chat.username}")


@bot.on_message(
filters.command("removechat", prefixes=["/", ".", "?", "-"])
& ~filters.private)
async def rmchat(_, message):
kukidb = MongoClient(MONGO_URL)
kuki = kukidb["KukiDb"]["Kuki"]

kuki = kukidb["KukiDb"]["Kuki"]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function rmchat refactored with the following changes:

if message.from_user:
user = message.from_user.id
chat_id = message.chat.id
Expand All @@ -70,12 +69,11 @@ async def rmchat(_, message):
return await message.reply_text(
"You are not admin"
)
is_kuki = kuki.find_one({"chat_id": message.chat.id})
if not is_kuki:
await message.reply_text("Already Kuki ChatBot Disable")
else:
if is_kuki := kuki.find_one({"chat_id": message.chat.id}):
kuki.delete_one({"chat_id": message.chat.id})
await message.reply_text("✅ | Kuki Chatbot is disable!")
else:
await message.reply_text("Already Kuki ChatBot Disable")



Expand All @@ -91,32 +89,28 @@ async def rmchat(_, message):
)
async def kukiai(client: Client, message: Message):

kukidb = MongoClient(MONGO_URL)

kuki = kukidb["KukiDb"]["Kuki"]

is_kuki = kuki.find_one({"chat_id": message.chat.id})
if is_kuki:
if message.reply_to_message:
botget = await bot.get_me()
botid = botget.id
if not message.reply_to_message.from_user.id == botid:
return
await bot.send_chat_action(message.chat.id, "typing")
if not message.text:
msg = "/"
else:
msg = message.text
try:
x = requests.get(f"https://kukiapi.xyz/api/apikey={KUKI_API}/message={msg}").json()
x = x['reply']
await asyncio.sleep(1)
except Exception as e:
error = str(e)
await message.reply_text(x)
await bot.send_message(
ERROR_LOG, f"""{error}""")
await bot.send_chat_action(message.chat.id, "cencel")
kukidb = MongoClient(MONGO_URL)

kuki = kukidb["KukiDb"]["Kuki"]

if is_kuki := kuki.find_one({"chat_id": message.chat.id}):
if message.reply_to_message:
botget = await bot.get_me()
botid = botget.id
if message.reply_to_message.from_user.id != botid:
return
await bot.send_chat_action(message.chat.id, "typing")
msg = message.text or "/"
try:
x = requests.get(f"https://kukiapi.xyz/api/apikey={KUKI_API}/message={msg}").json()
x = x['reply']
await asyncio.sleep(1)
except Exception as e:
error = str(e)
await message.reply_text(x)
await bot.send_message(
ERROR_LOG, f"""{error}""")
await bot.send_chat_action(message.chat.id, "cencel")
Comment on lines -94 to +113
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function kukiai refactored with the following changes:




Expand All @@ -130,10 +124,7 @@ async def kukiai(client: Client, message: Message):
)
async def kukiai(client: Client, message: Message):
await bot.send_chat_action(message.chat.id, "typing")
if not message.text:
msg = "/"
else:
msg = message.text
msg = message.text or "/"
Comment on lines -133 to +127
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function kukiai refactored with the following changes:

try:
x = requests.get(f"https://kukiapi.xyz/api/apikey={KUKI_API}/message={msg}").json()
x = x['reply']
Expand All @@ -151,10 +142,12 @@ async def kukiai(client: Client, message: Message):
filters.command("chat", prefixes=["/", ".", "?", "-"]))
async def kukiai(client: Client, message: Message):
await bot.send_chat_action(message.chat.id, "typing")
if not message.text:
msg = "/"
else:
msg = message.text.replace(message.text.split(" ")[0], "")
msg = (
message.text.replace(message.text.split(" ")[0], "")
if message.text
else "/"
)

Comment on lines -154 to +150
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function kukiai refactored with the following changes:

try:
x = requests.get(f"https://kukiapi.xyz/api/apikey={KUKI_API}/message={msg}").json()
x = x['reply']
Expand All @@ -176,11 +169,18 @@ async def start(client, message):
busername = self.username
if message.chat.type != "private":
buttons = InlineKeyboardMarkup(
[[InlineKeyboardButton(text="Click here",
url=f"t.me/kukichatbot?start")]])
[
[
InlineKeyboardButton(
text="Click here", url="t.me/kukichatbot?start"
)
]
]
)

await message.reply("Contact me in PM",
reply_markup=buttons)

Comment on lines -179 to +183
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function start refactored with the following changes:

else:
buttons = [[InlineKeyboardButton("Support", url="https://t.me/metavoidsupport"),
InlineKeyboardButton("Channel", url="https://t.me/metavoid"),
Expand All @@ -197,11 +197,18 @@ async def help(client, message):
busername = self.username
if message.chat.type != "private":
buttons = InlineKeyboardMarkup(
[[InlineKeyboardButton(text="Click here",
url=f"t.me/kukichatbot?start=help_")]])
[
[
InlineKeyboardButton(
text="Click here", url="t.me/kukichatbot?start=help_"
)
]
]
)

await message.reply("Contact me in PM",
reply_markup=buttons)

Comment on lines -200 to +211
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function help refactored with the following changes:

else:
await message.reply_text("/start - Start The Bot\n/chat - Send a message to this bot\n/setupchat - Active Kuki Chatbot In Group\n/removechat - Disable Kuki Chatbot In Group")

Expand Down