Created
April 23, 2010 17:54
-
-
Save sonicrules1234/376893 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import socket | |
import time | |
import string | |
import parse | |
import cmds | |
import opcmds | |
import IRCLISTS | |
import ccmds | |
import spanish | |
class IRCConnect(object): | |
def __init__(self, HOST, PORT, NICK, IDENT, REALNAME, JoinChannel, readbuffer, s): | |
self.HOST=HOST | |
self.PORT=PORT | |
self.NICK=NICK | |
self.IDENT=IDENT | |
self.REALNAME=REALNAME | |
self.JoinChannel=JoinChannel | |
self.s=s | |
self.readbuffer=readbuffer | |
self.parse = parse.Parse() | |
def Start(self): | |
self.s.connect((self.HOST, self.PORT)) | |
self.s.send("NICK %s\r\n" % self.NICK) | |
self.s.send("USER %s %s bla :%s\r\n" % (self.IDENT, self.HOST, self.REALNAME)) | |
self.s.send("PRIVMSG NICKSERV :IDENTIFY PASSWORD\r\n") | |
time.sleep(2) | |
self.s.send("JOIN %s\r\n" % (self.JoinChannel)) | |
def ReadBuffer(self): | |
readbuffer=self.readbuffer+self.s.recv(1024) | |
self.temp=string.split(readbuffer, "\n") | |
readbuffer=self.temp.pop() | |
for line in self.temp: | |
line=string.rstrip(line) | |
self.args=string.split(line) | |
if len(self.args)>1: | |
if self.args[0] == "PING": self.s.send("PONG %s\r\n" % self.args[1]) | |
if len(self.args)>=4: | |
self.line=line | |
self.CMD=(self.args[3])[1:].lower() | |
self.TotalString=" ".join(self.args[3:])[1:] | |
self.Nick=(self.args[0].split("!")[0])[1:] | |
self.Location=self.args[2] | |
self.parse.Parse(self.Nick, self.Location, self.TotalString, self.CMD, self.line, self.args, self.s) | |
if self.Nick=="Cam": | |
if self.CMD=="!r": | |
reload(parse) | |
reload(cmds) | |
reload(opcmds) | |
reload(IRCLISTS) | |
reload(ccmds) | |
reload(spanish) | |
HOST="irc.freenode.net" | |
PORT=6667 | |
NICK="Cam`" | |
IDENT="CamBot" | |
REALNAME="Owned by Cam" | |
PM="PRIVMSG" | |
JoinChannel="##bottest[cam]" | |
readbuffer="" | |
s=socket.socket() | |
Connect_IRC=IRCConnect(HOST, PORT, NICK, IDENT, REALNAME, JoinChannel, readbuffer, s) | |
Connect_IRC.Start() | |
while 1: | |
Connect_IRC.ReadBuffer() | |
print Connect_IRC.line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import socket | |
import time | |
import string | |
import cmds | |
import opcmds | |
import IRCLISTS | |
import ccmds | |
import spanish | |
class Parse(object): | |
def Parse(self, Nick, Location, TotalString, CMD, line, args, s): | |
self.Nick=Nick | |
self.Location=Location | |
self.TotalString=TotalString | |
self.CMD=CMD | |
self.line=line | |
self.args=args | |
self.s=s | |
self.PM="PRIVMSG" | |
self.rn="\r\n" | |
if self.Location=="Cam`": | |
self.Location=self.Nick | |
self.mod_cmds=cmds.Commands(self.Nick, self.Location, self.TotalString, self.CMD, self.line, self.args, self.s, self.iSend) | |
self.op_cmds=opcmds.OpCommands(self.Nick, self.Location, self.TotalString, self.CMD, self.line, self.args, self.s, self.iSend) | |
self.chan_cmds=ccmds.Chan_Commands(self.Nick, self.Location, self.TotalString, self.CMD, self.line, self.args, self.s, self.iSend) | |
self.spanish=spanish.Spanish(self.Nick, self.Location, self.TotalString, self.CMD, self.line, self.args, self.s, self.iSend) | |
#Start Parsing commands | |
if len(self.args)>=4: | |
if self.CMD=="!login":self.op_cmds.Login() | |
elif self.CMD=="!list":self.mod_cmds.List() | |
elif self.CMD=="!lookup":self.mod_cmds.LookUp() | |
elif self.CMD=="!up":self.chan_cmds.Up() | |
elif self.CMD=="!down":self.chan_cmds.Down() | |
elif self.CMD=="!leet":self.mod_cmds.LeetSpeak() | |
elif self.CMD=="!voice":self.chan_cmds.Voice() | |
elif self.CMD=="!devoice":self.chan_cmds.DeVoice() | |
elif self.CMD=="!kick":self.op_cmds.Kick() | |
elif self.CMD=="!conj":self.spanish.Conjugate() | |
elif self.CMD=="!join":self.chan_cmds.ChannelJP("join") | |
elif self.CMD=="!part":self.chan_cmds.ChannelJP("part") | |
elif self.CMD=="!ban":self.op_cmds.Ban("ban") | |
elif self.CMD=="!unban":self.op_cmds.Ban("unban") | |
elif self.CMD=="!userhost":self.op_cmds.UserHost() | |
if "=+~" in self.args[3]:self.op_cmds.UserHost2() | |
#iSend function | |
def iSend(self, msg): | |
x="%s %s :%s %s" % (self.PM, self.Location, msg, self.rn) | |
self.s.send(x) | |
print(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment