add roomid command and fix workflow file

This commit is contained in:
William Kray
2024-08-15 20:23:55 -07:00
parent 9d61733ac8
commit 72277818f1
4 changed files with 30 additions and 2 deletions
+1 -1
View File
@@ -26,4 +26,4 @@ jobs:
with:
files: |
*.mbp
LICENSE
LICENSE*
+7
View File
@@ -53,6 +53,13 @@ will attempt to sanitize the room name and assign a room alias automatically. th
power level (1000) and set an admin power level (100) to plugin administrators. this ensures that the bot is still able
to manage room admins. the bot will also invite other users to these new rooms as configured.
## get room ID
sometimes you need to know a rooms identifier, but if the room has an alias associated with it not all clients make it
easy (or possible) to find. this subcommand (`!community roomid`) can be used to return the room id that a room alias
points to. with no argument passed, it will return the current room's ID, or you can pass it an alias (e.g. `!community
roomid #whatisthisroom:myserver.tld`).
# installation
install this like any other maubot plugin: zip the contents of this repo into a file and upload via the web interface,
+21
View File
@@ -488,6 +488,27 @@ class CommunityBot(Plugin):
except Exception as e:
await evt.respond(f"something went wrong: {e}")
@community.subcommand("roomid", help="return the matrix room ID of this, or a given, room")
@command.argument("room", required=False)
async def get_roomid(self, evt: MessageEvent, room: str) -> None:
room_id = None
if room:
if room.startswith('#'):
try:
thatroom_id = await self.client.resolve_room_alias(room)
room_id = thatroom_id["room_id"]
except:
evt.reply("i don't recognize that room, sorry")
return
else:
room_id = room
else:
room_id = evt.room_id
try:
await evt.reply(f"Room ID is: {room_id}")
except Exception as e:
await evt.respond(f"something went wrong: {e}")
@classmethod
def get_db_upgrade_table(cls) -> None:
+1 -1
View File
@@ -1,6 +1,6 @@
maubot: 0.1.0
id: org.jobmachine.communitybot
version: 0.1.0
version: 0.1.1
license: MIT
modules:
- community