fix default channel, make ping less noisy
This commit is contained in:
parent
7e624d550b
commit
586d14bc69
18
uxnrepl.py
18
uxnrepl.py
|
@ -8,8 +8,8 @@ from sys import argv, stdin, stdout
|
|||
from tempfile import mkdtemp, mkstemp
|
||||
|
||||
server = "irc.libera.chat"
|
||||
nick = b"uxnbot7"
|
||||
channel = b"#uxnbot"
|
||||
nick = b"uxnbot"
|
||||
channel = b"#uxn"
|
||||
|
||||
sandbox = None
|
||||
irc = None
|
||||
|
@ -83,12 +83,18 @@ def repl():
|
|||
stdout.write(execute(s).decode('utf-8'))
|
||||
stdout.flush()
|
||||
|
||||
def send(msg):
|
||||
ping_re = re.compile(br'PING (.+)$')
|
||||
chan_msg_re = re.compile(br':([^!]+)![^ ]+ PRIVMSG ([^ ]+) :' + nick + br': (.*)$')
|
||||
priv_msg_re = re.compile(br':([^!]+)![^ ]+ PRIVMSG ' + nick + br' :(.*)$')
|
||||
|
||||
def send(msg, quiet=False):
|
||||
if not quiet:
|
||||
print('>>> %r' % msg)
|
||||
irc.send(msg + b'\r\n')
|
||||
|
||||
def recv():
|
||||
msg = irc.recv(2040)
|
||||
if not ping_re.match(msg):
|
||||
print('<<< %r' % msg)
|
||||
return msg
|
||||
|
||||
|
@ -111,16 +117,12 @@ def ircbot():
|
|||
#send("PRIVMSG nickserv :iNOOPE\r\n")
|
||||
send(b"JOIN %s" % channel)
|
||||
|
||||
ping_re = re.compile(br'PING (.+)$')
|
||||
chan_msg_re = re.compile(br':([^!]+)![^ ]+ PRIVMSG ([^ ]+) :' + nick + br': (.*)$')
|
||||
priv_msg_re = re.compile(br':([^!]+)![^ ]+ PRIVMSG ' + nick + br' :(.*)$')
|
||||
|
||||
while True:
|
||||
text = recv()
|
||||
|
||||
m = ping_re.match(text)
|
||||
if m:
|
||||
send(b'PONG %s' % m.group(1).strip())
|
||||
send(b'PONG %s' % m.group(1).strip(), quiet=True)
|
||||
continue
|
||||
|
||||
m = chan_msg_re.match(text)
|
||||
|
|
Loading…
Reference in New Issue