Skip to content

Commit 783a1b0

Browse files
authored
restrict /now command on groups (#44)
* restrict `/now` command on groups
1 parent 55a0ad2 commit 783a1b0

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

bot/commands/subject.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from mongoengine.errors import DoesNotExist, MultipleObjectsReturned
66

77
from bot.core import BotTelegramCore
8+
from bot.messages import NOW_GROUP_RESTRICTED
89
from db.subject import Subject
910
from db.observer import UserObserver
1011
from db.update_message import UpdateMessage
@@ -21,6 +22,14 @@ def now(update: Update, context: CallbackContext):
2122
chat = update.effective_chat
2223
message = update.effective_message
2324

25+
if not chat.type == "private":
26+
available_vsps = "\n".join([subject.header for
27+
subject in Subject.objects.all()])
28+
message.reply_text(NOW_GROUP_RESTRICTED, parse_mode='MARKDOWN')
29+
message.reply_text(f"<b>Available VSP's are:</b>\n\n{available_vsps}",
30+
parse_mode='HTML')
31+
return
32+
2433
try:
2534
observer = UserObserver.objects.get(chat_id=f"{chat.id}")
2635
except DoesNotExist:

bot/messages.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
"https://github.com/dcr-guys/JackBot/"
66

77
ADMIN_RESTRICTED = "This command is restricted to admins only!"
8+
9+
NOW_GROUP_RESTRICTED = "The command `/now` without args is restricted on groups! Please call `/now` with args"

0 commit comments

Comments
 (0)