2 Commits

Author SHA1 Message Date
Tulir Asokan
9a6e06cc29 Bump version to 1.2.0 2019-04-14 02:16:20 +03:00
Tulir Asokan
37df8c89d6 Use mention and event link instead of reply for pongs 2019-04-14 02:12:04 +03:00
2 changed files with 10 additions and 6 deletions

14
echo.py
View File

@@ -1,7 +1,7 @@
from typing import Optional
from time import time
from mautrix.types import TextMessageEventContent, MessageType
from mautrix.types import TextMessageEventContent, MessageType, Format
from maubot import Plugin, MessageEvent
from maubot.handlers import command
@@ -36,15 +36,19 @@ class EchoBot(Plugin):
@command.new("ping", help="Ping")
async def ping_handler(self, evt: MessageEvent) -> None:
diff = int(time() * 1000) - evt.timestamp
content = TextMessageEventContent(msgtype=MessageType.NOTICE,
body="Pong! (ping took "
f"{self.prettify_diff(diff)} to arrive)")
pretty_diff = self.prettify_diff(diff)
content = TextMessageEventContent(
msgtype=MessageType.NOTICE, format=Format.HTML,
body=f"{evt.sender}: Pong! (ping took {pretty_diff} to arrive)",
formatted_body=f"<a href='https://matrix.to/#/{evt.sender}'>{evt.sender}</a>: Pong! "
f"(<a href='https://matrix.to/#/{evt.room_id}/{evt.event_id}'>ping</a> took "
f"{pretty_diff} to arrive)")
content["pong"] = {
"ms": diff,
"from": evt.sender.split(":", 1)[1],
"ping": evt.event_id,
}
await evt.reply(content)
await evt.respond(content)
@command.new("echo", help="Repeat a message")
@command.argument("message", pass_raw=True)

View File

@@ -1,6 +1,6 @@
maubot: 0.1.0
id: xyz.maubot.echo
version: 1.1.1
version: 1.2.0
license: MIT
modules:
- echo