Skip to content

Instantly share code, notes, and snippets.

@illblew
Last active August 29, 2015 14:06
Show Gist options
  • Save illblew/8884b405bd5d90db4d4d to your computer and use it in GitHub Desktop.
Save illblew/8884b405bd5d90db4d4d to your computer and use it in GitHub Desktop.
Bot Example
#!/usr/bin/python
import socket
import sys
import mysqldb
server = "irc.swiftirc.net" #settings
channel = "#pxlbin"
botnick = "pxlboat"
#db jazzy
db=_mysql.connect("pxlb.in", "username", "password123", "database")
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #defines the socket
print "Connecting to:"+server
irc.connect((server, 6667))
irc.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :Pxlbot loaded\n")
irc.send("NICK "+ botnick +"\n")
irc.send("PRIVMSG nickserv :iNOOPE\r\n")
irc.send("JOIN "+ channel +"\n")
irc.send("PRIVMG frienz :I've joined pxlbin.") #who to alert when the bot is running.
while 1: #infinite loop
text=irc.recv(2040)
print text #prints all text from irc network.
if text.find('PING') != -1:
irc.send('PONG ' + text.split() [1] + '\r\n') #REQIRED PING PONG
if text.lower.find('!getpxl') != -1: #This is the thing you'll be looking for!
irc.send("PRIVMSG wblew :hi\r\n") #This is how you take action when you see the thing you're lookign for
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment