Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.78 KB | None | 0 0
  1. # coding: utf-8
  2.  
  3. from twitch import Twitch
  4. import sys
  5. import socket, string
  6.  
  7.  
  8. HOST = 'irc.twitch.tv'
  9. NICK = 'cashm3'
  10. PORT = 6667
  11. PASS = 'oauth:oswk1k3t9ois7bwyuxb70e0053mqy1'
  12. readbuffer = ''
  13.  
  14. s = socket.socket()
  15. s.connect((HOST, PORT))
  16. s.send('PASS ' + PASS + '\r\n')
  17. s.send('NICK ' + NICK + '\r\n')
  18. s.send('JOIN #cashm3 \r\n')
  19.  
  20. def join_room(room):
  21. s.send('JOIN #' + room + ' \r\n')
  22.  
  23. def Send_message(message):
  24. s.send('PRIVMSG #cashm3 :' + message + '\r\n')
  25.  
  26. def owner_bot(nomeOwner):
  27. listaNomes = open('owners_bot.txt', 'a')
  28. listaNomes.write('\n' + nomeOwner)
  29. listaNomes.close()
  30. ownerNome = open('owners_bot.txt', 'r').read().splitlines()
  31.  
  32. while True:
  33. readbuffer = readbuffer + s.recv(1024)
  34. temp = string.split(readbuffer, '\n')
  35. readbuffer = temp.pop()
  36.  
  37. for line in temp:
  38. if (line[0] == 'PING'):
  39. s.send('PONG %s\r\n' % line[1])
  40. else:
  41. parts = string.split(line, ':')
  42.  
  43. if 'QUIT' not in parts[1] and 'JOIN' not in parts[1] and 'PART' not in parts[1]:
  44. try:
  45. message = parts[2][:len(parts[2]) -1]
  46. except:
  47. message = ''
  48.  
  49. usernamesplit = string.split(parts[1], "!")
  50. username = usernamesplit[0]
  51.  
  52. Twitch('fcolor', 'green')
  53. print username + ": " + message
  54. tt = Twitch('','')
  55. tt.rcolor()
  56.  
  57.  
  58. if message.lower() == 'bot':
  59. Send_message('Olá @'+ username)
  60.  
  61. if 'bot' in message.lower():
  62. Send_message('Obviamente the Mr. BOT @' + username)
  63.  
  64. if message[:1] == '!':
  65. Twitch('fcolor', 'yellow')
  66. args = message.split(' ')
  67. args[0] = args[0][1:]
  68. test = args[0][2:]
  69. cmd = args[0]
  70. argu = message.replace('.'+cmd+' ', '')
  71. print '[COMMAND] '+cmd+' | [ARGUMENT] ' + argu
  72.  
  73. if cmd.lower() == 'go':
  74. ownerNome = open('owners_bot.txt', 'r').read().splitlines()
  75. if username in ownerNome:
  76. try:
  77. Send_message('[+] Abrindo conexao para ' + args[1])
  78. join_room(args[1])
  79. except:
  80. Send_message('Modo de uso: !go "Canal_Twitch"')
  81. else:
  82. Send_message('@'+ username + ' Você não tem permissão para executar esse comando.')
  83. tt.bcolor()
  84. print username + " : cannot do this command! [{}]".format(cmd)
  85. tt.rcolor()
  86.  
  87. elif cmd.lower() == 'moderador':
  88. ownerNome = open('owners_bot.txt', 'r').read().splitlines()
  89. if username in ownerNome:
  90. try:
  91. moderador = args[1]
  92. owner_bot(moderador)
  93. Send_message('[+] ' + moderador + ' Adicionado à lista de moderadores.')
  94. except:
  95. Send_message('Modo de uso: !moderador "nick"')
  96. else:
  97. Send_message('@'+ username + ' Você não tem permissão para executar esse comando.')
  98. tt.bcolor()
  99. print username + " : cannot do this command! [{}]".format(cmd)
  100. tt.rcolor()
  101. elif cmd.lower() == '' or cmd.lower() == ' ':
  102. Send_message('[-] @' + username + ' Lista de comandos disponíveis: moderador | go')
  103.  
  104. elif cmd.lower() == 'comandos':
  105. Send_message('[+] {} Lista de comandos disponíveis: moderador | go'.format('@'+username))
  106. Send_message('{} Para saber informações digite !info_<Comando> | Exemplo: !info_moderador'.format('@'+username))
  107.  
  108. elif cmd.lower() == 'info_moderador':
  109. Send_message('[+] {} Modo de uso: !moderador <Nick>'.format('@'+username))
  110. Send_message('{} Torna uma pessoa moderador do BOT.'.format('@'+username))
  111.  
  112. elif cmd.lower() == 'info_go':
  113. Send_message('[+] {} Modo de uso: !go <Canal_Twitch>'.format('@'+username))
  114. Send_message('{} Comando usado para abrir uma conexão com o canal informado,'
  115. ' servindo para visualizações de diálogos externos.'.format('@'+username))
  116.  
  117. else:
  118. Send_message('Este comando não existe. {}'.format('@'+username))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement