`I'm a begginer in python, so I'm learning how to send whispers using a bot, to help my friend. I've do a research and and I arrived at the following code.
`HOST = 'irc.twitch.tv'
PORT = 6667
USER = 'bot name'
PASS = 'oauth:xxxxxxxxxx'
CHAN = 'channel here'
def abrirSocket():
s = socket.socket()
s.connect((HOST, PORT))
message = "PASS " + PASS + "\r\n"
s.send(message.encode('utf-8'))
message = "NICK " + USER + "\r\n"
s.send(message.encode('utf-8'))
message = "JOIN #" + CHAN + "\r\n"
s.send(message.encode('utf-8'))
return s
def fecharSocket(s):
s.close()
def entrar(s):
readbuffer = ""
Loading = True
while Loading:
readbuffer = readbuffer + s.recv(1024).decode()
temp = readbuffer.split('\n')
readbuffer = temp.pop()
for line in temp:
print(line)
Loading = terminou(line)
def terminou(line):
if("End of /NAMES list" in line):
return False
else: return True
def enviar_key(s, usuario, mensagem):
entrar(s)
montarMSG = f'PRIVMSG jtv :/w {usuario} {mensagem}'
s.send(montarMSG.encode('utf-8'))
fecharSocket(s)
sys.exit()
enviar_key(abrirSocket(), "margoni_", "aaaaa")`
But when execute this, this appear on terminal
:tmi.twitch.tv 001 previabot :Welcome, GLHF!
:tmi.twitch.tv 002 previabot :Your host is tmi.twitch.tv
:tmi.twitch.tv 003 previabot :This server is rather new
:tmi.twitch.tv 004 previabot :-
:tmi.twitch.tv 375 previabot :-
:tmi.twitch.tv 372 previabot :You are in a maze of twisty passages, all alike.
:tmi.twitch.tv 376 previabot :>
And don't receive any DM... Can anyone help me?
Note: I've tried to remove the buffer, to change the nick and the account, change the host and the channel, but nothing worked`