2020-01-17 14:20:42 +00:00
|
|
|
from src import ModuleManager, utils
|
|
|
|
|
2020-01-17 14:45:33 +00:00
|
|
|
CAP = utils.irc.Capability(None, "draft/edit", alias="edit")
|
2020-01-17 14:20:42 +00:00
|
|
|
DELETE_TAG = utils.irc.MessageTag(None, "draft/delete")
|
|
|
|
|
2020-01-17 14:45:33 +00:00
|
|
|
@utils.export("cap", CAP)
|
2020-01-17 14:20:42 +00:00
|
|
|
class Module(ModuleManager.BaseModule):
|
2020-01-17 16:28:48 +00:00
|
|
|
def _tagmsg(self, event, channel):
|
2020-01-17 14:20:42 +00:00
|
|
|
msgid = DELETE_TAG.get_value(event["line"].tags)
|
|
|
|
if msgid:
|
|
|
|
line = event["target"].buffer.find_id(msgid)
|
|
|
|
if line:
|
|
|
|
line.deleted = True
|
2020-01-17 16:28:48 +00:00
|
|
|
|
2020-01-30 21:12:31 +00:00
|
|
|
timestamp = utils.datetime.format.datetime_human(line.timestamp,
|
2020-01-20 13:25:53 +00:00
|
|
|
timespec=utils.datetime.TimeSpec.MILLISECOND)
|
2020-01-20 13:26:39 +00:00
|
|
|
minimal = "{~NICK} deleted line from %s (%s)" % (
|
2020-01-17 16:28:48 +00:00
|
|
|
timestamp, line.message)
|
|
|
|
line = "- %s" % minimal
|
|
|
|
|
|
|
|
self.exports.get_one("format")("delete", event["server"], line,
|
|
|
|
event["target_str"], minimal=minimal, channel=channel,
|
|
|
|
user=event["user"])
|
|
|
|
|
|
|
|
@utils.hook("received.tagmsg.private")
|
|
|
|
def private(self, event):
|
|
|
|
self._tagmsg(event, None)
|
|
|
|
@utils.hook("received.tagmsg.channel")
|
|
|
|
def channel(self, event):
|
|
|
|
self._tagmsg(event, event["target"])
|