Skip to content
This repository has been archived by the owner on Apr 1, 2023. It is now read-only.

Commit

Permalink
partially fix #4 and resolve #27
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe committed Jan 30, 2021
1 parent 2375e53 commit 2245589
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 23 deletions.
30 changes: 16 additions & 14 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,24 @@
UN_BAN_COMMAND = get_config("UN_BAN_COMMAND", "unban")
# start command
START_COMMAND = get_config("START_COMMAND", "start")
# default message in-case of None types
DEFAULT_START_TEXT = (
"Hi. ☺️\n"
"Thank you for using me 😬\n\n"
"This is an Open Source Project available on "
"https://github.com/SpEcHIDe/NoPMsBot\n\n\n"
"If you are the owner of this bot, "
"and are seeing this message 🤦‍♂️, "
"means that you have not set up "
"the ENVironment variables properly "
"for the bot to function.\n\n\n"
"ℹ️ Subscribe @SpEcHlDe if you 😍 using this bot❗️❣️"
)
# /start message when other users start your bot
START_OTHER_USERS_TEXT = get_config(
START_OTHER_USERS_TEXT = int(get_config(
"START_OTHER_USERS_TEXT",
(
"Hi. ☺️\n"
"Thank you for using me 😬\n\n"
"This is an Open Source Project available on "
"https://github.com/SpEcHIDe/NoPMsBot\n\n\n"
"If you are the owner of this bot, "
"and are seeing this message 🤦‍♂️, "
"means that you have not set up "
"the ENVironment variables properly "
"for the bot to function.\n\n\n"
"ℹ️ Subscribe @SpEcHlDe if you 😍 using this bot❗️❣️"
)
)
0
))
# check online status of your bot
ONLINE_CHECK_START_TEXT = get_config(
"ONLINE_CHECK_START_TEXT",
Expand Down
18 changes: 17 additions & 1 deletion bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,22 @@
Client,
__version__
)
from . import (
from bot import (
API_HASH,
APP_ID,
AUTH_CHANNEL,
DEFAULT_START_TEXT,
LOGGER,
START_COMMAND,
START_OTHER_USERS_TEXT,
TG_BOT_TOKEN,
TG_BOT_WORKERS
)


class Bot(Client):
""" modded client for NoPMsBot """
commandi = {}

def __init__(self):
super().__init__(
Expand All @@ -49,6 +54,17 @@ async def start(self):
await super().start()
usr_bot_me = await self.get_me()
self.set_parse_mode("html")
try:
check_m = await self.get_messages(
chat_id=AUTH_CHANNEL,
message_ids=START_OTHER_USERS_TEXT,
replies=0
)
except ValueError:
self.commandi[START_COMMAND] = DEFAULT_START_TEXT
else:
if check_m:
self.commandi[START_COMMAND] = check_m.text.html
self.LOGGER(__name__).info(
f"@{usr_bot_me.username} based on Pyrogram v{__version__} "
"Try /start."
Expand Down
12 changes: 6 additions & 6 deletions bot/plugins/start_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@
AUTH_CHANNEL,
COMMM_AND_PRE_FIX,
ONLINE_CHECK_START_TEXT,
START_COMMAND,
START_OTHER_USERS_TEXT
START_COMMAND
)
from bot.bot import Bot
from bot.hf.flifi import uszkhvis_chats_ahndler


@Client.on_message(
@Bot.on_message(
filters.command(START_COMMAND, COMMM_AND_PRE_FIX) &
~uszkhvis_chats_ahndler([AUTH_CHANNEL])
)
async def num_start_message(_, message: Message):
async def num_start_message(client: Bot, message: Message):
await message.reply_text(
START_OTHER_USERS_TEXT,
client.commandi[START_COMMAND],
quote=True
)


@Client.on_message(
@Bot.on_message(
filters.command(START_COMMAND, COMMM_AND_PRE_FIX) &
uszkhvis_chats_ahndler([AUTH_CHANNEL])
)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Pyrogram==1.0.7
Pyrogram==1.1.13
TgCrypto==1.2.1

psycopg2-binary==2.8.6
Expand Down
2 changes: 1 addition & 1 deletion res/env_vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Create a Super Group in Telegram, add `@GoogleIMGBot` to the group, and send /id

* `START_COMMAND`: The command to check if the bot is alive, or for users to start the robot.

* `START_OTHER_USERS_TEXT`: The message that your bot users would see on sending /start message.
* `START_OTHER_USERS_TEXT`: Send a Message in your `AUTH_CHANNEL`, and paste message_id in this value.

* `ONLINE_CHECK_START_TEXT`: The message that the bot administrators can use to check if bot is online.

Expand Down

0 comments on commit 2245589

Please sign in to comment.