From 56344ac1e53f3d99a735ca654a623b50241fcc82 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sven=20M=C3=A4der?= <maeder@phys.ethz.ch>
Date: Sat, 24 Jul 2021 22:05:51 +0200
Subject: [PATCH] Add disown command

---
 maubot.yaml |  2 +-
 rt.py       | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/maubot.yaml b/maubot.yaml
index 1f023cf..5d42085 100644
--- a/maubot.yaml
+++ b/maubot.yaml
@@ -5,7 +5,7 @@ maubot: 0.1.0
 id: ch.ethz.phys.rt
 
 # A PEP 440 compliant version string.
-version: 0.3.2
+version: 0.3.3
 
 # The SPDX license identifier for the plugin. https://spdx.org/licenses/
 # Optional, assumes all rights reserved if omitted.
diff --git a/rt.py b/rt.py
index 4ca64f9..95e16bb 100755
--- a/rt.py
+++ b/rt.py
@@ -363,6 +363,21 @@ class RT(Plugin):
             f'took {self.html_link(number)} 👍️')
         await evt.respond(content)
 
+    @rt.subcommand('disown', aliases=('di', 'dis'), help='Disown a ticket.')
+    @command.argument('number', 'ticket number', parser=str)
+    async def take(self, evt: MessageEvent, number: str) -> None:
+        if not self.can_manage(evt) or not self.valid_number(number):
+            return
+        await evt.mark_read()
+        displayname = await self._displayname(evt.room_id, evt.sender)
+        await self._edit(number, {'Owner': 'Nobody'})
+        content = TextMessageEventContent(
+            msgtype=MessageType.NOTICE, format=Format.HTML,
+            body=f'{displayname} disowned rt#{number} 👎️',
+            formatted_body=f'<a href="https://matrix.to/#/{evt.sender}">{evt.sender}</a> '
+            f'disowned {self.html_link(number)} 👎️')
+        await evt.respond(content)
+
     @rt.subcommand('give', aliases=('g', 'gi', 'assign'), help='Give the ticket to somebody.')
     @command.argument('number', 'ticket number', parser=str)
     @command.argument('user', 'matrix user', parser=str)
-- 
GitLab