# Bot not Send message

**URL:** <https://discuss.dev.twitch.com/t/bot-not-send-message/33222>\
**Category:** Chat and IRC\
**Created:** [August 24, 2021, 8:31am UTC](https://discuss.dev.twitch.com/t/bot-not-send-message/33222 "2021-08-24T08:31:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![11196](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/11196/32/13330_2.png) [@11196](https://discuss.dev.twitch.com/u/11196)\
**Post date:** [August 24, 2021, 8:31am UTC](https://discuss.dev.twitch.com/t/bot-not-send-message/33222/1 "2021-08-24T08:31:52Z")

</div>

Help please. My bot read, but not send messages

```auto
import socket
import re
import time
import thread
from time import sleep

HOST = "irc.twitch.tv"
PORT = 6667
NICK = "dmitrygargulin"
PASS = "oauth:xxxxxx"
CHAN = "#mrlehasm"
RATE = (20/30)

oplist = {}

def mess(sock, message):
    #sock.send("PRIVMSG #{} :{}\r\n".format(CHAN, mess).encode("utf-8"))
    sock.send("PRIVMSG #{} :{}".format(CHAN, message))

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

    chat_message = re.compile(r"^:w+!\w+@\w+\.tmi\.twitch\.tv PRIVMSG #\w+ :")
    mess(s, "Я родился!")

    response = ""
    
    while True:
        response = s.recv(1024).decode("utf-8")
        print(response)
        if response == "PING :tmi.twitch.tv\r\n":
            s.send("POND :tmi.twitch.tv\r\n".encode("unf-8"))
        else:
            username = re.search(r"\w+", response).group(0)
            message = chat_message.sub("", response)
            print(username + ": " + message)
            
            if message.strip() == "!hello":
                mess(s, "Hi, mister!")
        sleep(1)

if __name__ == " __main__":
    main()

```

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [August 24, 2021, 9:26am UTC](https://discuss.dev.twitch.com/t/bot-not-send-message/33222/2 "2021-08-24T09:26:45Z")

</div>

What errors are returned?

Turn on/enabled raw reponse logging and see what you get back when you attempt to send a message

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [September 23, 2021, 9:27am UTC](https://discuss.dev.twitch.com/t/bot-not-send-message/33222/3 "2021-09-23T09:27:16Z")

</div>

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