Skip to content

Commit

Permalink
Merge pull request #156 from F33RNI/next
Browse files Browse the repository at this point in the history
Auto-split /users and /broadcast result message
  • Loading branch information
F33RNI authored Apr 5, 2024
2 parents d0f2295 + 95066b8 commit 2793e7a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion _version.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from packaging import version

__version__ = "5.2.6"
__version__ = "5.2.8"


def version_major() -> int:
Expand Down
31 changes: 22 additions & 9 deletions bot_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1240,13 +1240,18 @@ async def bot_command_broadcast(self, update: Update, context: ContextTypes.DEFA
except Exception as e:
logging.warning(f"Error sending message to {broadcast_user_id}", exc_info=e)

# Send final message with list of users
await _send_safe(
user_id,
self.messages.get_message("broadcast_done", lang_id=lang_id).format(
broadcast_ok_users="\n".join(broadcast_ok_users)
),
context,
# Send list of users with auto-splitting
message = self.messages.get_message("broadcast_done", lang_id=lang_id).format(
broadcast_ok_users="\n".join(broadcast_ok_users)
)
request_response = request_response_container.RequestResponseContainer(
user_id=user_id,
reply_message_id=update.effective_message.id,
module_name="",
response_text=message,
)
await bot_sender.send_message_async(
self.config.get("telegram"), self.messages, request_response, end=True, plain_text=True
)

async def bot_command_module(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
Expand Down Expand Up @@ -1515,8 +1520,16 @@ async def bot_command_users(self, update: Update, context: ContextTypes.DEFAULT_
admins_num=users_admin_counter,
)

# Send as markdown
await bot_sender.send_reply(self.config.get("telegram").get("api_key"), user_id, message, markdown=True)
# Send message with auto-splitting
request_response = request_response_container.RequestResponseContainer(
user_id=user_id,
reply_message_id=update.effective_message.id,
module_name="",
response_text=message,
)
await bot_sender.send_message_async(
self.config.get("telegram"), self.messages, request_response, end=True, plain_text=True
)

async def bot_command_chatid(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
"""/chatid command callback
Expand Down

0 comments on commit 2793e7a

Please sign in to comment.