Guest User

Untitled

a guest
Jan 31st, 2016
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. import socket #imports module allowing connection to IRC
  2. import threading #imports module allowing timing functions
  3. import time
  4. import random
  5. import urllib2
  6. import datetime
  7. import sys
  8.  
  9. from random import randint
  10.  
  11. phrases = [
  12. "MitchPls THIS MitchPls SONG MitchPls IS MitchPls ILL MitchPls NASTY MitchPls THIS MitchPls SONG MitchPls IS MitchPls ILL MitchPls NASTY MitchPls THIS MitchPls SONG MitchPls IS MitchPls ILL MitchPls NASTY MitchPls",
  13. "SourPls THIS SourPls SONG SourPls IS SourPls ILL SourPls NASTY SourPls THIS SourPls SONG SourPls IS SourPls ILL SourPls NASTY SourPls THIS SourPls SONG SourPls IS SourPls ILL SourPls NASTY SourPls",
  14. "bUrself I bUrself Dream bUrself Of bUrself A bUrself Chat bUrself Full bUrself Of bUrself Bees bUrself",
  15. "OpieOP I EAT BURGERS ALL DAY OpieOP LEAGUE OF LEGENDS I CANNOT PLAY OpieOP KOREANS I HAVE TO PAY OpieOP YOU GUESSED IT RIGHT OpieOP IM FROM NA OpieOP",
  16. "EleGiggle MY BELLY IS HUGE EleGiggle MY BRAIN HAS DELAY EleGiggle YOU GUESSED IT RIGHT EleGiggle I'M FROM NA"
  17. ]
  18.  
  19. sound_commands = [
  20. "!mlg",
  21. "!gg",
  22. "!unstoppable",
  23. "!lol",
  24. "!victory",
  25. "!sad",
  26. ]
  27.  
  28. #sets variables for connection to twitch chat
  29. bot_owner = 'Gasolinebased'
  30. nick = sys.argv[1]
  31. #nick = 'fwnaeuifbweoyi'
  32. channel = '#atomicus'
  33. server = 'irc.twitch.tv'
  34. password = sys.argv[2]
  35. #password = 'oauth:891j6yyz3nqg38afw1alxrn58eba07'
  36.  
  37. def send_message(msg):
  38. irc.send("PRIVMSG " + channel + " :" + msg + "\n")
  39.  
  40.  
  41. sound_command_timer = int(round(time.time() * 1000))
  42. irc = socket.socket()
  43. is_spamming = -1
  44. spam_time = 0
  45.  
  46.  
  47. irc.connect((server, 6667)) #connects to the server
  48.  
  49. #sends variables for connection to twitch chat
  50. irc.send('PASS ' + password + '\r\n')
  51. irc.send('USER ' + nick + ' 0 * :' + bot_owner + '\r\n')
  52. irc.send('NICK ' + nick + '\r\n')
  53. irc.send('JOIN ' + channel + '\r\n')
  54.  
  55. f = open(channel + ".txt",'w')
  56. f.write("\n")
  57. f.write("Connected to " + channel + " starting log...\n")
  58. f.write("---------\n")
  59.  
  60. while True:
  61. data = irc.recv(1204) #gets output from IRC server
  62. message = data.split(':')[1]
  63. user = message.split('!')[0] #determines the sender of the messages
  64.  
  65. try:
  66. message = data.split(":")[2]
  67. except IndexError:
  68. message = data
  69.  
  70. print datetime.datetime.now().strftime("%H:%M:%S") + " > " + user + ": " + message
  71. currentTime = int(round(time.time() * 1000))
  72. f.write(datetime.datetime.now().strftime("%H:%M:%S") + " > " + user + ": " + message)
  73.  
  74.  
  75. if user.find("atomicbots") != -1:
  76. send_message("MrDestructoid STFU ATOMICBOTS MrDestructoid")
  77.  
  78. if message.find('!status') != -1:
  79. send_message("MrDestructoid READY TO DEMOLISH ATOMICBOTS MrDestructoid")
  80.  
  81. if message.find('!autism') != -1:
  82. randLevel = randint(0,100)
  83. emote = ""
  84. if randLevel <= 30:
  85. emote = "FeelsGoodMan"
  86. else:
  87. emote = "FeelsBadMan"
  88. send_message(user + " is " + str(randLevel) + "%" + " autistic " + emote)
  89.  
  90. if message.find("!farm") != -1:
  91. send_message("!datapad")
  92.  
  93. if message.find("!sound") != -1:
  94. if int(round(time.time() * 1000)) - sound_command_timer > 10000:
  95. send_message(random.choice(sound_commands))
  96. else:
  97. send_message(user + " sounds are on a 10 second cooldown so my master won't get IP banned MrDestructoid")
  98.  
  99. if message.find("!spam") != -1:
  100. if is_spamming == -1:
  101. send_message("FeelsGoodMan Spam status has been toggled: ON FeelsGoodMan")
  102. else:
  103. send_message("FeelsBadMan Spam status has been toggled: OFF FeelsBadMan")
  104. is_spamming = is_spamming * -1
  105. spam_time = int(round(time.time() * 1000))
  106.  
  107. if currentTime - spam_time > 60000 * 3 and is_spamming == 1: #to prevet removal from double messaging within 30 sec
  108. spam_time = currentTime
  109. send_message(random.choice(phrases))
Add Comment
Please, Sign In to add comment