Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import string
- import time
- import calendar
- import re
- import datetime
- import os
- import urllib2
- import json
- import threading
- import random
- from random import randint
- irc = dict()
- server = "irc.chat.twitch.tv"
- port = 6667
- channel = "#headdome"
- epoch_time = int(time.time())
- nick = []
- password = []
- #create web socket for each acc
- for index in range(len(nick)):
- irc[index] = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- spam = open('spam.txt').read().splitlines()
- def testSpam():
- global sleepTime
- for index in range(len(nick)):
- msgToSend = ''.join(spam.pop(0))
- print "SENDING " + msgToSend
- irc[index].send('PRIVMSG '+ channel +' :' + " " + msgToSend + " " + ' \r\n')
- #time.sleep(1.55) #The sleep delay should be 1.5 seconds divided by the amount of accounts you have
- time.sleep(0.200)
- testSpam()
- def pong():
- for index in range(len(nick)):
- irc[index].send("PONG :Pong\n")
- ircANN.send("PONG :Pong\n")
- def get_sender(msg):
- "Returns the user's nick (string) that sent the message"
- return msg.split(":")[1].split('!')[0]
- def parse_command(command):
- '''Returns an IRC command's components
- A dictionary will be filled by the data of the command, the command is as
- follows:
- :sender ACTION action_args :arguments
- sender(string) is the user who sent the command (only the user's nick)
- action(string) can be one of the following: PING, KICK, PRIVMSG, QUIT, etc.
- Check: http://www.irchelp.org/irchelp/rfc/chapter4.html#c4_2
- action_args(list of strings) depends on the ACTION, they are usually the
- channel or the user whom is the command for(see KICK, PRIVMSG, etc.), this
- will be a list and the items in the list will be the words that form the
- actual arguments
- arguments(string) depends on the ACTION
- eg: the command ':foo!foo@domain.tld KICK #chan user :reason' will become:
- sender: 'foo'
- action: 'KICK'
- action_args: ['#chan', 'user']
- arguments: 'reason'
- '''
- components = {
- 'sender' : '',
- 'action' : '',
- 'action_args' : [],
- 'arguments' : '',
- }
- if ':' == command[0]: # a user sent a command
- components['sender'] = get_sender(command)
- space_pos = command.find(' ') + 1
- command = command[space_pos:]
- space_pos = command.find(' ')
- components['action'] = command[:space_pos]
- command = command[space_pos + 1:]
- if ':' != command[0]: # action_args are present
- colon_pos = command.find(':')
- if -1 == colon_pos:
- colon_pos = len(command)+1
- components['action_args'] = command[:colon_pos-1].split()
- command = command[colon_pos:]
- if command and ':' == command[0]: # arguments are present
- components['arguments'] = command[1:]
- else: # the server sent a command
- space_pos = command.find(' ')
- components['action'] = command[:space_pos]
- components['arguments'] = command[space_pos+2:]
- components['arguments'] = components['arguments'].rstrip('\r')
- return components
- print "Establishing connection to [%s]" % (server)
- #connect on all accounts
- for index in range(len(nick)):
- irc[index].connect((server, port))
- irc[index].setblocking(False)
- irc[index].send("PASS %s\n" % (password[index]))
- irc[index].send("USER "+ nick[index] +" "+ nick[index] +" "+ nick[index] +" :droid\n")
- irc[index].send("NICK "+ nick[index] +"\n")
- irc[index].send("PRIVMSG nickserv :identify %s %s\r\n" % (nick[index], password[index]))
- irc[index].send("JOIN "+ channel +"\n")
- #irc[index].send("CAP REQ :twitch.tv/commands")
- readbuffer = ""
- for index in range(len(nick)):
- irc[index].setblocking(1)
- testSpam()
- #just start spamming
- threads = []
- while 1:
- try:
- ircmsg = irc[0].recv(1024).decode("UTF-8") # receive data from the server
- ircmsg = ircmsg.strip('\n\r') # removing any unnecessary linebreaks
- print ircmsg
- components = parse_command(ircmsg)
- msg = components['sender'] + ": " + components['arguments']
- #print "action component is " + components['action']
- if 'PING' == components['action']:
- print "found PING in action, sending pong!"
- pong()
- except socket.error:
- print("Socket died.. RIP")
- except socket.timeout:
- print("Socket timeout")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement