diff --git a/SaitamaRobot/__main__.py b/SaitamaRobot/__main__.py index 343eb0cfeb..6d764f418b 100644 --- a/SaitamaRobot/__main__.py +++ b/SaitamaRobot/__main__.py @@ -36,10 +36,9 @@ the things I can help you with. *Main* commands available: - • /start: start the bot • /help: PM's you this message. • /help : PM's you info about that module. - • /donate: information about how to donate! + • /donate: information on how to donate! • /settings: • in PM: will send you your settings for all supported modules. • in a group: will redirect you to pm, with all that chat's settings. @@ -165,7 +164,7 @@ def start(update: Update, context: CallbackContext): context.bot.username)) ]])) else: - update.effective_message.reply_text("Yo, whadup?") + update.effective_message.reply_text("I am already online!") # for test purposes diff --git a/SaitamaRobot/modules/antiflood.py b/SaitamaRobot/modules/antiflood.py index 8ba1e7492a..0a7110e3ac 100644 --- a/SaitamaRobot/modules/antiflood.py +++ b/SaitamaRobot/modules/antiflood.py @@ -73,10 +73,8 @@ def check_flood(update, context) -> str: permissions=ChatPermissions(can_send_messages=False)) execstrings = ("Muted for {}".format(getvalue)) tag = "TMUTE" - send_message( - update.effective_message, - "Wonderful, I like to leave flooding to natural disasters but you, " - "you were just a disappointment {}!".format(execstrings)) + send_message(update.effective_message, + "Beep Boop! Boop Beep!\n{}!".format(execstrings)) return "{}:" \ "\n#{}" \ diff --git a/SaitamaRobot/modules/backups.py b/SaitamaRobot/modules/backups.py index fedbb4e596..9650f58143 100644 --- a/SaitamaRobot/modules/backups.py +++ b/SaitamaRobot/modules/backups.py @@ -70,7 +70,7 @@ def import_data(update, context): # Check if backup is this chat try: - if data.get(str(chat.id)) == None: + if data.get(str(chat.id)) is None: if conn: text = "Backup comes from another chat, I can't return another chat to chat *{}*".format( chat_name) @@ -347,7 +347,7 @@ def export_data(update, context): # Temporary data def put_chat(chat_id, value, chat_data): # print(chat_data) - if value == False: + if value is False: status = False else: status = True diff --git a/SaitamaRobot/modules/blacklist_stickers.py b/SaitamaRobot/modules/blacklist_stickers.py index 449c81bc2b..7c950e967b 100644 --- a/SaitamaRobot/modules/blacklist_stickers.py +++ b/SaitamaRobot/modules/blacklist_stickers.py @@ -476,7 +476,7 @@ def __stats__(): • `` can be `https://t.me/addstickers/` or just `` or reply to the sticker message. """ -__mod_name__ = "Sticker Blacklist" +__mod_name__ = "Stickers Blacklist" BLACKLIST_STICKER_HANDLER = DisableAbleCommandHandler( "blsticker", blackliststicker, admin_ok=True) diff --git a/SaitamaRobot/modules/blacklistusers.py b/SaitamaRobot/modules/blacklistusers.py index 1b196a6236..501e22af5e 100644 --- a/SaitamaRobot/modules/blacklistusers.py +++ b/SaitamaRobot/modules/blacklistusers.py @@ -2,7 +2,7 @@ import SaitamaRobot.modules.sql.blacklistusers_sql as sql from SaitamaRobot import (DEV_USERS, OWNER_ID, SUDO_USERS, SUPPORT_USERS, - WHITELIST_USERS, dispatcher) + TIGER_USERS, WHITELIST_USERS, dispatcher) from SaitamaRobot.modules.helper_funcs.chat_status import dev_plus from SaitamaRobot.modules.helper_funcs.extraction import (extract_user, extract_user_and_text) @@ -132,7 +132,9 @@ def __user_info__(user_id): is_blacklisted = sql.is_user_blacklisted(user_id) text = "Blacklisted: {}" - + if int(user_id) in SUDO_USERS + TIGER_USERS + WHITELIST_USERS: + text = text.format("???") + return text if is_blacklisted: text = text.format("Yes") reason = sql.get_reason(user_id) diff --git a/SaitamaRobot/modules/connection.py b/SaitamaRobot/modules/connection.py index 64045c8ef3..d8ba3b03ed 100644 --- a/SaitamaRobot/modules/connection.py +++ b/SaitamaRobot/modules/connection.py @@ -263,7 +263,7 @@ def connected(bot: Bot, update: Update, chat, user_id, need_admin=True): if ((isadmin) or (isallow and ismember) or (user.id in SUDO_USERS) or (user.id in DEV_USERS)): - if need_admin == True: + if need_admin is True: if (getstatusadmin.status in ("administrator", "creator") or user_id in SUDO_USERS or user.id in DEV_USERS): return conn_id diff --git a/SaitamaRobot/modules/currency_converter.py b/SaitamaRobot/modules/currency_converter.py index e9abafc4a4..e7bffe96a1 100644 --- a/SaitamaRobot/modules/currency_converter.py +++ b/SaitamaRobot/modules/currency_converter.py @@ -46,20 +46,9 @@ def convert(update: Update, context: CallbackContext): parse_mode=ParseMode.MARKDOWN) -__help__ = """ - • `/cash`*:* currency converter - - *Example syntax:* - `/cash 1 USD INR` _OR_ `/cash 1 usd inr` - - *Output:* `1.0 USD = 75.505 INR` - -""" - CONVERTER_HANDLER = CommandHandler('cash', convert) dispatcher.add_handler(CONVERTER_HANDLER) -__mod_name__ = "Currency Converter" __command_list__ = ["cash"] __handlers__ = [CONVERTER_HANDLER] diff --git a/SaitamaRobot/modules/cust_filters.py b/SaitamaRobot/modules/cust_filters.py index c879c7c84a..f53d5e3dea 100644 --- a/SaitamaRobot/modules/cust_filters.py +++ b/SaitamaRobot/modules/cust_filters.py @@ -54,7 +54,7 @@ def list_handlers(update, context): user = update.effective_user conn = connected(context.bot, update, chat, user.id, need_admin=False) - if not conn == False: + if not conn is False: chat_id = conn chat_name = dispatcher.bot.getChat(conn).title filter_list = "*Filter in {}:*\n" @@ -105,7 +105,7 @@ def filters(update, context): 1) # use python's maxsplit to separate Cmd, keyword, and reply_text conn = connected(context.bot, update, chat, user.id) - if not conn == False: + if not conn is False: chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: @@ -223,7 +223,7 @@ def stop_filter(update, context): args = update.effective_message.text.split(None, 1) conn = connected(context.bot, update, chat, user.id) - if not conn == False: + if not conn is False: chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: diff --git a/SaitamaRobot/modules/disasters.py b/SaitamaRobot/modules/disasters.py index 3999d5c0dd..25cb282537 100644 --- a/SaitamaRobot/modules/disasters.py +++ b/SaitamaRobot/modules/disasters.py @@ -529,13 +529,64 @@ def devlist(update: Update, context: CallbackContext): __help__ = f""" - • `/heroes`*:* Lists all Hero Association members. - • `/dragons`*:* Lists all Dragon disasters. - • `/demons`*:* Lists all Demon disasters. - • `/tigers`*:* Lists all Tigers disasters. - • `/wolves`*:* Lists all Wolf disasters. - *Note:* These commands list users with special bot priveleges and can only be used by them. - You can visit {SUPPORT_CHAT} to query more about these. +*⚠️ Notice:* +Commands listed here only work for users with special access are mainly used for troubleshooting, debugging purposes. +Group admins/group owners do not need these commands. + + ╔ *List all special users:* + ╠ `/dragons`*:* Lists all Dragon disasters. + ╠ `/demons`*:* Lists all Demon disasters. + ╠ `/tigers`*:* Lists all Tigers disasters. + ╠ `/wolves`*:* Lists all Wolf disasters. + ╚ `/heroes`*:* Lists all Hero Association members. + + ╔ *Ping:* + ╠ `/ping`*:* gets ping time of bot to telegram server + ╚ `/pingall`*:* gets all listed ping times + + ╔ *Broadcast: (Bot owner only)* + ╠ *Note:* This supports basic markdown + ╠ `/broadcastall`*:* Broadcasts everywhere + ╠ `/broadcastusers`*:* Broadcasts too all users + ╚ `/broadcastgroups`*:* Broadcasts too all groups + + ╔ *Getchats:* + ╚ `/getchats ID`*:* Gets a list of group names the user has been seen in. Bot owner only. + + ╔ *Blacklist:* + ╠ `/ignore`*:* Blacklists a user from + ╠ using the bot entirely. + ╚ `/notice`*:* Whitelists the user to allow bot usage. + + ╔ *Speedtest:* + ╚ `/speedtest`*:* Runs a speedtest and gives you 2 options to choose from, text or image output. + + ╔ *Global Bans:* + ╠ `/gban user reason`*:* Globally bans a user. + ╚ `/ungban user reason`*:* Unbans the user from the global bans list + + ╔ *Module loading:* + ╠ `/listmodules`*:* Lists names of all modules + ╠ `/load modulename`*:* Loads the said module to + ╠ memory without restarting. + ╠ `/unload modulename`*:* Loads the said module from + ╚ memory without restarting.memory without restarting the bot + + ╔ *Remote commands:* + ╠ `/runban user group`*:* + ╠ `/rpunch user group`*:* + ╠ `/rmute user group`*:* + ╚ `/runmute user group`*:* + + ╔ *Shell commands:* + ╠ `/eval`*:* Self explanatory + ╚ `/py`*:* Self explanatory + + ╔ *Windows self hosted only:* + ╠ `/restart`*:* Restarts the bots service. + ╚ `/gitpull`*:* Pulls the repo and then restarts the bots service. + +You can visit {SUPPORT_CHAT} if you want details on these. """ SUDO_HANDLER = CommandHandler(("addsudo", "adddragon"), addsudo) diff --git a/SaitamaRobot/modules/feds.py b/SaitamaRobot/modules/feds.py index 70f6eecc21..0131d8f728 100644 --- a/SaitamaRobot/modules/feds.py +++ b/SaitamaRobot/modules/feds.py @@ -143,6 +143,28 @@ def del_fed(update: Update, context: CallbackContext): callback_data="rmfed_cancel")]])) +@run_async +def rename_fed(update, context): + user = update.effective_user + msg = update.effective_message + args = msg.text.split(None, 2) + + if len(args) < 3: + return msg.reply_text("usage: /renamefed ") + + fed_id, newname = args[1], args[2] + verify_fed = sql.get_fed_info(fed_id) + + if not verify_fed: + return msg.reply_text("This fed not exist in my database!") + + if is_user_fed_owner(fed_id, user.id): + sql.rename_fed(fed_id, user.id, newname) + msg.reply_text(f"Successfully renamed your fed name to {newname}!") + else: + msg.reply_text("Only federation owner can do this!") + + @run_async def fed_chat(update: Update, context: CallbackContext): bot, args = context.bot, context.args @@ -405,7 +427,6 @@ def fed_info(update: Update, context: CallbackContext): except: owner_name = owner.first_name FEDADMIN = sql.all_fed_users(fed_id) - FEDADMIN.append(int(owner.id)) TotalAdminFed = len(FEDADMIN) user = update.effective_user @@ -2104,6 +2125,7 @@ def fed_user_help(update: Update, context: CallbackContext): NEW_FED_HANDLER = CommandHandler("newfed", new_fed) DEL_FED_HANDLER = CommandHandler("delfed", del_fed) +RENAME_FED = CommandHandler("renamefed", rename_fed) JOIN_FED_HANDLER = CommandHandler("joinfed", join_fed) LEAVE_FED_HANDLER = CommandHandler("leavefed", leave_fed) PROMOTE_FED_HANDLER = CommandHandler("fpromote", user_join_fed) @@ -2134,6 +2156,7 @@ def fed_user_help(update: Update, context: CallbackContext): dispatcher.add_handler(NEW_FED_HANDLER) dispatcher.add_handler(DEL_FED_HANDLER) +dispatcher.add_handler(RENAME_FED) dispatcher.add_handler(JOIN_FED_HANDLER) dispatcher.add_handler(LEAVE_FED_HANDLER) dispatcher.add_handler(PROMOTE_FED_HANDLER) diff --git a/SaitamaRobot/modules/fun.py b/SaitamaRobot/modules/fun.py index c7cbdc92b2..8990cf4070 100644 --- a/SaitamaRobot/modules/fun.py +++ b/SaitamaRobot/modules/fun.py @@ -120,15 +120,17 @@ def table(update: Update, context: CallbackContext): __help__ = """ - • `/runs`*:* reply a random string from an array of replies. - • `/slap`*:* slap a user, or get slapped if not a reply. - • `/shrug`*:* get shrug XD. - • `/table`*:* get flip/unflip :v. + • `/runs`*:* reply a random string from an array of replies + • `/slap`*:* slap a user, or get slapped if not a reply + • `/shrug`*:* get shrug XD + • `/table`*:* get flip/unflip :v • `/decide`*:* Randomly answers yes/no/maybe • `/toss`*:* Tosses A coin • `/bluetext`*:* check urself :V - • `/roll`*:* Roll a dice. + • `/roll`*:* Roll a dice • `/rlg`*:* Join ears,nose,mouth and create an emo ;-; + • `/shout `*:* write anything you want to give loud shout + • `/weebify `*:* returns a weebified text """ RUNS_HANDLER = DisableAbleCommandHandler("runs", runs) diff --git a/SaitamaRobot/modules/global_bans.py b/SaitamaRobot/modules/global_bans.py index f8a8d8dd3a..4f8e701f2b 100644 --- a/SaitamaRobot/modules/global_bans.py +++ b/SaitamaRobot/modules/global_bans.py @@ -467,6 +467,9 @@ def __user_info__(user_id): is_gbanned = sql.is_user_gbanned(user_id) text = "Globally banned: {}" + if int(user_id) in SUDO_USERS + TIGER_USERS + WHITELIST_USERS: + text = text.format("???") + return text if is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) @@ -499,6 +502,7 @@ def __chat_settings__(chat_id, user_id): *What is SpamWatch?* SpamWatch maintains a large constantly updated ban-list of spambots, trolls, bitcoin spammers and unsavoury characters[.](https://telegra.ph/file/f584b643c6f4be0b1de53.jpg) Constantly help banning spammers off from your group automatically So, you wont have to worry about spammers storming your group. +*Note:* Users can appeal spamwatch bans or report spammers at @SpamwatchSupport """ GBAN_HANDLER = CommandHandler("gban", gban) @@ -514,9 +518,9 @@ def __chat_settings__(chat_id, user_id): dispatcher.add_handler(GBAN_LIST) dispatcher.add_handler(GBAN_STATUS) -__mod_name__ = "Global Bans" +__mod_name__ = "Anti-Spam" __handlers__ = [GBAN_HANDLER, UNGBAN_HANDLER, GBAN_LIST, GBAN_STATUS] if STRICT_GBAN: # enforce GBANS if this is set dispatcher.add_handler(GBAN_ENFORCER, GBAN_ENFORCE_GROUP) - __handlers__.append((GBAN_ENFORCER, GBAN_ENFORCE_GROUP)) + __handlers__.append((GBAN_ENFORCER, GBAN_ENFORCE_GROUP)) \ No newline at end of file diff --git a/SaitamaRobot/modules/gtranslator.py b/SaitamaRobot/modules/gtranslator.py index 34bc29a2d3..6985b40631 100644 --- a/SaitamaRobot/modules/gtranslator.py +++ b/SaitamaRobot/modules/gtranslator.py @@ -14,10 +14,13 @@ def totranslate(update: Update, context: CallbackContext): if "-" in key: problem_lang_code.append(key) try: - if msg.reply_to_message and msg.reply_to_message.text: - + if msg.reply_to_message: args = update.effective_message.text.split(None, 1) - text = msg.reply_to_message.text + if msg.reply_to_message.text: + text = msg.reply_to_message.text + elif msg.reply_to_message.caption: + text = msg.reply_to_message.caption + message = update.effective_message dest_lang = None diff --git a/SaitamaRobot/modules/locks.py b/SaitamaRobot/modules/locks.py index 1b2aa1788f..9b3e152dff 100644 --- a/SaitamaRobot/modules/locks.py +++ b/SaitamaRobot/modules/locks.py @@ -222,7 +222,7 @@ def lock(update, context) -> str: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = chat.title - text = "Locked all {} messages for non-admins in {}!".format( + text = "Locked {} for non-admins in {}!".format( ltype, chat_name) else: if update.effective_message.chat.type == "private": @@ -234,8 +234,7 @@ def lock(update, context) -> str: chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title - text = "Locked all {} messages for non-admins!".format( - ltype) + text = "Locked {} for non-admins!".format(ltype) sql.update_lock(chat.id, ltype, locked=True) send_message( update.effective_message, text, parse_mode="markdown") @@ -329,7 +328,7 @@ def unlock(update, context) -> str: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = chat.title - text = "Unlocked {} messages for everyone in {}!".format( + text = "Unlocked {} for everyone in {}!".format( ltype, chat_name) else: if update.effective_message.chat.type == "private": @@ -341,7 +340,7 @@ def unlock(update, context) -> str: chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title - text = "Unlocked {} messages for everyone!".format(ltype) + text = "Unlocked {} for everyone!".format(ltype) sql.update_lock(chat.id, ltype, locked=False) send_message( update.effective_message, text, parse_mode="markdown") diff --git a/SaitamaRobot/modules/misc.py b/SaitamaRobot/modules/misc.py index fd46840880..5fffaee4ec 100644 --- a/SaitamaRobot/modules/misc.py +++ b/SaitamaRobot/modules/misc.py @@ -3,7 +3,7 @@ import requests from SaitamaRobot import (DEV_USERS, OWNER_ID, SUDO_USERS, SUPPORT_USERS, - TIGER_USERS, WHITELIST_USERS, dispatcher) + TIGER_USERS, WHITELIST_USERS, dispatcher, sw) from SaitamaRobot.__main__ import STATS, TOKEN, USER_INFO from SaitamaRobot.modules.disable import DisableAbleCommandHandler from SaitamaRobot.modules.helper_funcs.chat_status import sudo_plus, user_admin @@ -128,25 +128,36 @@ def info(update: Update, context: CallbackContext): text += f"\nPermanent user link: {mention_html(user.id, 'link')}" + try: + spamwtc = sw.get_ban(int(user.id)) + if spamwtc: + text += "\n\nThis person is banned in Spamwatch!" + text += f"\nReason:
{spamwtc.reason}
" + text += "\nAppeal at @SpamWatchSupport" + else: + pass + except: + pass # don't crash if api is down somehow... + disaster_level_present = False if user.id == OWNER_ID: - text += "\nThe Disaster level of this person is 'God'." + text += "\n\nThe Disaster level of this person is 'God'." disaster_level_present = True elif user.id in DEV_USERS: - text += "\nThis member is one of 'Hero Association'." + text += "\n\nThis member is one of 'Hero Association'." disaster_level_present = True elif user.id in SUDO_USERS: - text += "\nThe Disaster level of this person is 'Dragon'." + text += "\n\nThe Disaster level of this person is 'Dragon'." disaster_level_present = True elif user.id in SUPPORT_USERS: - text += "\nThe Disaster level of this person is 'Demon'." + text += "\n\nThe Disaster level of this person is 'Demon'." disaster_level_present = True elif user.id in TIGER_USERS: - text += "\nThe Disaster level of this person is 'Tiger'." + text += "\n\nThe Disaster level of this person is 'Tiger'." disaster_level_present = True elif user.id in WHITELIST_USERS: - text += "\nThe Disaster level of this person is 'Wolf'." + text += "\n\nThe Disaster level of this person is 'Wolf'." disaster_level_present = True if disaster_level_present: @@ -217,10 +228,24 @@ def stats(update: Update, context: CallbackContext): __help__ = """ - • `/id`*:* get the current group id. If used by replying to a message, gets that user's id. - • `/gifid`*:* reply to a gif to me to tell you its file ID. - • `/info`*:* get information about a user. - • `/markdownhelp`*:* quick summary of how markdown works in telegram - can only be called in private chats. +*Available commands:* +*Markdown:* + • `/markdownhelp`*:* quick summary of how markdown works in telegram - can only be called in private chats +*Paste:* + • `/paste`*:* Saves replied content to `nekobin.com` and replies with a url +*React:* + • `/react`*:* Reacts with a random reaction +*Urban Dictonary:* + • `/ud `*:* Type the word or expression you want to search use +*Wikipedia:* + • `/wiki `*:* wikipedia your query +*Currency converter:* + • `/cash`*:* currency converter +Example: + `/cash 1 USD INR` + _OR_ + `/cash 1 usd inr` +Output: `1.0 USD = 75.505 INR` """ ID_HANDLER = DisableAbleCommandHandler("id", get_id) @@ -238,7 +263,7 @@ def stats(update: Update, context: CallbackContext): dispatcher.add_handler(MD_HELP_HANDLER) dispatcher.add_handler(STATS_HANDLER) -__mod_name__ = "Misc" +__mod_name__ = "Extras" __command_list__ = ["id", "info", "echo"] __handlers__ = [ ID_HANDLER, GIFID_HANDLER, INFO_HANDLER, ECHO_HANDLER, MD_HELP_HANDLER, diff --git a/SaitamaRobot/modules/paste.py b/SaitamaRobot/modules/paste.py index f50a29d813..131a5564a2 100644 --- a/SaitamaRobot/modules/paste.py +++ b/SaitamaRobot/modules/paste.py @@ -35,13 +35,8 @@ def paste(update: Update, context: CallbackContext): disable_web_page_preview=True) -__help__ = """ - • `/paste`*:* Do a paste at `neko.bin` -""" - PASTE_HANDLER = DisableAbleCommandHandler("paste", paste) dispatcher.add_handler(PASTE_HANDLER) -__mod_name__ = "Paste" __command_list__ = ["paste"] __handlers__ = [PASTE_HANDLER] diff --git a/SaitamaRobot/modules/ping.py b/SaitamaRobot/modules/ping.py index 390154cd0e..2efefda252 100644 --- a/SaitamaRobot/modules/ping.py +++ b/SaitamaRobot/modules/ping.py @@ -102,17 +102,11 @@ def pingall(update: Update, context: CallbackContext): reply_msg, parse_mode=ParseMode.HTML, disable_web_page_preview=True) -__help__ = """ - • `/ping`*:* get ping time of bot to telegram server - • `/pingall`*:* get all listed ping time -""" - PING_HANDLER = DisableAbleCommandHandler("ping", ping) PINGALL_HANDLER = DisableAbleCommandHandler("pingall", pingall) dispatcher.add_handler(PING_HANDLER) dispatcher.add_handler(PINGALL_HANDLER) -__mod_name__ = "Ping" __command_list__ = ["ping", "pingall"] __handlers__ = [PING_HANDLER, PINGALL_HANDLER] diff --git a/SaitamaRobot/modules/reactions.py b/SaitamaRobot/modules/reactions.py index 14270e4a1f..396bb0cc6b 100644 --- a/SaitamaRobot/modules/reactions.py +++ b/SaitamaRobot/modules/reactions.py @@ -59,14 +59,9 @@ def react(update: Update, context: CallbackContext): message.reply_text(react) -__help__ = """ - • `/react`*:* Reacts with a random reaction -""" - REACT_HANDLER = DisableAbleCommandHandler("react", react) dispatcher.add_handler(REACT_HANDLER) -__mod_name__ = "React" __command_list__ = ["react"] __handlers__ = [REACT_HANDLER] diff --git a/SaitamaRobot/modules/remote_cmds.py b/SaitamaRobot/modules/remote_cmds.py index 9a917a3468..4ec951c1bb 100644 --- a/SaitamaRobot/modules/remote_cmds.py +++ b/SaitamaRobot/modules/remote_cmds.py @@ -11,9 +11,9 @@ "User is an administrator of the chat", "Chat not found", "Not enough rights to restrict/unrestrict chat member", "User_not_participant", "Peer_id_invalid", "Group chat was deactivated", - "Need to be inviter of a user to kick it from a basic group", + "Need to be inviter of a user to punch it from a basic group", "Chat_admin_required", - "Only the creator of a basic group can kick group administrators", + "Only the creator of a basic group can punch group administrators", "Channel_private", "Not in the chat" } @@ -21,9 +21,9 @@ "User is an administrator of the chat", "Chat not found", "Not enough rights to restrict/unrestrict chat member", "User_not_participant", "Peer_id_invalid", "Group chat was deactivated", - "Need to be inviter of a user to kick it from a basic group", + "Need to be inviter of a user to punch it from a basic group", "Chat_admin_required", - "Only the creator of a basic group can kick group administrators", + "Only the creator of a basic group can punch group administrators", "Channel_private", "Not in the chat" } @@ -31,9 +31,9 @@ "User is an administrator of the chat", "Chat not found", "Not enough rights to restrict/unrestrict chat member", "User_not_participant", "Peer_id_invalid", "Group chat was deactivated", - "Need to be inviter of a user to kick it from a basic group", + "Need to be inviter of a user to punch it from a basic group", "Chat_admin_required", - "Only the creator of a basic group can kick group administrators", + "Only the creator of a basic group can punch group administrators", "Channel_private", "Not in the chat" } @@ -41,9 +41,9 @@ "User is an administrator of the chat", "Chat not found", "Not enough rights to restrict/unrestrict chat member", "User_not_participant", "Peer_id_invalid", "Group chat was deactivated", - "Need to be inviter of a user to kick it from a basic group", + "Need to be inviter of a user to punch it from a basic group", "Chat_admin_required", - "Only the creator of a basic group can kick group administrators", + "Only the creator of a basic group can punch group administrators", "Channel_private", "Not in the chat" } @@ -51,9 +51,9 @@ "User is an administrator of the chat", "Chat not found", "Not enough rights to restrict/unrestrict chat member", "User_not_participant", "Peer_id_invalid", "Group chat was deactivated", - "Need to be inviter of a user to kick it from a basic group", + "Need to be inviter of a user to punch it from a basic group", "Chat_admin_required", - "Only the creator of a basic group can kick group administrators", + "Only the creator of a basic group can punch group administrators", "Channel_private", "Not in the chat" } @@ -252,7 +252,7 @@ def rkick(update: Update, context: CallbackContext): if not is_bot_admin(chat, bot.id) or not chat.get_member( bot.id).can_restrict_members: message.reply_text( - "I can't restrict people there! Make sure I'm admin and can kick users." + "I can't restrict people there! Make sure I'm admin and can punch users." ) return @@ -266,27 +266,27 @@ def rkick(update: Update, context: CallbackContext): raise if is_user_ban_protected(chat, user_id, member): - message.reply_text("I really wish I could kick admins...") + message.reply_text("I really wish I could punch admins...") return if user_id == bot.id: - message.reply_text("I'm not gonna KICK myself, are you crazy?") + message.reply_text("I'm not gonna punch myself, are you crazy?") return try: chat.unban_member(user_id) - message.reply_text("Kicked from chat!") + message.reply_text("Punched from chat!") except BadRequest as excp: if excp.message == "Reply message not found": # Do not reply - message.reply_text('Kicked!', quote=False) + message.reply_text('Punched!', quote=False) elif excp.message in RKICK_ERRORS: message.reply_text(excp.message) else: LOGGER.warning(update) - LOGGER.exception("ERROR kicking user %s in chat %s (%s) due to %s", + LOGGER.exception("ERROR punching user %s in chat %s (%s) due to %s", user_id, chat.title, chat.id, excp.message) - message.reply_text("Well damn, I can't kick that user.") + message.reply_text("Well damn, I can't punch that user.") @run_async @@ -455,15 +455,11 @@ def runmute(update: Update, context: CallbackContext): message.reply_text("Well damn, I can't unmute that user.") -__help__ = "" - -__mod_name__ = "Remote Commands" - RBAN_HANDLER = CommandHandler("rban", rban, filters=CustomFilters.sudo_filter) RUNBAN_HANDLER = CommandHandler( "runban", runban, filters=CustomFilters.sudo_filter) RKICK_HANDLER = CommandHandler( - "rkick", rkick, filters=CustomFilters.sudo_filter) + "rpunch", rkick, filters=CustomFilters.sudo_filter) RMUTE_HANDLER = CommandHandler( "rmute", rmute, filters=CustomFilters.sudo_filter) RUNMUTE_HANDLER = CommandHandler( diff --git a/SaitamaRobot/modules/shout.py b/SaitamaRobot/modules/shout.py index f1f5c93424..0d868cdd90 100644 --- a/SaitamaRobot/modules/shout.py +++ b/SaitamaRobot/modules/shout.py @@ -19,24 +19,9 @@ def shout(update: Update, context: CallbackContext): return update.effective_message.reply_text(msg, parse_mode="MARKDOWN") -__help__ = """ - A little piece of fun wording! Give a loud shout out in the chatroom. - - i.e `/shout HELP`, bot replies with huge coded *HELP* letters within the square. - - • `/shout `*:* write anything you want to give loud shout. - ``` - t e s t - e e - s s - t t - ``` -""" - SHOUT_HANDLER = DisableAbleCommandHandler("shout", shout) dispatcher.add_handler(SHOUT_HANDLER) -__mod_name__ = "Shout" __command_list__ = ["shout"] __handlers__ = [SHOUT_HANDLER] diff --git a/SaitamaRobot/modules/sql/connection_sql.py b/SaitamaRobot/modules/sql/connection_sql.py index c6ac0543f7..f4e19b106a 100644 --- a/SaitamaRobot/modules/sql/connection_sql.py +++ b/SaitamaRobot/modules/sql/connection_sql.py @@ -192,7 +192,7 @@ def __load_user_history(): HISTORY_CONNECT = {} for x in qall: check = HISTORY_CONNECT.get(x.user_id) - if check == None: + if check is None: HISTORY_CONNECT[x.user_id] = {} HISTORY_CONNECT[x.user_id][x.conn_time] = { "chat_name": x.chat_name, diff --git a/SaitamaRobot/modules/sql/feds_sql.py b/SaitamaRobot/modules/sql/feds_sql.py index 7ee1e7347f..12b0cd2180 100644 --- a/SaitamaRobot/modules/sql/feds_sql.py +++ b/SaitamaRobot/modules/sql/feds_sql.py @@ -292,6 +292,26 @@ def del_fed(fed_id): return True +def rename_fed(fed_id, owner_id, newname): + with FEDS_LOCK: + global FEDERATION_BYFEDID, FEDERATION_BYOWNER, FEDERATION_BYNAME + fed = SESSION.query(Federations).get(fed_id) + if not fed: + return False + fed.fed_name = newname + SESSION.commit() + + # Update the dicts + oldname = FEDERATION_BYFEDID[str(fed_id)]["fname"] + tempdata = FEDERATION_BYNAME[oldname] + FEDERATION_BYNAME.pop(oldname) + + FEDERATION_BYOWNER[str(owner_id)]["fname"] = newname + FEDERATION_BYFEDID[str(fed_id)]["fname"] = newname + FEDERATION_BYNAME[newname] = tempdata + return True + + def chat_join_fed(fed_id, chat_name, chat_id): with FEDS_LOCK: global FEDERATION_CHATS, FEDERATION_CHATS_BYID diff --git a/SaitamaRobot/modules/ud.py b/SaitamaRobot/modules/ud.py index ca62d1b910..98bb690562 100644 --- a/SaitamaRobot/modules/ud.py +++ b/SaitamaRobot/modules/ud.py @@ -18,14 +18,9 @@ def ud(update: Update, context: CallbackContext): message.reply_text(reply_text, parse_mode=ParseMode.MARKDOWN) -__help__ = """ - • `/ud `*:* Type the word or expression you want to search use. -""" - UD_HANDLER = DisableAbleCommandHandler(["ud"], ud) dispatcher.add_handler(UD_HANDLER) -__mod_name__ = "Urban dictionary" __command_list__ = ["ud"] __handlers__ = [UD_HANDLER] diff --git a/SaitamaRobot/modules/userinfo.py b/SaitamaRobot/modules/userinfo.py index da12266876..f4b0b8097b 100644 --- a/SaitamaRobot/modules/userinfo.py +++ b/SaitamaRobot/modules/userinfo.py @@ -144,10 +144,26 @@ def __user_info__(user_id): __help__ = """ - • `/setbio `*:* while replying, will save another user's bio - • `/bio`*:* will get your or another user's bio. This cannot be set by yourself. +*ID:* + • `/id`*:* get the current group id. If used by replying to a message, gets that user's id. + • `/gifid`*:* reply to a gif to me to tell you its file ID. + +*Self addded information:* • `/setme `*:* will set your info - • `/me`*:* will get your or another user's info + • `/me`*:* will get your or another user's info. +Examples: + `/setme I am a wolf.` + `/me @username(defaults to yours if no user specified)` + +*Information others add on you:* + • `/bio`*:* will get your or another user's bio. This cannot be set by yourself. +• `/setbio `*:* while replying, will save another user's bio +Examples: + `/bio @username(defaults to yours if not specified).` + `/setbio This user is a wolf` (reply to the user) + +*Overall Information about you:* + • `/info`*:* get information about a user. """ SET_BIO_HANDLER = DisableAbleCommandHandler("setbio", set_about_bio) @@ -161,7 +177,7 @@ def __user_info__(user_id): dispatcher.add_handler(SET_ABOUT_HANDLER) dispatcher.add_handler(GET_ABOUT_HANDLER) -__mod_name__ = "Bios and Abouts" +__mod_name__ = "Info" __command_list__ = ["setbio", "bio", "setme", "me"] __handlers__ = [ SET_BIO_HANDLER, GET_BIO_HANDLER, SET_ABOUT_HANDLER, GET_ABOUT_HANDLER diff --git a/SaitamaRobot/modules/users.py b/SaitamaRobot/modules/users.py index f06d6fd646..e26df5bdd1 100644 --- a/SaitamaRobot/modules/users.py +++ b/SaitamaRobot/modules/users.py @@ -54,9 +54,9 @@ def broadcast(update: Update, context: CallbackContext): if len(to_send) >= 2: to_group = to_user = False - if to_send[0] == '/broadcastgroup': + if to_send[0] == '/broadcastgroups': to_group = True - if to_send[0] == '/broadcastuser': + if to_send[0] == '/broadcastusers': to_user = True else: to_group = to_user = True @@ -159,7 +159,7 @@ def __migrate__(old_chat_id, new_chat_id): __help__ = "" # no help string BROADCAST_HANDLER = CommandHandler( - ["broadcastall", "broadcastuser", "broadcastgroup"], broadcast) + ["broadcastall", "broadcastusers", "broadcastgroups"], broadcast) USER_HANDLER = MessageHandler(Filters.all & Filters.group, log_user) CHAT_CHECKER_HANDLER = MessageHandler(Filters.all & Filters.group, chat_checker) CHATLIST_HANDLER = CommandHandler("chatlist", chats) diff --git a/SaitamaRobot/modules/weebify.py b/SaitamaRobot/modules/weebify.py index 547a87acb6..35446fb145 100644 --- a/SaitamaRobot/modules/weebify.py +++ b/SaitamaRobot/modules/weebify.py @@ -41,14 +41,9 @@ def weebify(update: Update, context: CallbackContext): message.reply_text(string) -__help__ = """ - • `/weebify `*:* returns a weebified text - """ - WEEBIFY_HANDLER = DisableAbleCommandHandler("weebify", weebify) dispatcher.add_handler(WEEBIFY_HANDLER) -__mod_name__ = "Weebify" __command_list__ = ["weebify"] __handlers__ = [WEEBIFY_HANDLER] diff --git a/SaitamaRobot/modules/wiki.py b/SaitamaRobot/modules/wiki.py index fcef87ab65..7a3f9e7c60 100644 --- a/SaitamaRobot/modules/wiki.py +++ b/SaitamaRobot/modules/wiki.py @@ -45,13 +45,5 @@ def wiki(update: Update, context: CallbackContext): disable_web_page_preview=True) -__help__ = """ -WIKIPEDIA!! -*Available commands:* - • `/wiki `*:* wiki your query. -""" - -__mod_name__ = "Wiki" - WIKI_HANDLER = DisableAbleCommandHandler("wiki", wiki) dispatcher.add_handler(WIKI_HANDLER)