Commit 88057810 authored by Kasalehlia's avatar Kasalehlia

irc: refine output, respond to PING

parent 40d64208
......@@ -10,7 +10,7 @@ NICK = 'infodisplay'
CHANNEL = '#stratum0'
def _clean_str(s):
return s.replace('<','&lt;').replace('>','&gt;')
return s.rstrip().replace('<','&lt;').replace('>','&gt;')
def run(emit, log_err):
emit('<h3>&nbsp;IRC #stratum0</h3><div class="chat" data-infodisplay-outlet="inner"></div>')
......@@ -28,12 +28,21 @@ def run(emit, log_err):
try:
while 1:
line = fp.readline().decode()
print(line)
if line[:4] == 'PING':
conn.write(line.replace(b'PING',b'PONG', 1))
continue
source, command, args = line.split(' ', 2)
if command == 'PRIVMSG' and 'znc@znc.in' not in source:
channel, message = args.split(' :', 1)
sender = source.split('!', 1)[0][1:]
message = message.strip()
if channel == CHANNEL:
out = '<p><span>{}</span> {}</p>'.format(sender, _clean_str(message))
if message[:7] == '\x01ACTION':
message = message.replace('ACTION ', '', 1)
out = '<p><span class="nobraces">{}</span> {}</p>'.format(sender, _clean_str(message))
else:
out = '<p><span>{}</span> {}</p>'.format(sender, _clean_str(message))
cache.append(out)
if len(cache) > CACHE_LIMIT:
cache.pop(0)
......
......@@ -43,11 +43,11 @@ h3 {
#irc p span {
color: #268bd2;
}
#irc p span::before {
#irc p span:not(.nobraces)::before {
content: "<";
color: #839496;
}
#irc p span:after {
#irc p span:not(.nobraces):after {
content: ">";
color: #839496;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment