Show current template if ran without arguments

This commit is contained in:
Tulir Asokan 2023-02-21 12:43:32 +02:00
parent f12d32ad3c
commit 1a52d18f59

View File

@ -21,6 +21,7 @@ from string import Template
from time import mktime, time
import asyncio
import hashlib
import html
import aiohttp
import attr
@ -392,7 +393,7 @@ class RSSBot(Plugin):
help="Change the notification template for a subscription in this room",
)
@command.argument("feed_id", "feed ID", parser=int)
@command.argument("template", "new template", pass_raw=True)
@command.argument("template", "new template", pass_raw=True, required=False)
async def command_template(self, evt: MessageEvent, feed_id: int, template: str) -> None:
if not await self.can_manage(evt):
return
@ -400,6 +401,13 @@ class RSSBot(Plugin):
if not sub:
await evt.reply("This room is not subscribed to that feed")
return
if not template:
await evt.reply(
'<p>Current template in this room:</p><pre><code language="markdown">'
f"{html.escape(sub.notification_template.template)}"
"</code></pre>", allow_html=True, markdown=False,
)
return
await self.dbm.update_template(feed.id, evt.room_id, template)
sub = Subscription(
feed_id=feed.id,