-
Notifications
You must be signed in to change notification settings - Fork 0
/
message.py
29 lines (24 loc) · 832 Bytes
/
message.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Message class for ;; bot."""
class Message:
"""Define a message to send."""
PLAIN = 0 # text
LINE = 1 # `text`
BLOCK = 2 # ```text```
def __init__(self, text, style=LINE, private=False, tts=False, channel=None):
"""Initialize Message."""
self.text = str(text)
if style == self.LINE:
self.text = '`' + self.text + '`'
elif style == self.BLOCK:
self.text = '```\n' + self.text + '```'
self.private = private
self.tts = tts
self.channel = channel
def get_channel(self, author, channel):
"""Return destination channel."""
if self.private:
return author
elif self.channel is not None:
return self.channel
else:
return channel