Skip to content

Commit

Permalink
Show current template if ran without arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Feb 21, 2023
1 parent f12d32a commit 1a52d18
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rss/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from time import mktime, time
import asyncio
import hashlib
import html

import aiohttp
import attr
Expand Down Expand Up @@ -392,14 +393,21 @@ async def unsubscribe(self, evt: MessageEvent, feed_id: int) -> None:
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
sub, feed = await self.dbm.get_subscription(feed_id, evt.room_id)
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,
Expand Down

0 comments on commit 1a52d18

Please sign in to comment.