[TASK] Add Quit message.
This commit is contained in:
parent
35f358cccf
commit
1c99d74f02
|
@ -288,3 +288,15 @@ class Topic(Message, metaclass=register_derivative):
|
|||
self.source = self.get("nick")
|
||||
self.channel = self.get("params")[0]
|
||||
self.topic = self.get("trailing")
|
||||
|
||||
class Quit(Message, metaclass=register_derivative):
|
||||
def __init__(self, message="QUIT", *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if "data" not in kwargs:
|
||||
self.update({
|
||||
"command": "QUIT",
|
||||
"trailing": message
|
||||
})
|
||||
def parse(self):
|
||||
self.nick = self.get("nick")
|
||||
self.message = self.get("trailing")
|
||||
|
|
|
@ -156,4 +156,17 @@ class Message(unittest.TestCase):
|
|||
|
||||
def test_construct_topic(self):
|
||||
msg = irc.Topic(channel="#politics", topic="Yes, we can!")
|
||||
self.assertEqual(str(msg), "TOPIC #politics :Yes, we can!")
|
||||
self.assertEqual(str(msg), "TOPIC #politics :Yes, we can!")
|
||||
|
||||
|
||||
def test_parse_quit(self):
|
||||
raw = ":worker!~frustrated@company.com QUIT :This is it!"
|
||||
msg = irc.Message.from_string(raw)
|
||||
self.assertIsInstance(msg, irc.Quit, msg="Not a Quit!")
|
||||
self.assertEqual(msg.nick, "worker")
|
||||
self.assertEqual(msg.message, "This is it!")
|
||||
|
||||
def test_construct_quit(self):
|
||||
msg = irc.Quit(message="Good bye!")
|
||||
self.assertEqual(str(msg), "QUIT :Good bye!")
|
||||
|
||||
|
|
Loading…
Reference in New Issue