-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutputHandler.py
More file actions
26 lines (21 loc) · 851 Bytes
/
OutputHandler.py
File metadata and controls
26 lines (21 loc) · 851 Bytes
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
import MessageHandler
import time
import datetime
import unicodedata
class OutputHandler(MessageHandler.MessageHandler):
def __init_():
super().__init__()
def update(self, data):
if data[1] == 'WHISPER':
nick = data[0].split('!', 1)[0]
timestamp = time.time()
timestamp = datetime.datetime.fromtimestamp(timestamp).strftime('%H:%M:%S')
print('[' + timestamp + '] ', end='') #timestamp
try:
print(data[2][0] + ' ', end='') #channel
print(nick + ': ', end='') #nick
print(data[2][1], end='') #message
except UnicodeEncodeError:
print(unicodedata.normalize('NFKD', data[2][0]).encode('ascii', 'ignore'), end='')
print(unicodedata.normalize('NFKD', nick + ': ').encode('ascii', 'ignore'), end='')
print(unicodedata.normalize('NFKD', data[2][1] + '\r\n').encode('ascii', 'ignore'), end='')