Irc connection issue

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! : )

This indicates you have some sort of networ connectivity error and you cannot reach the stated destination as the connection timed out within the specified “time to wait for a connection to be made”

I cross ref’ed against python error code 60 - Google Search but basically seems your timeout is too low (unlikely) or wherever your code is cannot reach Twitch

1 Like

I mean this respectfully it’s just I’m really bad at code but I don’t understand what that means? Is it referring to my wifi or is it referring to the fact that I’m running this in sublime text. Im sorry that I’m asking I’m just really bad with coding things like this. I am also using an unregistered version of sublime text but the tutorial I’m following also is using the same version as me. I don’t think it could be my network since the code was working fine a couple days ago but when I had finished the tutorial it stopped working. Im following this tutorial by the way https://www.youtube.com/watch?v=sCagGV9Jl88&t=396s

Could be either, or both or something else.

Network connectivity issues could be any number of things

The version or registration state of Sublime shouldn’t make a difference

The error indicated is nothing to do with code, it’s a network/environment error

This is 6 years old theres probably much easier ways to achieve this now due to EventSub existing, likely EventSub Subscription Types | Twitch Developers is you want to consume chat messaging.

It’s not a code problem it’s a environment problem.

And from the tutorial I have no idea why the irc.connect is being cast with variables.

And if your code was working and you changed nothing and now isn’t working then the issue is environment and not code.

1 Like

Never mind I fixed it the join chat wasn’t indented correctly I have no idea why
sublime text never had said anything. Thanks for the help though since I had been trying to figure this out! <3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.