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

Commit

Permalink
Merge pull request #190 from AnimeKaizoku/autofix
Browse files Browse the repository at this point in the history
Automated code formatting.
  • Loading branch information
TsunayoshiSawada authored Aug 27, 2020
2 parents cc35fef + f20b3d3 commit b8670ce
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 211 deletions.
14 changes: 9 additions & 5 deletions SaitamaRobot/modules/helper_funcs/msg_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def get_welcome_type(msg: Message):
else:
args = msg.reply_to_message.caption
else:
args = msg.text.split(None, 1) # use python's maxsplit to separate cmd and args
args = msg.text.split(
None, 1) # use python's maxsplit to separate cmd and args
except AttributeError:
args = False

Expand All @@ -111,7 +112,8 @@ def get_welcome_type(msg: Message):
data_type = Types.DOCUMENT

elif msg.reply_to_message and msg.reply_to_message.photo:
content = msg.reply_to_message.photo[-1].file_id # last elem = best quality
content = msg.reply_to_message.photo[
-1].file_id # last elem = best quality
text = msg.reply_to_message.caption
data_type = Types.PHOTO

Expand Down Expand Up @@ -140,13 +142,15 @@ def get_welcome_type(msg: Message):
if args:
if msg.reply_to_message:
argumen = msg.reply_to_message.caption if msg.reply_to_message.caption else ""
offset = 0 # offset is no need since target was in reply
offset = 0 # offset is no need since target was in reply
entities = msg.reply_to_message.parse_entities()
else:
argumen = args[1]
offset = len(argumen) - len(msg.text) # set correct offset relative to command + notename
offset = len(argumen) - len(
msg.text) # set correct offset relative to command + notename
entities = msg.parse_entities()
text, buttons = button_markdown_parser(argumen, entities=entities, offset=offset)
text, buttons = button_markdown_parser(
argumen, entities=entities, offset=offset)

if not data_type:
if text and buttons:
Expand Down
9 changes: 7 additions & 2 deletions SaitamaRobot/modules/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,14 @@ def echo(update: Update, context: CallbackContext):
message = update.effective_message

if message.reply_to_message:
message.reply_to_message.reply_text(args[1], parse_mode="MARKDOWN", disable_web_page_preview=True)
message.reply_to_message.reply_text(
args[1], parse_mode="MARKDOWN", disable_web_page_preview=True)
else:
message.reply_text(args[1], quote=False, parse_mode="MARKDOWN", disable_web_page_preview=True)
message.reply_text(
args[1],
quote=False,
parse_mode="MARKDOWN",
disable_web_page_preview=True)
message.delete()


Expand Down
6 changes: 5 additions & 1 deletion SaitamaRobot/modules/sql/welcome_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,11 @@ def set_gdbye_preference(chat_id, should_goodbye):
SESSION.commit()


def set_custom_welcome(chat_id, custom_content, custom_welcome, welcome_type, buttons=None):
def set_custom_welcome(chat_id,
custom_content,
custom_welcome,
welcome_type,
buttons=None):
if buttons is None:
buttons = []

Expand Down
12 changes: 10 additions & 2 deletions SaitamaRobot/modules/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,22 @@ def broadcast(update: Update, context: CallbackContext):
if to_group:
for chat in chats:
try:
context.bot.sendMessage(int(chat.chat_id), to_send[1], parse_mode="MARKDOWN", disable_web_page_preview=True)
context.bot.sendMessage(
int(chat.chat_id),
to_send[1],
parse_mode="MARKDOWN",
disable_web_page_preview=True)
sleep(0.1)
except TelegramError:
failed += 1
if to_user:
for user in users:
try:
context.bot.sendMessage(int(user.user_id), to_send[1], parse_mode="MARKDOWN", disable_web_page_preview=True)
context.bot.sendMessage(
int(user.user_id),
to_send[1],
parse_mode="MARKDOWN",
disable_web_page_preview=True)
sleep(0.1)
except TelegramError:
failed_user += 1
Expand Down
Loading

0 comments on commit b8670ce

Please sign in to comment.