Skip to content
This repository has been archived by the owner on Jun 18, 2022. It is now read-only.

Commit

Permalink
[feds] Update help and mention rename fed
Browse files Browse the repository at this point in the history
  • Loading branch information
BazookaHub committed Aug 29, 2020
2 parents 504e4f4 + e7e97f3 commit 99018fb
Show file tree
Hide file tree
Showing 27 changed files with 219 additions and 141 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
25 changes: 24 additions & 1 deletion 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 @@ -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)
Expand Down Expand Up @@ -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)
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))
9 changes: 6 additions & 3 deletions SaitamaRobot/modules/gtranslator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 4 additions & 5 deletions SaitamaRobot/modules/locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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")
Expand Down Expand Up @@ -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":
Expand All @@ -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")
Expand Down
Loading

0 comments on commit 99018fb

Please sign in to comment.