Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding: utf-8
- from twitch import Twitch
- import sys
- import socket, string
- HOST = 'irc.twitch.tv'
- NICK = 'cashm3'
- PORT = 6667
- PASS = 'oauth:oswk1k3t9ois7bwyuxb70e0053mqy1'
- readbuffer = ''
- s = socket.socket()
- s.connect((HOST, PORT))
- s.send('PASS ' + PASS + '\r\n')
- s.send('NICK ' + NICK + '\r\n')
- s.send('JOIN #cashm3 \r\n')
- def join_room(room):
- s.send('JOIN #' + room + ' \r\n')
- def Send_message(message):
- s.send('PRIVMSG #cashm3 :' + message + '\r\n')
- def owner_bot(nomeOwner):
- listaNomes = open('owners_bot.txt', 'a')
- listaNomes.write('\n' + nomeOwner)
- listaNomes.close()
- ownerNome = open('owners_bot.txt', 'r').read().splitlines()
- while True:
- readbuffer = readbuffer + s.recv(1024)
- temp = string.split(readbuffer, '\n')
- readbuffer = temp.pop()
- for line in temp:
- if (line[0] == 'PING'):
- s.send('PONG %s\r\n' % line[1])
- else:
- parts = string.split(line, ':')
- if 'QUIT' not in parts[1] and 'JOIN' not in parts[1] and 'PART' not in parts[1]:
- try:
- message = parts[2][:len(parts[2]) -1]
- except:
- message = ''
- usernamesplit = string.split(parts[1], "!")
- username = usernamesplit[0]
- Twitch('fcolor', 'green')
- print username + ": " + message
- tt = Twitch('','')
- tt.rcolor()
- if message.lower() == 'bot':
- Send_message('Olá @'+ username)
- if 'bot' in message.lower():
- Send_message('Obviamente the Mr. BOT @' + username)
- if message[:1] == '!':
- Twitch('fcolor', 'yellow')
- args = message.split(' ')
- args[0] = args[0][1:]
- test = args[0][2:]
- cmd = args[0]
- argu = message.replace('.'+cmd+' ', '')
- print '[COMMAND] '+cmd+' | [ARGUMENT] ' + argu
- if cmd.lower() == 'go':
- ownerNome = open('owners_bot.txt', 'r').read().splitlines()
- if username in ownerNome:
- try:
- Send_message('[+] Abrindo conexao para ' + args[1])
- join_room(args[1])
- except:
- Send_message('Modo de uso: !go "Canal_Twitch"')
- else:
- Send_message('@'+ username + ' Você não tem permissão para executar esse comando.')
- tt.bcolor()
- print username + " : cannot do this command! [{}]".format(cmd)
- tt.rcolor()
- elif cmd.lower() == 'moderador':
- ownerNome = open('owners_bot.txt', 'r').read().splitlines()
- if username in ownerNome:
- try:
- moderador = args[1]
- owner_bot(moderador)
- Send_message('[+] ' + moderador + ' Adicionado à lista de moderadores.')
- except:
- Send_message('Modo de uso: !moderador "nick"')
- else:
- Send_message('@'+ username + ' Você não tem permissão para executar esse comando.')
- tt.bcolor()
- print username + " : cannot do this command! [{}]".format(cmd)
- tt.rcolor()
- elif cmd.lower() == '' or cmd.lower() == ' ':
- Send_message('[-] @' + username + ' Lista de comandos disponíveis: moderador | go')
- elif cmd.lower() == 'comandos':
- Send_message('[+] {} Lista de comandos disponíveis: moderador | go'.format('@'+username))
- Send_message('{} Para saber informações digite !info_<Comando> | Exemplo: !info_moderador'.format('@'+username))
- elif cmd.lower() == 'info_moderador':
- Send_message('[+] {} Modo de uso: !moderador <Nick>'.format('@'+username))
- Send_message('{} Torna uma pessoa moderador do BOT.'.format('@'+username))
- elif cmd.lower() == 'info_go':
- Send_message('[+] {} Modo de uso: !go <Canal_Twitch>'.format('@'+username))
- Send_message('{} Comando usado para abrir uma conexão com o canal informado,'
- ' servindo para visualizações de diálogos externos.'.format('@'+username))
- else:
- Send_message('Este comando não existe. {}'.format('@'+username))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement