Advertisement
plum0

Untitled

Nov 17th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. from IRC import *
  2. import time
  3. import random
  4. import sys
  5.  
  6.  
  7. ### Server Options
  8. SERVER = "irc.chat.twitch.tv" # server
  9. PORT = 6667 # port
  10.  
  11. ### User/Channel Options
  12. PASS = "oauth:x725aqacblofgd73xlrdgwpo2xn874" # plum0_ bot password
  13. BOT = "plum0_" # Bot's name no caps
  14. CHANNEL = "plum0_" # Channel name no caps
  15. OWNER = "plum0_" # Owner's name no caps
  16.  
  17. bot = IRC(SERVER, PORT, PASS, BOT, CHANNEL, OWNER)
  18. bot.joinchat()
  19.  
  20. ##bot.s.send(("CAP REQ :twitch.tv/membership\r\n").encode())
  21. ##bot.s.send(("CAP REQ :twitch.tv/tags\r\n").encode())
  22. ##bot.s.send(("CAP REQ :twitch.tv/commands\r\n").encode())
  23.  
  24. while True:
  25. try:
  26. readbuffer = bot.s.recv(1024)
  27. readbuffer = readbuffer.decode('utf-8')
  28. temp = readbuffer.split("\n")
  29. readbuffer = readbuffer.encode('utf-8')
  30. readbuffer = temp.pop()
  31. except:
  32. temp = ""
  33.  
  34. for line in temp:
  35. if line == "":
  36. break
  37. ### So twitch doesn't timeout the bot.
  38. if "PING" in line and bot.Console(line):
  39. msgg = "PONG tmi.twitch.tv\r\n".encode()
  40. bot.s.send(msgg)
  41. print(msgg)
  42. break
  43. ### get user
  44. user = bot.getUser(line)
  45. ### get message send by user
  46. message = bot.getMessage(line)
  47. ### for you to see the chat from CMD and prevents some spammy text
  48. if "tmi.twitch.tv NOTICE #" in user and "Your color has been changed." in message or ".twitch.tv USERSTATE #" in user:
  49. break
  50. else:
  51. print(user + " > " + message)
  52. ### sends private msg to the user (start line)
  53. PMSG = "/w " + user + " "
  54.  
  55. if bot.coolCheck():
  56.  
  57. if "plum" in message.lower():
  58. bot.sendMessage(bot.s, "")
  59. def quote(user,message):
  60. file = open("Tzu.txt")
  61. #num_lines = sum(1 for line in open("Tzu.txt"))
  62. lines = file.read().splitlines()
  63. time.sleep(1)
  64. ater = user
  65. try:
  66. if(len(message.lower()[5:])!=0):
  67. ater = message.lower()[5:]
  68. sendMessage(s, random.choice(lines) + " @" + ater)
  69. else:
  70. sendMessage(s, random.choice(lines) + " @" + user)
  71. except:
  72. print(user + " tried to break the bot.")
  73. sendMessage(s, random.choice(lines) + " @" + user)
  74. file.close()
  75.  
  76. bot.cooldown(2) # CoolDown Time
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement