Here's the code for the Jister bot on IRC, if anyone cares.
import socket
import random
import time
server = "irc.freenode.net" # Server
channel = "##universesandbox" # Channel
botnick = "Jister" # Your bots nick
with open("kol.txt", "rt") as in_file:
koltimes = in_file.readline()
koltimes = int(koltimes)
with open("mfw.txt", "rt") as in_file:
mfwtimes = in_file.readline()
mfwtimes = int(mfwtimes)
shitlist = [" :kol\n", " :jkok\n", " :peacock\n", " :trollface.png\n", " :jackie_chan.png\n", " :misc_jackie_chan.png\n", " :home phone\n", " :mpw\n", " :mfw\n", " :what the christ\n", " :what the pony\n", " :allahu ackbar\n", " :ackbar\n", " :con\n", " :kolok\n", " :hpw\n", " :hfw\n", " :u wot m8\n", " :hue\n", " :peasant\n", " :what_the_christ.png\n", " :dar_on_his_sides.png\n", " :music.avi\n", " :sugg\n", " :inb4\n", " :peacock\n", " :plot twist\n", " :gorchul\n", " :my homeschooling when\n", " :pants.bigger\n", " :what the inafter christ\n", " :kolmunism\n", " :kolkommunism\n", " :sell your cars\n", " :donate your cars\n", " :kol\n", " :kolkon\n", " :inb4\n", " :hue\n", " :what the jkok\n", " :blotz is literally of jkok\n", " :bangkok\n"]
def ping(): # Respond to server pings
ircsock.send("PONG :pingis\n")
def joinchan(chan): # Join a channel
ircsock.send("JOIN "+ chan +"\n")
def randShitSpeak(): # Randomly selects a shitspeak phrase
ircsock.send("PRIVMSG " + channel + random.choice(shitlist))
ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ircsock.connect((server, 6667)) # Here we connect to the server using the port 6667
ircsock.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :Jister - A bot made by Jorster on USF\n") # user authentication
ircsock.send("NICK "+ botnick +"\n") # here we actually assign the nick to the bot
joinchan(channel) # Join the channel using the functions we previously defined
while 1: # Be careful with these! it might send you to an infinite loop
ircmsg = ircsock.recv(2048) # receive data from the server
ircmsg = ircmsg.strip('\n\r') # removing any unnecessary linebreaks.
ircmsg = ircmsg.lower() # Converting to lowercase for easier finding of kol
ircmsg = ircmsg.replace('osmotikol', 'dsfjak')
ircmsg = ircmsg.replace('!kol', 'dsfjal')
ircmsg = ircmsg.replace('!mfw', 'whatthejkok.avi')
print(ircmsg) # Here we print what's coming from the server
if ircmsg.find("ping :") != -1: # If the server pings us then we've got to respond!
ping()
if ircmsg.find("##universesandbox") != -1: # Make sure we're getting a message from the irc channel
if ircmsg.find("kol") != -1: # If someone says kol
koltimes += 1 # Add one to the koltimes variable
if koltimes == 3000:
ircsock.send("PRIVMSG " + channel + " :Congratulations!\n")
ircsock.send("PRIVMSG " + channel + " :UniverseSandbox has reached 3000 kols!\n")
with open("kol.txt", "wt") as out_file: # Open the kol.txt file
out_file.write(str(koltimes)) # Populate the file with the kol number
if ircmsg.find("mfw") != -1:
mfwtimes += 1
with open("mfw.txt", "wt") as out_file:
out_file.write(str(mfwtimes))
if ircmsg.find("whatthejkok.avi") != -1:
ircsock.send("PRIVMSG " + channel + " :mfw has been said " + str(mfwtimes) + " times!\n")
if ircmsg.find("soul") != -1: # If someone says soul
randShitSpeak() # Respond with shitspeak
if ircmsg.find("!jister") != -1: # If someone says !Jister
ircsock.send("PRIVMSG "+ channel + " :Jister v1.8 - A bot by Jorster. Counts the number of Kol's and Mfw's said in IRC, retrieve them via !kol and !mfw, respectively.\n") # Gives bot info
if ircmsg.find("dsfjal") != -1: # If someone says !kol
ircsock.send("PRIVMSG "+ channel + " :kol has been said " + str(koltimes) + " times!\n") # Respond with the number of times kol has been said
if ircmsg.find("thomas") != -1: # if someone says thomas
ircsock.send("PRIVMSG "+ channel + " :thamis*\n") #correct them to thamis
if ircmsg.find("BlaBla44") != -1:
if (random.randint(1,100)) == 1:
ircsock.send("PRIVMSG "+ channel + randShitSpeak())