05-12-2014, 02:36 AM
This is just the basic stuff for python 3.x to get connected to IRC
Code:
import sys
import socket
import string
import random
HOST = "irc.freenode.net" #keep this the same
CHANNEL = "#OREServerChat" #keep this set to
PORT = 6667 #IRC's port, don't change
NICK = "CHANGEME" #name of your bot
IDENT = "CHANGEME" #more name of bot
REALNAME = "CHANGEME" #bot bot bot
MASTER = "CHANGEME" #you
readbuffer = "" #can't touch this.
password = str(random.randint(0,1111)) + "CHANGEME" #change to anything
print (password) #this prints your randomly-generated password
cmd = "CHANGEME" #what the bot looks for to execute commands
#getting connected
s=socket.socket( )
s.connect((HOST, PORT))
s.send(bytes("NICK %s\r\n" % NICK, "latin1"))
s.send(bytes("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME), "latin1"))
s.send(bytes("JOIN %s\r\n" % (CHANNEL), "latin1"));
s.send(bytes("PRIVMSG %s :Hello \r\n" % MASTER, "latin1"))
#what your bot does after its up and running
while 1:
text = s.recv(2040).decode("latin1") #don't mess with this, idk what it does
if text.find('PING') != -1: #confirms connection to IRC
s.send(bytes('PONG ' + text.split() [1] + '\r\n', "latin1"))
#quit bot when you type your cmd + quit + password(without space or +)
if text.find(cmd + "quit" + str(password)) != -1:
s.send(bytes("QUIT\r\n","latin1"))
break