Skip to content

Commit

Permalink
Merge pull request #676 from justinbot/justinbot/welcome-text-config
Browse files Browse the repository at this point in the history
Add example config for custom welcome messages
  • Loading branch information
sumnerevans authored Oct 26, 2021
2 parents e7d8948 + 8aecf1f commit 7c5d1c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
15 changes: 15 additions & 0 deletions mautrix_telegram/example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,21 @@ bridge:
# The prefix for commands. Only required in non-management rooms.
command_prefix: "!tg"

# Messages sent upon joining a management room.
# Markdown is supported. The defaults are listed below.
management_room_text:
# Sent when joining a room.
welcome: "Hello, I'm a Telegram bridge bot."
# Sent when joining a management room and the user is already logged in.
welcome_connected: "Use `help` for help."
# Sent when joining a management room and the user is not logged in.
welcome_unconnected: "Use `help` for help or `login` to log in."
# Optional extra text sent when joining a management room.
additional_help: ""

# Send each message separately (for readability in some clients)
management_room_multiple_messages: false

# Permissions for using the bridge.
# Permitted values:
# relaybot - Only use the bridge via the relaybot, no access to commands.
Expand Down
17 changes: 0 additions & 17 deletions mautrix_telegram/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,6 @@ async def handle_puppet_invite(self, room_id: RoomID, puppet: pu.Puppet, inviter
await intent.send_notice(room_id, "This puppet will remain inactive until a "
"Telegram chat is created for this room.")

async def send_welcome_message(self, room_id: RoomID, inviter: 'u.User') -> None:
try:
is_management = len(await self.az.intent.get_room_members(room_id)) == 2
except MatrixError:
# The AS bot is not in the room.
return
cmd_prefix = self.commands.command_prefix
text = html = "Hello, I'm a Telegram bridge bot. "
if is_management and inviter.puppet_whitelisted and not await inviter.is_logged_in():
text += f"Use `{cmd_prefix} help` for help or `{cmd_prefix} login` to log in."
html += (f"Use <code>{cmd_prefix} help</code> for help"
f" or <code>{cmd_prefix} login</code> to log in.")
else:
text += f"Use `{cmd_prefix} help` for help."
html += f"Use <code>{cmd_prefix} help</code> for help."
await self.az.intent.send_notice(room_id, text=text, html=html)

async def handle_invite(self, room_id: RoomID, user_id: UserID, inviter: 'u.User',
event_id: EventID) -> None:
user = u.User.get_by_mxid(user_id, create=False)
Expand Down

0 comments on commit 7c5d1c2

Please sign in to comment.