Added the /busy command

This commit is contained in:
nocturn9x 2020-06-07 07:38:11 +00:00
parent 7998b9c416
commit 9e6e158ac8
2 changed files with 21 additions and 2 deletions

View File

@ -1,6 +1,7 @@
from ..config import ADMINS, USER_INFO, INVALID_SYNTAX, ERROR, NONNUMERIC_ID, USERS_COUNT, \
NO_PARAMETERS, ID_MISSING, GLOBAL_MESSAGE_STATS, NAME, WHISPER_FROM, USER_INFO_UPDATED, USER_INFO_UNCHANGED, \
USER_BANNED, USER_UNBANNED, CANNOT_BAN_ADMIN, USER_ALREADY_BANNED, USER_NOT_BANNED, YOU_ARE_BANNED, YOU_ARE_UNBANNED
USER_BANNED, USER_UNBANNED, CANNOT_BAN_ADMIN, USER_ALREADY_BANNED, USER_NOT_BANNED, YOU_ARE_BANNED, YOU_ARE_UNBANNED, \
MARKED_BUSY, UNMARKED_BUSY, CACHE
from pyrogram import Client, Filters
from ..database.query import get_user, get_users, update_name, ban_user, unban_user
from .antiflood import BANNED_USERS
@ -194,3 +195,18 @@ def unban(client, message):
send_message(client, True, message.chat.id, f"{ERROR}: {NONNUMERIC_ID}")
else:
send_message(client, True, message.chat.id, f"{INVALID_SYNTAX}: Use <code>/unban user_id</code>")
@Client.on_message(Filters.command("/busy") & ADMINS_FILTER & Filters.private & ~BANNED_USERS & ~Filters.edited)
def get_random_user(client, message):
logging.warning(f"{ADMINS[message.from_user.id]} [{message.from_user.id}] sent /busy")
if len(message.command) > 1:
send_message(client, True, message.chat.id, f"{INVALID_SYNTAX}: {NO_PARAMETERS.format(command='/busy')}")
else:
if CACHE[message.from_user.id][0] == "none":
send_message(client, True, message.chat.id, MARKED_BUSY)
CACHE[message.from_user.id] = ["IN_CHAT", 1234567]
else:
if message.from_user.id in CACHE:
del CACHE[message.from_user.id]
send_message(client, True, message.chat.id, UNMARKED_BUSY)

View File

@ -6,6 +6,8 @@ BotBase is a collection of plugins that use [Pyrogram's](https://github.com/pyro
BotBase requires a solid knowledge of pyrogram and of the Telegram MTProto API itself, you can check pyrogram's docs [here](https://docs.pyrogram.org)
The author of this project assumes that the reader is not a completely computer illiterate, this project is thought for smart people that want to develop better bots faster, it is **not** a beginner's friendly thing.
Also, you need to know how to host a bot yourself. I mean, I coded all of this for you already, make some effort!
## BotBase - Setup
@ -17,7 +19,7 @@ To setup a project using BotBase, follow this step-by-step guide (assuming `pip`
- Once that is done, open the `BotBase/config.py` module with a text editor and start changing the default settings
- The first thing you might want to do is change the `API_ID`, `API_HASH` and `BOT_TOKEN` global variables. Check [this page](https://my.telegram.org/apps) and login with your telegram account to create an API_ID/API_HASH pair. For the bot token, just create one with [BotFather](https://telegram.me/BotFather)
**Note**: The configuration file is still a python file, so when it will be imported any python code that you typed inside it will be executed, so be careful! If you need to perform pre-startup operations it is advised to do them in the `if __name__ == "main":` block inside `bot.py`, before `bot.start()`
**Note**: The configuration file is still a python file and when it will be imported any python code that you typed inside it will be executed, so be careful! If you need to perform pre-startup operations it is advised to do them in the `if __name__ == "main":` block inside `bot.py`, before `bot.start()`
## BotBase - Plugins
@ -70,6 +72,7 @@ The available commands are:
- `/global msg`: Broadcast `msg` to all users, supports HTML and markdown formatting
- `/whisper ID msg`: Send `msg` to a specific user given its ID. HTML and markdown formatting supported
- `/update ID`: Updates the user's info in the database, if they've changed
- `/busy`: Sets your admin status as busy/not busy to silence/unsilence support requests to you
### Plugins - Antiflood