built-with-matrix-nio badge + permit aliases (#15)
* added built-with-matrix-nio badge to README * permit aliases - using room.is_group is not ideal to determine if a room is a DM - if a room alias is created for a DM, the existing code will break - changing to check for room.member_count seems to be more appropriate - new code also works on DMs that have aliases * moving badge next to existing badge * Update my_project_name/callbacks.py Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
This commit is contained in:
parent
98e1262b16
commit
8c0ec5f759
2 changed files with 7 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
||||||
# Nio Template <a href="https://matrix.to/#/#nio-template:matrix.org"><img src="https://img.shields.io/matrix/nio-template:matrix.org?color=blue&label=Join%20the%20Matrix%20Room&server_fqdn=matrix-client.matrix.org" /></a>
|
# Nio Template [![Built with matrix-nio](https://img.shields.io/badge/built%20with-matrix--nio-brightgreen)](https://github.com/poljar/matrix-nio) <a href="https://matrix.to/#/#nio-template:matrix.org"><img src="https://img.shields.io/matrix/nio-template:matrix.org?color=blue&label=Join%20the%20Matrix%20Room&server_fqdn=matrix-client.matrix.org" /></a>
|
||||||
|
|
||||||
A template for creating bots with
|
A template for creating bots with
|
||||||
[matrix-nio](https://github.com/poljar/matrix-nio). The documentation for
|
[matrix-nio](https://github.com/poljar/matrix-nio). The documentation for
|
||||||
|
|
|
@ -46,7 +46,12 @@ class Callbacks(object):
|
||||||
|
|
||||||
# Process as message if in a public room without command prefix
|
# Process as message if in a public room without command prefix
|
||||||
has_command_prefix = msg.startswith(self.command_prefix)
|
has_command_prefix = msg.startswith(self.command_prefix)
|
||||||
if not has_command_prefix and not room.is_group:
|
|
||||||
|
# room.is_group is often a DM, but not always.
|
||||||
|
# room.is_group does not allow room aliases
|
||||||
|
# room.member_count > 2 ... we assume a public room
|
||||||
|
# room.member_count <= 2 ... we assume a DM
|
||||||
|
if not has_command_prefix and room.member_count > 2:
|
||||||
# General message listener
|
# General message listener
|
||||||
message = Message(self.client, self.store, self.config, msg, room, event)
|
message = Message(self.client, self.store, self.config, msg, room, event)
|
||||||
await message.process()
|
await message.process()
|
||||||
|
|
Loading…
Reference in a new issue