Python bot seems to be connecting in terminal but not showing up in chat?

Hi there, Im pretty new to this so I might have just made a dumb mistake but I’m stumped.

RUN.PY
from Socket import openSocket
from Initialize import joinRoom

s = openSocket()
joinRoom(s)

while True:
persist = True

SETTINGS.PY
HOST = “irc.chat.twitch.tv
PORT = 6667
PASS = “oauth:”
IDENT = “taq_bot”
CHANNEL = “zortaq”

SOCKET.PY
import socket
from Settings import HOST, PORT, PASS, IDENT, CHANNEL

def openSocket():
s = socket.socket()
s.connect((HOST, PORT))
s.send(“PASS {}\r\n”.format(PASS).encode(“utf-8”))
s.send(“NICK {}\r\n”.format(IDENT).encode(“utf-8”))
s.send(“JOIN {}\r\n”.format(CHANNEL).encode(“utf-8”))
return s

def sendMessage(s, message):
s.send(bytes(“PRIVMSG #” + NICK + " :" + message + “\r\n”, “UTF-8”))

READ.PY
import string

def getUser(line):
separate = line.split(":", 2)
user = separate[1].split("!", 1)[0]
return user

def getMessage(line):
separate = line.split(":", 2)
message = separate[2]
return message

INITIALIZE.PY
from Socket import sendMessage

def joinRoom(s):
readbuffer = “”
Loading = True
while Loading:
readbuffer += str(s.recv(1024))
temp = str(readbuffer).split(".")
readbuffer = temp.pop()

    for line in temp:
        print(line)
        Loading = loadingComplete(line)
sendMessage(s, "Successfully joined chat")

def loadingComplete(line):
if “End of /NAMES list” in line:
return False
else:
return True

You didn’t include a # in front of the channel name.

So you didn’t join the right room

1 Like

Thank you! however im still having the same problem.

It’s it reading and responding to chat commands as expected?

Or jsut not appearing in the chatters list? (Chatters lsit take an age to update)

its not appearing in the chat list

If it’s working fine except for that

Then I imagine the chatter lists are jsut taking longer than usual to update (as they do not update instantly)

1 Like

now its getting to this point but still not connecting
b’:tmi
twitch
tv 001 zortaq :Welcome, GLHF!\r\n:tmi
twitch
tv 002 zortaq :Your host is tmi
twitch
tv\r\n:tmi
twitch
tv 003 zortaq :This server is rather new\r\n:tmi
twitch
tv 004 zortaq :-\r\n:tmi
twitch
tv 375 zortaq :-\r\n:tmi
twitch
tv 372 zortaq :You are in a maze of twisty passages, all alike
\r\n:tmi
twitch

That looks connected to me.

So

what do you mean not connecting?

I apologies for the slow replies. The bot is not connecting the chat. Sorry about the lack of clarification.

Earlier you said this

and

Both of these you said it was responding to commands in chat, As thats what I asked
And the second block shows it is connecting…
As thats the IRC Welcome messaging

So you seem to be contradicting yourself.

I don’t see any faults in your code, nothing obvious at least.

And if it’s returning the welcome messaging then you are connecting. It’s just not showing in the viewerlist

What is the current problem. Let us start over.

  • Is it repling to commands in chat?
  • Is it logging incoming chat messages?
  • Where any errors logged?

Again I’m sorry. I’m still really new to this.
It is not replying to anything in chat.
No chat messages are appearing in chat.
I do not see any errors logged.

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