Add option to bridge notices and command to get relaybot info
This commit is contained in:
@@ -32,6 +32,21 @@ async def ping(evt):
|
||||
return await evt.reply("You're not logged in.")
|
||||
|
||||
|
||||
@command_handler()
|
||||
async def ping_bot(evt):
|
||||
if not evt.tgbot:
|
||||
return await evt.reply("Telegram message relay bot not configured.")
|
||||
bot_info = await evt.tgbot.client.get_me()
|
||||
localpart = evt.config.get("bridge.username_template", "telegram_{userid}").format(
|
||||
userid=bot_info.id)
|
||||
hs = evt.config["homeserver"]["domain"]
|
||||
mxid = f"@{localpart}:{hs}"
|
||||
displayname = bot_info.first_name
|
||||
return await evt.reply(f"Telegram message relay bot is active: "
|
||||
+ f"[{displayname}](https://matrix.to/#/{mxid}) (ID {bot_info.id})\n\n"
|
||||
+ f"To use the bot, simply invite it to a portal room.")
|
||||
|
||||
|
||||
@command_handler(needs_auth=False, management_only=True)
|
||||
def register(evt):
|
||||
return evt.reply("Not yet implemented.")
|
||||
|
||||
@@ -45,6 +45,8 @@ class CommandEvent:
|
||||
self.az = handler.az
|
||||
self.log = handler.log
|
||||
self.loop = handler.loop
|
||||
self.tgbot = handler.tgbot
|
||||
self.config = handler.config
|
||||
self.command_prefix = handler.command_prefix
|
||||
self.room_id = room
|
||||
self.sender = sender
|
||||
@@ -87,7 +89,7 @@ class CommandHandler:
|
||||
log = logging.getLogger("mau.commands")
|
||||
|
||||
def __init__(self, context):
|
||||
self.az, self.db, self.config, self.loop, _ = context
|
||||
self.az, self.db, self.config, self.loop, self.tgbot = context
|
||||
self.command_prefix = self.config["bridge.command_prefix"]
|
||||
|
||||
# region Utility functions for handling commands
|
||||
|
||||
@@ -65,6 +65,7 @@ def help(evt):
|
||||
`channel` (defaults to `group`).
|
||||
|
||||
#### Portal management
|
||||
**ping-bot** - Get info of the message relay Telegram bot.
|
||||
**upgrade** - Upgrade a normal Telegram group to a supergroup.
|
||||
**invite-link** - Get a Telegram invite link to the current chat.
|
||||
**delete-portal** - Forget the current portal room. Only works for group chats; to delete
|
||||
|
||||
Reference in New Issue
Block a user