Skip to content

Commit

Permalink
Merge pull request AnimeKaizoku#193 from AnimeKaizoku/shiken
Browse files Browse the repository at this point in the history
Push minor edits and improvements to master
  • Loading branch information
TsunayoshiSawada authored Aug 29, 2020
2 parents 7ff0d8b + 99018fb commit eecad59
Show file tree
Hide file tree
Showing 27 changed files with 246 additions and 167 deletions.
5 changes: 2 additions & 3 deletions SaitamaRobot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <module name>: 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.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions SaitamaRobot/modules/antiflood.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<b>{}:</b>" \
"\n#{}" \
Expand Down
4 changes: 2 additions & 2 deletions SaitamaRobot/modules/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion SaitamaRobot/modules/blacklist_stickers.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def __stats__():
• `<sticker link>` can be `https://t.me/addstickers/<sticker>` or just `<sticker>` or reply to the sticker message.
"""

__mod_name__ = "Sticker Blacklist"
__mod_name__ = "Stickers Blacklist"

BLACKLIST_STICKER_HANDLER = DisableAbleCommandHandler(
"blsticker", blackliststicker, admin_ok=True)
Expand Down
6 changes: 4 additions & 2 deletions SaitamaRobot/modules/blacklistusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -132,7 +132,9 @@ def __user_info__(user_id):
is_blacklisted = sql.is_user_blacklisted(user_id)

text = "Blacklisted: <b>{}</b>"

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)
Expand Down
2 changes: 1 addition & 1 deletion SaitamaRobot/modules/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions SaitamaRobot/modules/currency_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
6 changes: 3 additions & 3 deletions SaitamaRobot/modules/cust_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
65 changes: 58 additions & 7 deletions SaitamaRobot/modules/disasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
78 changes: 51 additions & 27 deletions SaitamaRobot/modules/feds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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>")

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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2045,43 +2066,44 @@ def get_chat(chat_id, chat_data):
def fed_owner_help(update: Update, context: CallbackContext):
update.effective_message.reply_text(
"""*👑 Fed Owner Only:*
• `/newfed <fed_name>`*:* Creates a Federation, One allowed per user. Can also be used to rename the Fed. (max. 64 chars)
• `/delfed <fed_id>`*:* Delete a Federation, and any information related to it. Will not cancel blocked users.
• `/fpromote <user>`*:* Assigns the user as a federation admin. Enables all commands for the user under `Fed Admins`.
• `/fdemote <user>`*:* Drops the User from the admin Federation to a normal User.
• `/subfed <fed_id>`*:* Subscribes to a given fed ID, bans from that subscribed fed will also happen in your fed.
• `/unsubfed <fed_id>`*:* Unsubscribes to a given fed ID.
• `/setfedlog <fed_id>`*:* Sets the group as a fed log report base for the federation.
• `/unsetfedlog <fed_id>`*:* Removed the group as a fed log report base for the federation.
• `/fbroadcast <message>`*:* Broadcasts a messages to all groups that have joined your fed.
• `/fedsubs`*:* Shows the feds your group is subscribed to. `(broken rn)`""",
• `/newfed <fed_name>`*:* Creates a Federation, One allowed per user
• `/renamefed <fed_id> <new_fed_name>`*:* Renames the fed id to a new name
• `/delfed <fed_id>`*:* Delete a Federation, and any information related to it. Will not cancel blocked users
• `/fpromote <user>`*:* Assigns the user as a federation admin. Enables all commands for the user under `Fed Admins`
• `/fdemote <user>`*:* Drops the User from the admin Federation to a normal User
• `/subfed <fed_id>`*:* Subscribes to a given fed ID, bans from that subscribed fed will also happen in your fed
• `/unsubfed <fed_id>`*:* Unsubscribes to a given fed ID
• `/setfedlog <fed_id>`*:* Sets the group as a fed log report base for the federation
• `/unsetfedlog <fed_id>`*:* Removed the group as a fed log report base for the federation
• `/fbroadcast <message>`*:* Broadcasts a messages to all groups that have joined your fed
• `/fedsubs`*:* Shows the feds your group is subscribed to `(broken rn)`""",
parse_mode=ParseMode.MARKDOWN)


@run_async
def fed_admin_help(update: Update, context: CallbackContext):
update.effective_message.reply_text(
"""*🔱 Fed Admins:*
• `/fban <user> <reason>`*:* Fed bans a user.
• `/unfban <user> <reason>`*:* Removes a user from a fed ban.
• `/fedinfo <fed_id>`*:* Information about the specified Federation.
• `/joinfed <fed_id>`*:* Join the current chat to the Federation. Only chat owners can do this. Every chat can only be in one Federation.
• `/leavefed <fed_id>`*:* Leave the Federation given. Only chat owners can do this.
• `/setfrules <rules>`*:* Arrange Federation rules.
• `/fednotif <on/off>`*:* Federation settings not in PM when there are users who are fbaned/unfbanned.
• `/frules`*:* See Federation regulations.
• `/fedadmins`*:* Show Federation admin.
• `/fbanlist`*:* Displays all users who are victimized at the Federation at this time.
• `/fedchats`*:* Get all the chats that are connected in the Federation.\n""",
• `/fban <user> <reason>`*:* Fed bans a user
• `/unfban <user> <reason>`*:* Removes a user from a fed ban
• `/fedinfo <fed_id>`*:* Information about the specified Federation
• `/joinfed <fed_id>`*:* Join the current chat to the Federation. Only chat owners can do this. Every chat can only be in one Federation
• `/leavefed <fed_id>`*:* Leave the Federation given. Only chat owners can do this
• `/setfrules <rules>`*:* Arrange Federation rules
• `/fednotif <on/off>`*:* Federation settings not in PM when there are users who are fbaned/unfbanned
• `/frules`*:* See Federation regulations
• `/fedadmins`*:* Show Federation admin
• `/fbanlist`*:* Displays all users who are victimized at the Federation at this time
• `/fedchats`*:* Get all the chats that are connected in the Federation\n""",
parse_mode=ParseMode.MARKDOWN)


@run_async
def fed_user_help(update: Update, context: CallbackContext):
update.effective_message.reply_text(
"""*🎩 Any user:*
• `/fbanstat`*:* Shows if you/or the user you are replying to or their username is fbanned somewhere or not.
• `/chatfed `*:* See the Federation in the current chat.\n""",
• `/fbanstat`*:* Shows if you/or the user you are replying to or their username is fbanned somewhere or not
• `/chatfed `*:* See the Federation in the current chat\n""",
parse_mode=ParseMode.MARKDOWN)


Expand All @@ -2095,14 +2117,15 @@ def fed_user_help(update: Update, context: CallbackContext):
*Commands:*\n
Feds are now divided into 3 sections for your ease.
• `/fedownerhelp`*:* Provides help for fed creation and owner only commands.
• `/fedadminhelp`*:* Provides help for fed administration commands.
• `/feduserhelp`*:* Provides help for commands anyone can use.
• `/fedownerhelp`*:* Provides help for fed creation and owner only commands
• `/fedadminhelp`*:* Provides help for fed administration commands
• `/feduserhelp`*:* Provides help for commands anyone can use
"""

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)
Expand Down Expand Up @@ -2133,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)
Expand Down
12 changes: 7 additions & 5 deletions SaitamaRobot/modules/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <keyword>`*:* write anything you want to give loud shout
• `/weebify <text>`*:* returns a weebified text
"""

RUNS_HANDLER = DisableAbleCommandHandler("runs", runs)
Expand Down
8 changes: 6 additions & 2 deletions SaitamaRobot/modules/global_bans.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ def __user_info__(user_id):
is_gbanned = sql.is_user_gbanned(user_id)

text = "Globally banned: <b>{}</b>"
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)
Expand Down Expand Up @@ -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)
Expand All @@ -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))
Loading

0 comments on commit eecad59

Please sign in to comment.