Advertisement
Guest User

Untitled

a guest
Aug 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. import socket, string, time, re, random
  2.  
  3. # Set all the variables necessary to connect to Twitch IRC
  4. HOST = "irc.twitch.tv"
  5. NICK = "calus14"
  6. PORT = 6667
  7. PASS = "oauth:frct1uinrqvb3gz7udzqybxrm7ne8k"
  8. MODT = False
  9. CHANNELNAME = "kaia"
  10.  
  11. # Connecting to Twitch IRC by passing credentials and joining a certain channel
  12. s = socket.socket()
  13. s.connect((HOST, PORT))
  14. s.send("PASS " + PASS + "\r\n")
  15. s.send("NICK " + NICK + "\r\n")
  16. s.send("JOIN #"+CHANNELNAME+" \r\n")
  17.  
  18. # Method for sending a message
  19. def Send_message(message):
  20. print("sending message "+message)
  21. s.send("PRIVMSG #"+CHANNELNAME+" :" + message + "\r\n")
  22. print("Sent message")
  23.  
  24. spamMessages = []
  25.  
  26. with open("PickupLines.txt", 'r') as pickUpLines:
  27. lines = pickUpLines.readlines()
  28. for pickupLine in lines:
  29. pickupLine = pickupLine.rstrip()
  30. if pickupLine:
  31. print(pickupLine)
  32. spamMessages.append(pickupLine)
  33.  
  34. with open("DadJokes.txt", 'r') as dadJokes:
  35. jokes = dadJokes.readlines()
  36. for joke in jokes:
  37. joke = joke.rstrip()
  38. if joke:
  39. print(joke)
  40. spamMessages.append(joke)
  41.  
  42. while True:
  43. print("Listening")
  44. readbuffer = s.recv(1024).decode("utf-8")
  45. print("got something "+readbuffer)
  46. temp = string.split(readbuffer, "\n")
  47. for line in temp:
  48. print(line)
  49. # Checks whether the message is PING because its a method of Twitch to check if you're afk
  50. if "PING" in line:
  51. s.send("PONG :tmi.twitch.tv\r\n")
  52. else:
  53. Send_message(random.choice(spamMessages))
  54. time.sleep(300)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement