[SCRIPT] ircpublish
Posted: Tue Jul 09, 2013 5:08 pm
hai ho, hai ho, its off to script we go...
ircpublish just adds a load of things to allow your server irc people to, well, know what is going on.
e.g in the default when i do /squad cool
the irc people see "thepolm3 joined squad cool"
have funnnnnnnnnnnn
nnnnnnnnnnnnnnnnnnn
nnnnnnnnnnnnnnnnnnn
ircpublish just adds a load of things to allow your server irc people to, well, know what is going on.
e.g in the default when i do /squad cool
the irc people see "thepolm3 joined squad cool"
have funnnnnnnnnnnn
nnnnnnnnnnnnnnnnnnn
nnnnnnnnnnnnnnnnnnn
Code: Select all
"""
publishes speial events to the irc
thepolm3
requested by blender man
"""
from pyspades.constants import *
from commands import add,admin
@admin
def ircpublish(connection):
global ENABLED
ENABLED = not ENABLED
return "ircpublish %s" %(["disabled","enabled"][ENABLED])
add(ircpublish)
ENABLED = True
PLAYER_DIED = "{player} died" #given player
PLAYER_KILLED = "{killer} killed {player}" #given player and killer
PLAYER_SUICIDED = "{player} commmited suicide" #given player
PLAYER_ENTERED_COMMAND = "{player} : /{command} {parameters}" #given player, command and parameters
PLAYER_ENTERED = { #given player and parameters
"squad" : "{player} joined squad {parameters}",
"pm" : "{player} sends the following message to {parameters}"
}
PLAYER_CHANGED_WEAPON = "{player} switched to the {weapon}" #given player and weapon
PLAYER_CHANGED_TEAM = "{player} joined the {team} team" #given player and team
PLAYER_HIT = False #given player and hitter
PLAYER_FALLS = False #given player
PLAYER_TAKES_FLAG = False #given player
PLAYER_DROPS_FLAG = False #given player
PLAYER_CAPTURES_FLAG = False #given player
PLAYER_LOGS_IN = False #given player and login
def apply_script(protocol,connection,config):
class IRCPublishConnection(connection):
def on_kill(self,by,type,grenade):
if ENABLED:
if type==TEAM_CHANGE_KILL and PLAYER_CHANGED_TEAM:
self.protocol.irc_say(PLAYER_CHANGED_TEAM.format(player = self.name,team=self.team.name))
elif type==CLASS_CHANGE_KILL and PLAYER_CHANGED_WEAPON:
self.protocol.irc_say(PLAYER_CHANGED_WEAPON.format(player = self.name,weapon=self.weapon))
elif not by and PLAYER_DIED:
self.protocol.irc_say(PLAYER_DIED.format(player = self.name))
elif self==by and PLAYER_SUICIDED:
self.protocol.irc_say(PLAYER_SUICIDED.format(player = self.name))
return connection.on_kill(self,by,type,grenade)
def on_hit(self,victim,damage,type,b):
if ENABLED:
if PLAYER_HIT and damage<self.hp:
self.protocol.irc_say(PLAYER_HIT.format(player = victim.name,hitter = self.name))
return connection.on_hit(self,victim,damage,type,b)
def on_fall(self,a):
if ENABLED:
if PLAYER_FALLS:
self.protocol.irc_say(PLAYER_FALLS.format(player = self.name))
return connection.on_fall(self,a)
def on_flag_take(self):
if ENABLED:
if PLAYER_TAKES_FLAG:
self.protocol.irc_say(PLAYER_TAKES_FLAG.format(player = self.name))
return connection.on_flag_take(self)
def on_flag_capture(self):
if ENABLED:
if PLAYER_CAPTURES_FLAG:
self.protocol.irc_say(PLAYER_CAPTURES_FLAG.format(player = self.name))
return connection.on_flag_capture(self)
def on_flag_drop(self):
if ENABLED:
if PLAYER_DROPS_FLAG:
self.protocol.irc_say(PLAYER_DROPS_FLAG.format(player = self.name))
return connection.on_flag_drop(self)
def on_user_login(self,rank,cake):
if ENABLED:
if PLAYER_LOGS_IN:
self.protocol.irc_say(PLAYER_LOGS_IN.format(player = self.name,login = rank))
return connection.on_user_login(self,rank,cake)
def on_command(self,command,parameters):
if ENABLED:
if PLAYER_ENTERED:
for com in PLAYER_ENTERED:
if com==command.lower():
self.protocol.irc_say(PLAYER_ENTERED[com].format(player = self.name,parameters = " ".join(parameters)))
elif PLAYER_ENTERED_COMMAND:
self.protocol.irc_say(PLAYER_ENTERED_COMMAND.format(player = self.name,command = command,parameters = " ".join(parameters)))
return connection.on_command(self,command,parameters)
class IRCPublishProtocol(protocol):
pass
return IRCPublishProtocol,IRCPublishConnection