I have an issue with my Irc chat and im following a tutorial it was working fine until a couple days ago but now it gets stuck in an infinite loop please help me since I’m new to coding. any help is appreciated!
import socket
import pyautogui
SERVER = "irc.twitch.tv"
PORT = 6667
PASS = "oauth:placeholder"
BOT = "epic"
CHANNEL = "yamps_"
OWNER = "yamps_"
irc = socket.socket()
irc.connect((SERVER, PORT))
irc.send(("PASS " + PASS + "\n" +
"NICK " + BOT + "\n" +
"JOIN #" + CHANNEL + "\n").encode())
def gamecontrol():
global message
while true:
if "up" in message.lower():
pyautogui.keyDown('up')
message = ""
pyautogui.keyUp('up')
else:
pass
def twitch():
def joinchat():
Loading = True
while Loading:
readbuffer_join = irc.recv(1024)
readbuffer_join = readbuffer_join.decode()
for line in readbuffer_join.split("\n")[0:-1]:
print(line)
loading = loadingComplete(line)
def loadingComplete(line):
if ("End of /NAMES list" in line):
print("Bot has joined " + CHANNEL + "Channel")
sendMessage(irc, "Chat room Joined")
return False
else:
return True
def sendMessage(irc, message):
messageTemp = "PRIVMSG #" + CHANNEL + message
irc.send((messageTemp + "\n").encode())
def getUser(line):
seperate = line.split(":", 2)
user = seperate[1].split("!", 1)[0]
print(user)
return user
def getMessage(line):
try:
message = (line.split(":,2"))[2]
except:
message = ""
return message
def Console(line):
if "PRIVMSG" in line:
return False
else:
return True
joinchat()
while True:
try:
readbuffer = irc.recv(1024).decode()
except:
readbuffer = ""
for line in readbuffer.split("\r\n"):
if line == "":
continue
if "PING" in line and Console(line):
msgg = "PONG tmi.twitch.tv\r\n".encode()
irc.send(msgg)
print(msgg)
continue
else:
print(line)
user = getuser(line)
message = getMessage(line)
print(user + message)
if _name_=='_main_':
t1 = threading.Thread(target = twitch)
t1. start()
t2 = threading.Thread(target = gamecontrol)
t2.start()
The only feedback I get is this
Traceback (most recent call last):
File “/Users/macintosh/Downloads/Twitch Plays/main/untitled.py”, line 10, in
irc.connect((SERVER, PORT))
TimeoutError: [Errno 60] Operation timed out
[Finished in 76.3s with exit code 1]
[cmd: [‘python3’, ‘-u’, ‘/Users/macintosh/Downloads/Twitch Plays/main/untitled.py’]]
[dir: /Users/macintosh/Downloads/Twitch Plays/main] [path:/Library/Frameworks/Python.framework/Versions/3.12/bin:/usr/local/bin:/System/Cryptexes/App/ usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/VMware Fusion.app/Contents/Public]
I don’t know I f im allowed to post code here but ive been switching from different forums trying to find an answer but nobody’s been giving me any answers. thanks to anyone who tries to help me! : )