Spaces:
Sleeping
Sleeping
Captain Ezio
commited on
Commit
·
48f18b6
1
Parent(s):
497d0b7
Added botcommand and fixed few bugs
Browse files- Powers/bot_class.py +8 -1
- Powers/utils/string.py +5 -3
Powers/bot_class.py
CHANGED
@@ -5,6 +5,7 @@ from time import gmtime, strftime, time
|
|
5 |
from aiohttp import ClientSession
|
6 |
from pyrogram import Client, __version__
|
7 |
from pyrogram.raw.all import layer
|
|
|
8 |
|
9 |
from Powers import (API_HASH, API_ID, BOT_TOKEN, LOG_DATETIME, LOGFILE, LOGGER,
|
10 |
MESSAGE_DUMP, NO_LOAD, UPTIME, WORKERS, load_cmds)
|
@@ -41,7 +42,13 @@ class Gojo(Client):
|
|
41 |
async def start(self):
|
42 |
"""Start the bot."""
|
43 |
await super().start()
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
meh = await self.get_me() # Get bot info from pyrogram client
|
46 |
LOGGER.info("Starting bot...")
|
47 |
Config.BOT_ID = meh.id
|
|
|
5 |
from aiohttp import ClientSession
|
6 |
from pyrogram import Client, __version__
|
7 |
from pyrogram.raw.all import layer
|
8 |
+
from pyrogram.types import BotCommand
|
9 |
|
10 |
from Powers import (API_HASH, API_ID, BOT_TOKEN, LOG_DATETIME, LOGFILE, LOGGER,
|
11 |
MESSAGE_DUMP, NO_LOAD, UPTIME, WORKERS, load_cmds)
|
|
|
42 |
async def start(self):
|
43 |
"""Start the bot."""
|
44 |
await super().start()
|
45 |
+
await self.set_bot_commands(
|
46 |
+
[
|
47 |
+
BotCommand("start", "To check weather the bot is alive or not"),
|
48 |
+
BotCommand("help", "To get help menu"),
|
49 |
+
BotCommand("donate", "To buy me a coffee")
|
50 |
+
]
|
51 |
+
)
|
52 |
meh = await self.get_me() # Get bot info from pyrogram client
|
53 |
LOGGER.info("Starting bot...")
|
54 |
Config.BOT_ID = meh.id
|
Powers/utils/string.py
CHANGED
@@ -122,6 +122,10 @@ async def escape_mentions_using_curly_brackets(
|
|
122 |
text: str,
|
123 |
parse_words: list,
|
124 |
) -> str:
|
|
|
|
|
|
|
|
|
125 |
teks = await escape_invalid_curly_brackets(text, parse_words)
|
126 |
if teks:
|
127 |
teks = teks.format(
|
@@ -141,9 +145,7 @@ async def escape_mentions_using_curly_brackets(
|
|
141 |
if m.from_user.last_name
|
142 |
else [escape(m.from_user.first_name)],
|
143 |
),
|
144 |
-
chatname=
|
145 |
-
if m.chat.type != ChatType.SUPERGROUP
|
146 |
-
else escape(m.from_user.first_name),
|
147 |
id=m.from_user.id,
|
148 |
)
|
149 |
else:
|
|
|
122 |
text: str,
|
123 |
parse_words: list,
|
124 |
) -> str:
|
125 |
+
if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP, ChatType.CHANNEL]:
|
126 |
+
chat_name = escape(m.chat.title)
|
127 |
+
else:
|
128 |
+
chat_name = escape(m.from_user.first_name)
|
129 |
teks = await escape_invalid_curly_brackets(text, parse_words)
|
130 |
if teks:
|
131 |
teks = teks.format(
|
|
|
145 |
if m.from_user.last_name
|
146 |
else [escape(m.from_user.first_name)],
|
147 |
),
|
148 |
+
chatname=chat_name,
|
|
|
|
|
149 |
id=m.from_user.id,
|
150 |
)
|
151 |
else:
|