Twitchbot doesn't connect to the server

I have made a twitchbot, in the console it gives me the “your are in a maze” thing and successfully reads messages from the chat and even pings and pongs but, doesn’t send the messages i tell it to write in chat. here is my bot code

import cfg
import BotFunc
import socket
import re
import time,thread
from time import sleep

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

CHAT_MSG = re.compile(r"^:\w+!\w+@\w+\.tmi\.twitch\.tv PRIVMSG #\w+ :")
BotFunc.chat(s, "I LIVE!!!")

thread.start_new_thread(BotFunc.threadFillOPList, ())

while True:
    response = s.recv(1024).decode("utf-8")
    if response == "PING :tmi.twitch.tv\r\n":
        print("Ping")
        s.send("PONG :tmi.twitch.tv\r\n".encode("utf-8"))
        print("Pong")
    else:
        username = re.search(r"\w+", response).group(0)
        message = CHAT_MSG.sub("", response)
        print(response)

    if message.strip == "!info": #and BotFunc,isOp(username)
        BotFunc.chat(s, "test 1")
        BotFunc.chat(s, "test 2")
        BotFunc.chat(s, "test 3")
sleep(1)

if name == “main”:
main()

and here is my message sending function

def chat(sock, msg):
sock.send(“PRIVMSG #{} :{}\r\n”.format(cfg.CHAN, msg))

i would greatly appreciate your input and suggestions as to how to fix this, it is important.

Based on you successfully receiving messages, your cfg.CHAN has # in it, so you’re sending 2.

so do i remove a #?

so i added a # in

s.send(“JOIN #{}\r\n”.format(cfg.CHAN).encode(“utf-8”))

and removed a # in

sock.send(“PRIVMSG {} :{}\r\n”.format(cfg.CHAN, msg))

and now it can send but not recieve

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