From 6ddd2333a0c47e8a77922e4a739be78ef03d3741 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 29 Sep 2019 01:11:30 +0300 Subject: [PATCH] Add event ID parameter to karma up/down commands --- karma/bot.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/karma/bot.py b/karma/bot.py index 006970f..7317f6a 100644 --- a/karma/bot.py +++ b/karma/bot.py @@ -69,13 +69,15 @@ class KarmaBot(Plugin): async def karma(self) -> None: pass - @karma.subcommand("up", help="Upvote a message") - def upvote(self, evt: MessageEvent) -> Awaitable[None]: - return self._vote(evt, evt.content.get_reply_to(), +1) + @karma.subcommand("up", help="Upvote an event") + @command.argument("event_id", "Event ID", required=True) + def upvote(self, evt: MessageEvent, event_id: EventID) -> Awaitable[None]: + return self._vote(evt, event_id, +1) @karma.subcommand("down", help="Downvote a message") - def downvote(self, evt: MessageEvent) -> Awaitable[None]: - return self._vote(evt, evt.content.get_reply_to(), -1) + @command.argument("event_id", "Event ID", required=True) + def downvote(self, evt: MessageEvent, event_id: EventID) -> Awaitable[None]: + return self._vote(evt, event_id, -1) @command.passive(UPVOTE) def upvote(self, evt: MessageEvent, _: Tuple[str]) -> Awaitable[None]: