Add command to force set a Matrix power level without affecting Telegram. Fixes #60
This commit is contained in:
@@ -57,7 +57,8 @@ def help(evt):
|
|||||||
#### Miscellaneous things
|
#### Miscellaneous things
|
||||||
**search** [_-r|--remote_] <_query_> - Search your contacts or the Telegram servers for users.
|
**search** [_-r|--remote_] <_query_> - Search your contacts or the Telegram servers for users.
|
||||||
**sync** [`chats`|`contacts`|`me`] - Synchronize your chat portals, contacts and/or own info.
|
**sync** [`chats`|`contacts`|`me`] - Synchronize your chat portals, contacts and/or own info.
|
||||||
**ping-bot** - Get info of the message relay Telegram bot.
|
**ping-bot** - Get info of the message relay Telegram bot.
|
||||||
|
**set-pl** <_level_> - Set a temporary power level without affecting Telegram.
|
||||||
|
|
||||||
#### Initiating chats
|
#### Initiating chats
|
||||||
**pm** <_identifier_> - Open a private chat with the given Telegram user. The identifier is either
|
**pm** <_identifier_> - Open a private chat with the given Telegram user. The identifier is either
|
||||||
@@ -72,10 +73,10 @@ def help(evt):
|
|||||||
**delete-portal** - Remove all users from the current portal room and forget the portal.
|
**delete-portal** - Remove all users from the current portal room and forget the portal.
|
||||||
Only works for group chats; to delete a private chat portal, simply
|
Only works for group chats; to delete a private chat portal, simply
|
||||||
leave the room.
|
leave the room.
|
||||||
**unbridge** - Remove puppets from the current portal room and forget the portal.
|
**unbridge** - Remove puppets from the current portal room and forget the portal.
|
||||||
**bridge** [_id_] - Bridge the current Matrix room to the Telegram chat with the given
|
**bridge** [_id_] - Bridge the current Matrix room to the Telegram chat with the given
|
||||||
ID. The ID must be the prefixed version that you get with the `/id`
|
ID. The ID must be the prefixed version that you get with the `/id`
|
||||||
command of the Telegram-side bot.
|
command of the Telegram-side bot.
|
||||||
**group-name** <_name_|`-`> - Change the username of a supergroup/channel. To disable, use a dash
|
**group-name** <_name_|`-`> - Change the username of a supergroup/channel. To disable, use a dash
|
||||||
(`-`) as the name.
|
(`-`) as the name.
|
||||||
**clean-rooms** - Clean up unused portal/management rooms.
|
**clean-rooms** - Clean up unused portal/management rooms.
|
||||||
|
|||||||
@@ -23,6 +23,23 @@ from .. import portal as po
|
|||||||
from . import command_handler, CommandEvent
|
from . import command_handler, CommandEvent
|
||||||
|
|
||||||
|
|
||||||
|
@command_handler(needs_admin=True, needs_auth=False, name="set-pl")
|
||||||
|
async def set_power_level(evt: CommandEvent):
|
||||||
|
try:
|
||||||
|
level = int(evt.args[0])
|
||||||
|
except KeyError:
|
||||||
|
return await evt.reply("**Usage:** `$cmdprefix+sp set-power <level>`")
|
||||||
|
except ValueError:
|
||||||
|
return await evt.reply("The level must be an integer.")
|
||||||
|
levels = await evt.az.intent.get_power_levels(evt.room_id)
|
||||||
|
levels["users"][evt.sender.mxid] = level
|
||||||
|
try:
|
||||||
|
await evt.az.intent.set_power_levels(evt.room_id, levels)
|
||||||
|
except MatrixRequestError:
|
||||||
|
evt.log.exception("Failed to set power level.")
|
||||||
|
return await evt.reply("Failed to set power level.")
|
||||||
|
|
||||||
|
|
||||||
@command_handler()
|
@command_handler()
|
||||||
async def invite_link(evt: CommandEvent):
|
async def invite_link(evt: CommandEvent):
|
||||||
portal = po.Portal.get_by_mxid(evt.room_id)
|
portal = po.Portal.get_by_mxid(evt.room_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user