Skip to content

Commit

Permalink
Auto Code Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
imDivu committed Apr 11, 2023
1 parent 8616ebb commit 009b3e5
Show file tree
Hide file tree
Showing 59 changed files with 561 additions and 629 deletions.
6 changes: 4 additions & 2 deletions Cutiepii_Robot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ def get_user_list(__init__, key):
telethn = TelegramClient(MemorySession(), API_ID, API_HASH)

defaults = Defaults(block=False)
CUTIEPII_PTB = Application.builder().token(TOKEN).defaults(defaults).concurrent_updates(True).build()
CUTIEPII_PTB = Application.builder().token(TOKEN).defaults(
defaults).concurrent_updates(True).build()

# asyncio.get_event_loop().run_until_complete(CUTIEPII_PTB.bot.initialize())
#------------------------------------------------------------------
Expand All @@ -348,7 +349,8 @@ def get_user_list(__init__, key):
api_id=API_ID,
api_hash=API_HASH,
bot_token=TOKEN,
workers=min(32, os.cpu_count() + 4),
workers=min(32,
os.cpu_count() + 4),
parse_mode=ParseMode.DEFAULT,
sleep_threshold=60,
in_memory=True,
Expand Down
46 changes: 19 additions & 27 deletions Cutiepii_Robot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,13 @@
TimedOut,
Forbidden,
)
from telegram.ext import (
CallbackContext,
CallbackContext,
filters,
CallbackQueryHandler,
MessageHandler
)
from telegram.ext import (CallbackContext, CallbackContext, filters,
CallbackQueryHandler, MessageHandler)

from telegram.helpers import escape_markdown
from pyrogram import idle


def get_readable_time(seconds: int) -> str:
count = 0
ping_time = ""
Expand Down Expand Up @@ -211,10 +207,7 @@ def get_readable_time(seconds: int) -> str:


# do not async
async def send_help(context: CallbackContext,
chat_id,
text,
keyboard=None):
async def send_help(context: CallbackContext, chat_id, text, keyboard=None):
if not keyboard:
keyboard = InlineKeyboardMarkup(paginate_modules(0, HELPABLE, "help"))
await context.bot.send_message(
Expand All @@ -226,7 +219,6 @@ async def send_help(context: CallbackContext,
)



async def test(update: Update):
# pLOGGER.debug(eval(str(update)))
# await update.effective_message.reply_text("Hola tester! _I_ *have* `markdown`", parse_mode=ParseMode.MARKDOWN)
Expand Down Expand Up @@ -340,9 +332,7 @@ async def error_callback(_, context: CallbackContext):
# handle all other telegram related errors



async def help_button(update: Update,
context: CallbackContext) -> None:
async def help_button(update: Update, context: CallbackContext) -> None:
query = update.callback_query
mod_match = re.match(r"help_module\((.+?)\)", query.data)
prev_match = re.match(r"help_prev\((.+?)\)", query.data)
Expand Down Expand Up @@ -399,7 +389,6 @@ async def help_button(update: Update,
# await query.message.delete()



async def cutiepii_callback_data(update: Update,
context: CallbackContext) -> None:
query = update.callback_query
Expand Down Expand Up @@ -428,7 +417,6 @@ async def cutiepii_callback_data(update: Update,
)



async def get_help(update: Update, context: CallbackContext) -> None:
chat = update.effective_chat # type: Optional[Chat]
args = update.effective_message.text.split(None, 1)
Expand Down Expand Up @@ -508,8 +496,7 @@ async def send_settings(context: CallbackContext,
)


async def settings_button(update: Update,
context: CallbackContext) -> None:
async def settings_button(update: Update, context: CallbackContext) -> None:
query = update.callback_query
user = update.effective_user
bot = context.bot
Expand Down Expand Up @@ -586,8 +573,7 @@ async def settings_button(update: Update,
str(query.data))


async def get_settings(update: Update,
context: CallbackContext) -> None:
async def get_settings(update: Update, context: CallbackContext) -> None:
chat = update.effective_chat # type: Optional[Chat]
user = update.effective_user # type: Optional[User]
msg = update.effective_message # type: Optional[Message]
Expand Down Expand Up @@ -679,21 +665,27 @@ def main():
CUTIEPII_PTB.add_handler(DisableAbleCommandHandler("start", start))

CUTIEPII_PTB.add_handler(DisableAbleCommandHandler("help", get_help))
CUTIEPII_PTB.add_handler(CallbackQueryHandler(help_button, pattern=r"help_.*"))
CUTIEPII_PTB.add_handler(
CallbackQueryHandler(help_button, pattern=r"help_.*"))

CUTIEPII_PTB.add_handler(DisableAbleCommandHandler("settings", get_settings))
CUTIEPII_PTB.add_handler(CallbackQueryHandler(settings_button, pattern=r"stngs_"))
CUTIEPII_PTB.add_handler(
DisableAbleCommandHandler("settings", get_settings))
CUTIEPII_PTB.add_handler(
CallbackQueryHandler(settings_button, pattern=r"stngs_"))

CUTIEPII_PTB.add_handler(CallbackQueryHandler(cutiepii_callback_data, pattern=r"cutiepii_"))
CUTIEPII_PTB.add_handler(
CallbackQueryHandler(cutiepii_callback_data, pattern=r"cutiepii_"))
CUTIEPII_PTB.add_handler(DisableAbleCommandHandler("donate", donate))
CUTIEPII_PTB.add_handler(MessageHandler(filters.StatusUpdate.MIGRATE, migrate_chats))
CUTIEPII_PTB.add_handler(
MessageHandler(filters.StatusUpdate.MIGRATE, migrate_chats))

if WEBHOOK:
LOGGER.info("Using webhooks.")
CUTIEPII_PTB.run_webhook(listen="127.0.0.1", port=PORT, url_path=TOKEN)

else:
CUTIEPII_PTB.run_polling(allowed_updates=Update.ALL_TYPES, stop_signals=None)
CUTIEPII_PTB.run_polling(allowed_updates=Update.ALL_TYPES,
stop_signals=None)
LOGGER.info(
"Cutiepii Robot started, Using long polling. | BOT: [@Cutiepii_Robot]"
)
Expand Down
33 changes: 11 additions & 22 deletions Cutiepii_Robot/modules/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ async def get_users(show):
@connection_status
@bot_admin_check(AdminPerms.CAN_CHANGE_INFO)
@user_admin_check(AdminPerms.CAN_CHANGE_INFO)
async def set_sticker(update: Update,
context: CallbackContext) -> str:
async def set_sticker(update: Update, context: CallbackContext) -> str:
bot = context.bot
chat = update.effective_chat
msg = update.effective_message
Expand Down Expand Up @@ -211,8 +210,7 @@ async def set_sticker(update: Update,
@connection_status
@bot_admin_check(AdminPerms.CAN_CHANGE_INFO)
@user_admin_check(AdminPerms.CAN_CHANGE_INFO)
async def setchatpic(update: Update,
context: CallbackContext) -> str:
async def setchatpic(update: Update, context: CallbackContext) -> str:
bot = context.bot
chat = update.effective_chat
msg = update.effective_message
Expand Down Expand Up @@ -329,8 +327,7 @@ async def set_desc(update: Update, context: CallbackContext) -> str:
@connection_status
@bot_admin_check(AdminPerms.CAN_CHANGE_INFO)
@user_admin_check(AdminPerms.CAN_CHANGE_INFO)
async def setchat_title(update: Update,
context: CallbackContext) -> str:
async def setchat_title(update: Update, context: CallbackContext) -> str:
bot = context.bot
chat = update.effective_chat
msg = update.effective_message
Expand Down Expand Up @@ -425,8 +422,7 @@ async def promote_button(update: Update,

@loggable
@user_admin
async def refresh_admin(update: Update,
context: CallbackContext) -> None:
async def refresh_admin(update: Update, context: CallbackContext) -> None:
with contextlib.suppress(KeyError):
ADMIN_CACHE.pop(update.effective_chat.id)
await update.effective_message.reply_text("Admins cache refreshed!")
Expand Down Expand Up @@ -950,8 +946,7 @@ async def fullpromote(update: Update,
@bot_admin_check(AdminPerms.CAN_PROMOTE_MEMBERS)
@user_admin_check(AdminPerms.CAN_PROMOTE_MEMBERS)
@loggable
async def middemote(update: Update,
context: CallbackContext) -> Optional[str]:
async def middemote(update: Update, context: CallbackContext) -> Optional[str]:
bot = context.bot
args = context.args

Expand Down Expand Up @@ -1031,8 +1026,7 @@ async def middemote(update: Update,
@bot_admin_check(AdminPerms.CAN_PROMOTE_MEMBERS)
@user_admin_check(AdminPerms.CAN_PROMOTE_MEMBERS)
@loggable
async def demote(update: Update,
context: CallbackContext) -> Optional[str]:
async def demote(update: Update, context: CallbackContext) -> Optional[str]:
bot = context.bot
args = context.args

Expand Down Expand Up @@ -1209,8 +1203,7 @@ async def demoteanon(update: Update,


@user_admin
async def refresh_admin(update: Update,
context: CallbackContext) -> None:
async def refresh_admin(update: Update, context: CallbackContext) -> None:
with contextlib.suppress(KeyError):
ADMIN_CACHE.pop(update.effective_chat.id)
await update.effective_message.reply_text("Admins cache refreshed!")
Expand All @@ -1219,8 +1212,7 @@ async def refresh_admin(update: Update,
@bot_admin_check(AdminPerms.CAN_PROMOTE_MEMBERS)
@user_admin_check(AdminPerms.CAN_PROMOTE_MEMBERS)
@loggable
async def set_title(update: Update,
context: CallbackContext) -> None:
async def set_title(update: Update, context: CallbackContext) -> None:
bot = context.bot
args = context.args

Expand Down Expand Up @@ -1584,8 +1576,7 @@ async def permapin(update: Update, context: CallbackContext) -> None:
@connection_status
@bot_admin_check(AdminPerms.CAN_DELETE_MESSAGES)
@user_admin
async def permanent_pin_set(update: Update,
context: CallbackContext) -> str:
async def permanent_pin_set(update: Update, context: CallbackContext) -> str:
u = update.effective_user # type: Optional[User]
chat = update.effective_chat # type: Optional[Chat]
args = context.args
Expand Down Expand Up @@ -1687,8 +1678,7 @@ async def unpinall(update: Update, context: CallbackContext) -> None:
)


async def permanent_pin(update: Update,
context: CallbackContext) -> None:
async def permanent_pin(update: Update, context: CallbackContext) -> None:
user = update.effective_user # type: Optional[User]
chat = update.effective_chat # type: Optional[Chat]
message = update.effective_message
Expand Down Expand Up @@ -1727,8 +1717,7 @@ async def permanent_pin(update: Update,
@bot_admin_check(AdminPerms.CAN_PIN_MESSAGES)
@user_admin_check(AdminPerms.CAN_PIN_MESSAGES)
@loggable
async def unpinallbtn(update: Update,
context: CallbackContext) -> None:
async def unpinallbtn(update: Update, context: CallbackContext) -> None:
chat = update.effective_chat
query = update.callback_query
user = update.effective_user
Expand Down
6 changes: 2 additions & 4 deletions Cutiepii_Robot/modules/antichannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@


@user_admin
async def set_antichannel(update: Update,
context: CallbackContext) -> None:
async def set_antichannel(update: Update, context: CallbackContext) -> None:
message = update.effective_message
chat = update.effective_chat
args = context.args
Expand All @@ -63,8 +62,7 @@ async def set_antichannel(update: Update,
)


async def eliminate_channel(update: Update,
context: CallbackContext) -> None:
async def eliminate_channel(update: Update, context: CallbackContext) -> None:
message = update.effective_message
chat = update.effective_chat
bot = context.bot
Expand Down
9 changes: 3 additions & 6 deletions Cutiepii_Robot/modules/antiflood.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@


@loggable
async def check_flood(update: Update,
context: CallbackContext) -> str:
async def check_flood(update: Update, context: CallbackContext) -> str:
user = update.effective_user # type: Optional[User]
chat = update.effective_chat # type: Optional[Chat]
msg = update.effective_message # type: Optional[Message]
Expand Down Expand Up @@ -125,8 +124,7 @@ async def check_flood(update: Update,

@user_admin_no_reply
@bot_admin
async def flood_button(update: Update,
context: CallbackContext) -> None:
async def flood_button(update: Update, context: CallbackContext) -> None:
bot = context.bot
query = update.callback_query
user = update.effective_user
Expand Down Expand Up @@ -263,8 +261,7 @@ async def flood(update: Update, context: CallbackContext) -> None:


@user_admin
async def set_flood_mode(update: Update,
context: CallbackContext) -> None:
async def set_flood_mode(update: Update, context: CallbackContext) -> None:
chat = update.effective_chat # type: Optional[Chat]
user = update.effective_user # type: Optional[User]
msg = update.effective_message # type: Optional[Message]
Expand Down
3 changes: 1 addition & 2 deletions Cutiepii_Robot/modules/antilinkedchannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ async def eliminate_linked_channel_msg(update: Update):

@bot_admin
@user_admin
async def set_antipinchannel(update: Update,
context: CallbackContext) -> None:
async def set_antipinchannel(update: Update, context: CallbackContext) -> None:
message = update.effective_message
chat = update.effective_chat
args = context.args
Expand Down
3 changes: 1 addition & 2 deletions Cutiepii_Robot/modules/approve.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ async def approve(update: Update, context: CallbackContext) -> None:

@loggable
@user_admin_check(AdminPerms.CAN_CHANGE_INFO)
async def disapprove(update: Update,
context: CallbackContext) -> None:
async def disapprove(update: Update, context: CallbackContext) -> None:
message = update.effective_message
chat_title = message.chat.title
chat = update.effective_chat
Expand Down
6 changes: 2 additions & 4 deletions Cutiepii_Robot/modules/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@


@user_admin
async def import_data(update: Update,
context: CallbackContext) -> None:
async def import_data(update: Update, context: CallbackContext) -> None:
msg = update.effective_message
chat = update.effective_chat
user = update.effective_user
Expand Down Expand Up @@ -149,8 +148,7 @@ async def import_data(update: Update,


@user_admin
async def export_data(update: Update,
context: CallbackContext) -> None:
async def export_data(update: Update, context: CallbackContext) -> None:
chat_data = context.chat_data
msg = update.effective_message # type: Optional[Message]
user = update.effective_user # type: Optional[User]
Expand Down
Loading

0 comments on commit 009b3e5

Please sign in to comment.