$ git clone https://www.wlchat.ion.nu/wlchat.git
commit 8ca7b1f09b31a46268ef362fb17bd75c63750822
Author: Alicia <...>
Date: Sat Aug 23 10:52:46 2025 +0200
Fixed IRC DMs and improved startup when the port is still taken (as tends to happen with restarts)
diff --git a/irc.py b/irc.py
index b07dde4..f0a3621 100755
--- a/irc.py
+++ b/irc.py
@@ -20,6 +20,7 @@ import socket
import threading
import sys
import json
+import time
port=3333
pcolors=[ # Pronoun color associations
'00', # 1-indexed, so pad 0
@@ -61,7 +62,7 @@ def irc_msg(c, chan, nick, data):
c['irc'].send(bytes(':'+data['nick']+'!user@host PRIVMSG #'+chan+' :'+data['data']+'\n', 'utf-8'))
def irc_privmsg(c, chan, nick, data):
- c['irc'].send(bytes(':'+chan+'|'+data['nick']+'!user@host PRIVMSG '+nick+' :'+data['data']+'\n', 'utf-8'))
+ c['irc'].send(bytes(':'+data['nick']+'!user@host PRIVMSG '+nick+' :'+data['data']+'\n', 'utf-8'))
def irc_broadcast(c, chan, nick, data):
c['irc'].send(bytes(':wlchat NOTICE #'+chan+' :Broadcast: '+data['data']+'\n', 'utf-8'))
@@ -213,7 +214,13 @@ interface={
# Set up server-based interface
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-s.bind(('127.0.0.1', port))
+while(True):
+ try:
+ s.bind(('127.0.0.1', port))
+ except Exception:
+ time.sleep(10)
+ continue
+ break
s.listen()
print('Listening to localhost:'+str(port))
while(True):