-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored main branch #6
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,7 @@ | |
if not hasattr(imported_module, "__mod_name__"): | ||
imported_module.__mod_name__ = imported_module.__name__ | ||
|
||
if not imported_module.__mod_name__.lower() in IMPORTED: | ||
if imported_module.__mod_name__.lower() not in IMPORTED: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
IMPORTED[imported_module.__mod_name__.lower()] = imported_module | ||
else: | ||
raise Exception("Can't have two modules with the same name! Please change one") | ||
|
@@ -121,7 +121,7 @@ def test(bot: Bot, update: Update): | |
@run_async | ||
def start(bot: Bot, update: Update, args: List[str]): | ||
if update.effective_chat.type == "private": | ||
if len(args) >= 1: | ||
if args: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
if args[0].lower() == "help": | ||
send_help(update.effective_chat.id, HELP_STRINGS) | ||
elif args[0].lower() == "disasters": | ||
|
@@ -235,13 +235,11 @@ def help_button(bot: Bot, update: Update): | |
bot.answer_callback_query(query.id) | ||
query.message.delete() | ||
except BadRequest as excp: | ||
if excp.message == "Message is not modified": | ||
pass | ||
elif excp.message == "Query_id_invalid": | ||
pass | ||
elif excp.message == "Message can't be deleted": | ||
pass | ||
else: | ||
if excp.message not in [ | ||
"Message is not modified", | ||
"Query_id_invalid", | ||
"Message can't be deleted", | ||
]: | ||
Comment on lines
-238
to
+242
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
LOGGER.exception("Exception in help buttons. %s", str(query.data)) | ||
|
||
|
||
|
@@ -332,8 +330,6 @@ def imdb(bot: Bot, update: Update, args): | |
'Which one? ', | ||
reply_markup = reply_markup | ||
) | ||
else: | ||
pass | ||
Comment on lines
-335
to
-336
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def send_settings(chat_id, user_id, user=False): | ||
|
@@ -348,18 +344,17 @@ def send_settings(chat_id, user_id, user=False): | |
dispatcher.bot.send_message(user_id, "Seems like there aren't any user specific settings available :'(", | ||
parse_mode=ParseMode.MARKDOWN) | ||
|
||
elif CHAT_SETTINGS: | ||
chat_name = dispatcher.bot.getChat(chat_id).title | ||
dispatcher.bot.send_message(user_id, | ||
text="Which module would you like to check {}'s settings for?".format( | ||
chat_name), | ||
reply_markup=InlineKeyboardMarkup( | ||
paginate_modules(0, CHAT_SETTINGS, "stngs", chat=chat_id))) | ||
else: | ||
if CHAT_SETTINGS: | ||
chat_name = dispatcher.bot.getChat(chat_id).title | ||
dispatcher.bot.send_message(user_id, | ||
text="Which module would you like to check {}'s settings for?".format( | ||
chat_name), | ||
reply_markup=InlineKeyboardMarkup( | ||
paginate_modules(0, CHAT_SETTINGS, "stngs", chat=chat_id))) | ||
else: | ||
dispatcher.bot.send_message(user_id, "Seems like there aren't any chat settings available :'(\nSend this " | ||
"in a group chat you're admin in to find its current settings!", | ||
parse_mode=ParseMode.MARKDOWN) | ||
dispatcher.bot.send_message(user_id, "Seems like there aren't any chat settings available :'(\nSend this " | ||
"in a group chat you're admin in to find its current settings!", | ||
parse_mode=ParseMode.MARKDOWN) | ||
Comment on lines
+347
to
+357
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
@run_async | ||
|
@@ -417,13 +412,11 @@ def settings_button(bot: Bot, update: Update): | |
bot.answer_callback_query(query.id) | ||
query.message.delete() | ||
except BadRequest as excp: | ||
if excp.message == "Message is not modified": | ||
pass | ||
elif excp.message == "Query_id_invalid": | ||
pass | ||
elif excp.message == "Message can't be deleted": | ||
pass | ||
else: | ||
if excp.message not in [ | ||
"Message is not modified", | ||
"Query_id_invalid", | ||
"Message can't be deleted", | ||
]: | ||
Comment on lines
-420
to
+419
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
LOGGER.exception("Exception in settings buttons. %s", str(query.data)) | ||
|
||
|
||
|
@@ -435,19 +428,18 @@ def get_settings(bot: Bot, update: Update): | |
args = msg.text.split(None, 1) | ||
|
||
# ONLY send settings in PM | ||
if chat.type != chat.PRIVATE: | ||
if is_user_admin(chat, user.id): | ||
text = "Click here to get this chat's settings, as well as yours." | ||
msg.reply_text(text, | ||
reply_markup=InlineKeyboardMarkup( | ||
[[InlineKeyboardButton(text="Settings", | ||
url="t.me/{}?start=stngs_{}".format( | ||
bot.username, chat.id))]])) | ||
else: | ||
text = "Click here to check your settings." | ||
if chat.type == chat.PRIVATE: | ||
send_settings(chat.id, user.id, True) | ||
|
||
elif is_user_admin(chat, user.id): | ||
text = "Click here to get this chat's settings, as well as yours." | ||
msg.reply_text(text, | ||
reply_markup=InlineKeyboardMarkup( | ||
[[InlineKeyboardButton(text="Settings", | ||
url="t.me/{}?start=stngs_{}".format( | ||
bot.username, chat.id))]])) | ||
else: | ||
send_settings(chat.id, user.id, True) | ||
text = "Click here to check your settings." | ||
Comment on lines
-438
to
+442
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines
29-148
refactored with the following changes:collection-builtin-to-comprehension
)