Add ability to query a single homeserver.
This commit is contained in:
parent
d6b1062fe8
commit
f5933792eb
|
@ -3,3 +3,4 @@ A simple [maubot](https://github.com/maubot/maubot) that displays everyone's hom
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
* `!shame` - Reply with a list of homeservers and their respective running versions.
|
* `!shame` - Reply with a list of homeservers and their respective running versions.
|
||||||
|
* `!shame server.example.com` - Reply with the version for the homeserver provided, server.example.com.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
maubot: 0.1.0
|
maubot: 0.1.0
|
||||||
id: sh.wallace.matrix.shameotron
|
id: sh.wallace.matrix.shameotron
|
||||||
version: 0.0.2
|
version: 0.0.3
|
||||||
license: MIT
|
license: MIT
|
||||||
modules:
|
modules:
|
||||||
- shameotron
|
- shameotron
|
||||||
|
|
|
@ -99,28 +99,32 @@ class ShameOTron(Plugin):
|
||||||
|
|
||||||
|
|
||||||
@command.new('shame', help='Show versions of all homeservers in the room')
|
@command.new('shame', help='Show versions of all homeservers in the room')
|
||||||
async def shame_handler(self, evt: MessageEvent) -> None:
|
@command.argument("candidate", pass_raw=True, required=False)
|
||||||
|
async def shame_handler(self, evt: MessageEvent, candidate: str = None) -> None:
|
||||||
"""
|
"""
|
||||||
Class method to handle the `!shame` command
|
Class method to handle the `!shame` command
|
||||||
"""
|
"""
|
||||||
event_id = await evt.reply('Loading member list...')
|
event_id = await evt.reply('Loading member list...')
|
||||||
member_servers = await self._load_members(evt.room_id)
|
if candidate:
|
||||||
|
member_servers = [candidate]
|
||||||
|
else:
|
||||||
|
member_servers = await self._load_members(evt.room_id)
|
||||||
|
|
||||||
# Filter out the "dead servers"
|
# Filter out the "dead servers"
|
||||||
dead_servers = self.config['dead_servers']
|
dead_servers = self.config['dead_servers']
|
||||||
if dead_servers:
|
if dead_servers:
|
||||||
# Return a unique list
|
# Return a unique list
|
||||||
member_servers = sorted(
|
member_servers = sorted(
|
||||||
list(
|
list(
|
||||||
set(member_servers.keys() - set(dead_servers))
|
set(member_servers.keys() - set(dead_servers))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
await self._edit(
|
await self._edit(
|
||||||
evt.room_id,
|
evt.room_id,
|
||||||
event_id,
|
event_id,
|
||||||
'Member list loaded, fetching versions... please wait...'
|
'Member list loaded, fetching versions... please wait...'
|
||||||
)
|
)
|
||||||
|
|
||||||
versions = []
|
versions = []
|
||||||
for host in member_servers:
|
for host in member_servers:
|
||||||
|
|
Loading…
Reference in a new issue