|
18 | 18 | @admin_method |
19 | 19 | def ban_user_cmd(update, context): |
20 | 20 | """Bans a user from using the bot""" |
| 21 | + usage_message = r"Please provide a valid userid\. Usage: `/ban <userid>`" |
21 | 22 | # Try to get user_id from command |
22 | 23 | if len(context.args) != 1: |
23 | | - update.message.reply_text("Please provide a valid user_id - `/ban <user_id>`", parse_mode=ParseMode.MARKDOWN_V2) |
| 24 | + update.effective_message.reply_text(usage_message, parse_mode=ParseMode.MARKDOWN_V2) |
24 | 25 | return |
25 | 26 |
|
26 | 27 | match = re.search(r"^\d+$", context.args[0]) |
27 | 28 | if not match: |
28 | | - logger.error(f"The user_id did not match: {context.args}") |
| 29 | + logger.error(f"The user_id did not match. Args: {context.args}") |
| 30 | + update.effective_message.reply_text(usage_message, parse_mode=ParseMode.MARKDOWN_V2) |
29 | 31 | return |
30 | 32 | user_id = match.group(0) |
31 | 33 |
|
32 | 34 | db = Database() |
33 | 35 | db.ban_user(user_id=user_id) |
34 | 36 |
|
35 | 37 | logger.info(f"Admin '{update.effective_user.id}' banned user '{user_id}'!") |
36 | | - notify_admins(f"Admin '{update.effective_user.id}' banned user '{user_id}'!") |
| 38 | + notify_admins(f"Admin '{update.effective_user.id}' banned user '{user_id}'!", context) |
37 | 39 |
|
38 | 40 |
|
39 | 41 | @admin_method |
40 | 42 | def unban_user_cmd(update, context): |
41 | 43 | """Unbans a user from using the bot""" |
| 44 | + usage_message = r"Please provide a valid userid\. Usage: `/unban <userid>`" |
| 45 | + |
42 | 46 | # Try to get user_id from command |
43 | 47 | if len(context.args) != 1: |
44 | | - update.message.reply_text("Please provide a valid user_id - `/unban <user_id>`", parse_mode=ParseMode.MARKDOWN_V2) |
| 48 | + update.message.reply_text(usage_message, parse_mode=ParseMode.MARKDOWN_V2) |
45 | 49 | return |
46 | 50 |
|
47 | 51 | match = re.search(r"^\d+$", context.args[0]) |
48 | 52 | if not match: |
49 | | - logger.error(f"The user_id did not match: {context.args}") |
| 53 | + logger.error(f"The user_id did not match. Args: {context.args}") |
| 54 | + update.effective_message.reply_text(usage_message, parse_mode=ParseMode.MARKDOWN_V2) |
50 | 55 | return |
51 | 56 | user_id = match.group(0) |
52 | 57 |
|
53 | 58 | db = Database() |
54 | 59 | db.unban_user(user_id=user_id) |
55 | 60 |
|
56 | 61 | logger.info(f"Admin '{update.effective_user.id}' unbanned user '{user_id}'!") |
57 | | - notify_admins(f"Admin '{update.effective_user.id}' unbanned user '{user_id}'!") |
| 62 | + notify_admins(f"Admin '{update.effective_user.id}' unbanned user '{user_id}'!", context) |
58 | 63 |
|
59 | 64 |
|
60 | 65 | @admin_method |
|
0 commit comments