Skip to content

Instantly share code, notes, and snippets.

@Nezzerath
Created January 10, 2013 02:33
Show Gist options
  • Save Nezzerath/4498906 to your computer and use it in GitHub Desktop.
Save Nezzerath/4498906 to your computer and use it in GitHub Desktop.
functions
def parse():
try:
IRC_PRIVMSG_Information = [
data.split( ":" )[ 1 ].split( "!" )[ 0 ], #nick
data.split( "!" )[ 1 ].split( "@" )[ 0 ], #user
data.split( " " )[ 0 ].split( "@" )[ 1 ], #host
data.split( " " )[ 2 ], #Channel, Message
":".join( data.split( ":" )[ 2: ] ), True ] # Channel or PM
if not IRC_PRIVMSG_Information[ 3 ][ 0 ] == "#":
IRC_PRIVMSG_Information[ 5 ] = False
print IRC_PRIVMSG_Information
except Exception, Error: print "Error: %s" % ( Error )
commands()
def commands():
if not nickname.lower() in IRC_PRIVMSG_Information[4]:
if "action is dead" in IRC_PRIVMSG_Information[4]:
time.sleep(2)
s.send("PRIVMSG %s :%s\r\n" % (channel, "ACTION is resurrecting " + name + ""))
time.sleep(2)
s.send("PRIVMSG %s :%s\r\n" % (channel, name + " has been resurrected."))
if nickname.lower() in IRC_PRIVMSG_Information[4]:
if "hello" in IRC_PRIVMSG_Information[4]:
s.send("PRIVMSG %s :%s\r\n" % (channel, "Hello" + " " + name))
if "disconnect" in IRC_PRIVMSG_Information[4]:
sys.exit()
if "set status to away" in IRC_PRIVMSG_Information[4]:
reason = IRC_PRIVMSG_Information[4]
reason = reason.split("*")
print reason[1]
s.send("AWAY " + reason[1])
if "come back" in IRC_PRIVMSG_Information[4]:
s.send("BACK \n")
if "what are you?" in IRC_PRIVMSG_Information[4]:
s.send("PRIVMSG %s :%s\r\n" % (channel, "I am a Cleric, " + name))
if "roll d20" in IRC_PRIVMSG_Information[4]:
s.send("PRIVMSG %s :%s\r\n" % (channel, "ACTION rolled a " + str(random.randrange(1,20+1)) + ""))
if "flip a coin" in IRC_PRIVMSG_Information[4]:
coin = random.randrange(1,2+1)
if coin == 1:
answer = "heads"
if coin == 2:
answer = "tails"
s.send("PRIVMSG %s :%s\r\n" % (channel, "ACTION flips a coin"))
s.send("PRIVMSG %s :%s\r\n" % (channel, "Coin lands on " + answer))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment