[SCRIPT] ircpublish

Intended for use on live public servers.
3 posts Page 1 of 1 First unread post
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 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
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
Attachments
ircpublish.py
(3.67 KiB) Downloaded 265 times
Last edited by thepolm3 on Mon Jan 19, 2015 4:25 pm, edited 3 times in total.
StarDust
League Participant
League Participant
Posts: 205
Joined: Sun Nov 11, 2012 12:37 pm


nice script, thanks polm

"PLAYER_LOGS_IN = False #given player and login" why ?
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


Updated to allow admins to toggle it with "/ircpublish"
3 posts Page 1 of 1 First unread post
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 1 guest