예제 #1
0
def parse(commands):

    _command = commands[0]

    if _command == 'help':  # Done
        command.help()
    elif _command == 'add':  # Done
        command.add(commands[1:])
    elif _command == 'display':  # All done
        # TODO: Date
        # sort [date|cost]
        command.display()
    elif _command == 'delete':  # Done
        command.delete(commands[1])
    elif _command == 'find':  # TODO
        if len(commands) == 1:
            print('please enter criteria')
            return True

        command.find(commands[1:])
    elif _command == 'clear':
        command.clear()
    elif _command == 'quit':  # Done
        command.quit()
        return False

    return True
예제 #2
0
def main(argv=sys.argv[1:]):

    args = parser.parse_args(argv)

    if args.command == 'add':
        add(args.paths)
    elif args.command == 'cat-file':
        try:
            cat_file(args.mode, args.hash_prefix)
        except ValueError as error:
            print(error, file=sys.stderr)
            sys.exit(1)
    elif args.command == 'commit':
        commit(args.message, author=args.author)
    elif args.command == 'diff':
        diff()
    elif args.command == 'hash-object':
        sha1 = hash_object(read_file(args.path), args.type, write=args.write)
        print(sha1)
    elif args.command == 'init':
        init(args.repo)
    elif args.command == 'ls-files':
        ls_files(details=args.stage)
    elif args.command == 'push':
        push(args.git_url, username=args.username, password=args.password)
    elif args.command == 'status':
        status()
    else:
        assert False, 'unexpected command {!r}'.format(args.command)
예제 #3
0
def menu():
	try:
		menu_print()
		user_input = input('\033[47m' + 'Please choose: ')
		if int(user_input) == 1:
			commands.lists(store.load())

		elif int(user_input) == 2:
			commands.add(store.load())
			commands.lists(store.load())

		elif int(user_input) == 3:
			commands.lists(store.load())
			commands.complete(store.load())

		elif int(user_input) == 4:
			commands.lists(store.load())
			commands.removes(store.load())

		elif int(user_input) == 5:
			commands.remove_completed(store.load())

		elif int(user_input) == 6:
			exit()
		else:
			print('\n' + '\033[31m' + 'Wrong input!\n')

	except ValueError:
		print('\n' + '\033[31m' + 'Please only enter numbers!\n')
		menu()
예제 #4
0
 def on_message(self, message):
     # print('message received:  %s' % message)
     [command, args] = message.rstrip().split(' ', 1)
     # print(tokens)
     if command == 'get':
         if args == 'full_json':
             commands.remote_lost_link_predict()
             dict_mirror = {}
             root.setBool("main_magic", True)
             props_json.buildDict(dict_mirror, root)
             self.write_message(
                 json.dumps(
                     dict_mirror, separators=(',', ':'), sort_keys=True) +
                 '\r\n')
     elif command == 'send':
         # request relay 'args' string up to aircraft
         commands.add(str(args))
     elif command == 'projects_get':
         print("request for list of all projects")
         json_str = projects.load()
         print('project json:', json_str)
         self.write_message(json_str + '\r\n')
     elif command == 'projects_update':
         projects.update_name(args)
     elif command == 'projects_delete':
         projects.delete_name(args)
예제 #5
0
def _main(args, config, timesheet):
    if args['add']:
        add(args, config, timesheet)
    if args['show']:
        show(args, timesheet)
    if args['reauth']:
        reauth(config)
    if args['delete']:
        delete(args, timesheet)
예제 #6
0
파일: console.py 프로젝트: miimbles/Sow
def _main(args, config, timesheet):
    if args['add']:
        add(args, config, timesheet)
    if args['show']:
        show(args, timesheet)
    if args['reauth']:
        reauth(config)
    if args['delete']:
        delete(args, timesheet)
예제 #7
0
def command_caller(command_list):
    if(command_list[0] == 'add'):
        commands.add()
        #print('Process raw now ? enter y to process, press any other key to skip > ',end = '')
        #select = input()
        #if(select == 'y'):
        command_caller(['rawpro'])
    elif(command_list[0] == 'rawpro'):
        commands.raw_process()
        print('-----------------------------')
        commands.show('todo')
    elif(command_list[0] == 'show'):
        if(len(command_list) == 1):
            commands.show('todo')
            return None
        commands.show(command_list[1].strip())
    elif(command_list[0] == 'todo'):
        commands.show('todo')
    elif(command_list[0] == 'ls'):
        commands.show('todo')
    elif(command_list[0] == 'done'):
        if(len(command_list) == 1):
            print('Usage: done [id]')
            return None
        print(commands.done(command_list[1].strip()))
        print('-----------------------------')
        commands.show('todo')
    elif(command_list[0] == 'repeatgen'):
        commands.repeatgen()
    elif(command_list[0] == 'clear'):
        os.system('clear')
    elif(command_list[0] == 'pp' or command_list[0] == 'postpone'):
        if(len(command_list) == 3):
            print(commands.postpone(command_list[1].strip(),command_list[2].strip()))
        else:
            content = call_vim_single_line('Enter target date')
            print(commands.postpone(command_list[1].strip(),content))
        commands.show('todo')
    elif(command_list[0] == 'cancel'):
        print(commands.cancel(command_list[1].strip()))
        commands.show('todo')
    elif(command_list[0] == 'editrep' or command_list[0] == 'editrepeat' or command_list[0] == 'editrp'):
        commands.repeat_edit()
        commands.repeatgen()
    elif(command_list[0] == 'addto' or command_list[0] == 'addchild'):
        commands.add_child()
        commands.show('todo')
    else:
        print('command not found: ' + command_list[0])
        commands.show('todo')
예제 #8
0
def keyadd():
    data = json.loads(request.body.read())
    user = data['user']
    host = data['host']
    port = data['port']
    keylist = data['keylist']
    info = commands.add(user, host, port, keylist)
    return info
예제 #9
0
def keyadd():
    data = json.loads(request.body.read())
    user = data['user']
    host = data['host']
    port = data['port']
    keylist = data['keylist']
    info = commands.add(user,host,port,keylist)
    return info
예제 #10
0
파일: app.py 프로젝트: Marius-prog/myCalc
def get_result(id):
    record = get_from_database(id)
    if record.operation == "add":
        result = add(1, 5)
    elif record.operation == "subtract":
        result = subtract(1, 2)
    elif record.operation == "multiply":
        result = multiply(1, 2)
    else:
        result = divide(1, 2)
    return render_template('app.html', record=record, result=result)
예제 #11
0
파일: afk.py 프로젝트: iamgreaser/pycubed
    to_kick.sort(key = lambda conn: conn.name is None)
    amount = amount or len(to_kick)
    kicks = 0
    for conn in to_kick[:amount]:
        if conn.name:
            conn.afk_kick()
            kicks += 1
        else:
            conn.disconnect()
    message = S_AFK_KICKED.format(num_players = kicks,
        num_connections = amount - kicks, time = minutes_s)
    protocol.irc_say('* ' + message)
    if connection in protocol.players:
        return message

add(afk)
add(kick_afk)

def apply_script(protocol, connection, config):
    time_limit = config.get('afk_time_limit', None)
    time_limit = time_limit and time_limit * 60.0
    
    class AFKConnection(connection):
        afk_kick_call = None
        last_activity = None
        
        def afk_kick(self):
            if self.name:
                time_inactive = reactor.seconds() - self.last_activity
                time_inactive = max(1.0, round(time_inactive / 60.0)) * 60.0
                elapsed = prettify_timespan(time_inactive)
예제 #12
0
                    connection.send_chat("You are no longer analyzing %s." %
                                         (person.name))
                    print person.shots_analyzed_by
            if connection.name not in player.shots_analyzed_by:
                connection.send_chat("You are now analyzing %s." %
                                     (player.name))
                player.shots_analyzed_by.append(connection.name)
                connection.hs, connection.bs, connection.ls = 0, 0, 0
                print player.shots_analyzed_by
            elif connection.name in player.shots_analyzed_by:
                connection.send_chat("You are no longer analyzing anyone.")
                player.shots_analyzed_by.remove(connection.name)
                print player.shots_analyzed_by


add(analyze_shot)


def apply_script(protocol, connection, config):
    class analyze_shotsConnection(connection):
        dist = ""
        weap = ""
        shots_analyzed_by = []
        local_variable = []
        hs, bs, ls = 0, 0, 0
        prev_time = None
        illegal_dt_count = 0
        spread_hs_count, spread_bs_count, spread_ls_count = 0, 0, 0
        spread_hit_amount, spread_hit_player = None, None

        def on_hit(self, hit_amount, hit_player, type, grenade):
예제 #13
0
import commands

X_COORDS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
Y_COORDS = ['1', '2', '3', '4', '5', '6', '7', '8']

MAP_SQUARE_SIZE = 64

def getSquareByCoordinates(coords):
    x, y, z = coords
    return X_COORDS[int(x / MAP_SQUARE_SIZE)] + Y_COORDS[int(y / MAP_SQUARE_SIZE)]

@commands.alias('w')
def whereintel(connection):
    enemy_flag = connection.team.other.flag
    player_with_flag = enemy_flag.player
    if player_with_flag is None:
        connection.send_chat("%s intel isn't hold by somebody. It is in %s" % (connection.team.other.name, getSquareByCoordinates((enemy_flag.x, enemy_flag.y, enemy_flag.z))))
    else:
        connection.send_chat("%s intel is hold by %s in %s" % (connection.team.other.name, player_with_flag.name, getSquareByCoordinates(player_with_flag.get_location())))
commands.add(whereintel)

def apply_script(protocol, connection, config):
    return protocol, connection
예제 #14
0
        message += s + ' %s teammates in the last %s' % (teamkills, minutes_s)
    if switch_sentence or teamkills > 0:
        message += '.'
    votekick = getattr(protocol, 'votekick', None)
    if (votekick and votekick.victim is player and
        votekick.victim.world_object and votekick.instigator.world_object):
        instigator = votekick.instigator
        tiles = int(distance_3d_vector(player.world_object.position,
            instigator.world_object.position))
        instigator_name = (('\x0303' if instigator.team.id else '\x0302') +
            instigator.name + '\x0f')
        message += (' %s is %d tiles away from %s, who started the votekick.' %
            (player_name, tiles, instigator_name))
    return message

add(grief_check)

def griefalert(self):
    player = self
    time = seconds() - AUTO_GC_TIME * 60
    blocks_removed = player.blocks_removed or []
    blocks = [b[1] for b in blocks_removed if b[0] >= time]
    player_name = player.name
    infos = set(blocks)
    infos.discard(None)
    namecheck = [[name, team, 0] for name, team in infos]
    
    if len(namecheck) > 0:
        for f in range(len(namecheck)):
            for i in range(len(blocks_removed)):
                if blocks_removed[i][1] is not None:
예제 #15
0
    player = get_player(protocol, player)

    if lang is None:
        if player.language_detected:
            lang = player.language_pair[:2]
            return S_LANGUAGE.format(player=player.name, lang=lang)
        else:
            return S_NOT_DETECTED_YET.format(player=player.name)
    else:
        player.language_detected = True
        player.language_pair = lang + '|en'
        player.translating = lang != 'en'
        return S_LANGUAGE_SET.format(player=player.name, lang=lang)


add(toggle_translate)
add(language)

# stats from shams, 2012 jul 02
# vowel to consonant ratios from 4708 chat lines
# discarded outliers at 88%
# min 0.0133 max 1.5556 avg 0.6509 stddev 0.2508 - 4199 samples

TRANSLATE_BASE_URL = 'http://mymemory.translated.net/api/get?'
DETECT_BASE_URL = 'http://ws.detectlanguage.com/0.2/detect?'
VC_RATIO_MIN = 0.14
VC_RATIO_MAX = 3.0
BIG_LANGUAGE_MULTIPLIERS = {
    'xxx': 0.0,
    'en': 10.0,
    'pl': 6.0,
예제 #16
0
import random

import commands

DISCO_ON_GAME_END = False
# Time is in seconds
DISCO_ON_GAME_END_DURATION = 10.0


@commands.name("disco")
@commands.admin
def toggle_disco(connection):
    connection.protocol.toggle_disco(True)


commands.add(toggle_disco)

DISCO_COLORS = set([(235, 64, 0), (128, 232, 121), (220, 223, 12), (43, 72, 228), (216, 94, 231), (255, 255, 255)])


def apply_script(protocol, connection, config):
    class DiscoProtocol(protocol):
        current_colors = None
        disco = False
        old_fog_color = None

        def __init__(self, *arg, **kw):
            protocol.__init__(self, *arg, **kw)
            self.disco_loop = LoopingCall(self.update_color)

        def update_color(self):
예제 #17
0
	global survival_mode
	protocol = connection.protocol
	survival_mode = not survival_mode
	if survival_mode:
		protocol.send_chat(SURVIVAL_ENABLED)
		respawnall(connection) #WORKING
	else:
		protocol.send_chat(SURVIVAL_DISABLED)
		respawnall(connection) #WORKING

@alias('ra')
@admin
def respawnall(connection):
        global respawn_
        connection.respawn_ = True
add(respawnall)
add(survival)


def apply_script(protocol, connection, config):
  
  class survivalConnection(connection):     
    
	def spawn(self):
		if survival_mode:
			self.weapon = RIFLE_WEAPON
		return connection.spawn(self)

	def on_spawn(self, pos):
		if survival_mode:
			weapon_reload.player_id = self.player_id
예제 #18
0
파일: kick.py 프로젝트: tukkek/piemod
  server.cs('spectator 1 '+name)
  bots()
  if name in KICKS:
    KICKS[name]+=1
    if not name in ANNOUNCE:
      ANNOUNCE.append(name)
      piemod.announce(name+' will be banned in '+str(BAN_GRACE_TIME)+' seconds! To save this player type: #save '+name)
      threading.Timer(BAN_GRACE_TIME, decide, [cn,p]).start()
  else:
    KICKS[name]=0
    piemod.announce(name+', be nice. Another #kick and you will be banned!')
    
def _save_(args,parameters):
  ps=server.players()
  p=nametocn(ps,args,parameters[0])
  if p==None:
    return
  name=ps[p]['name']
  if name in KICKS and not preventdouble(args):
    KICKS[name]-=1
    piemod.announce('Someone wants to save '+name+'. If you agree the player should be kicked type: #kick '+name.lower())
  
def gameover(args):
  del PREVENT[:]

import notices
notices.add(['To kickban a player type: #kick [name or prefix]'])

import commands
commands.add(globals())
예제 #19
0
from pyspades.collision import distance_3d_vector
from pyspades.server import block_action
from pyspades.constants import *
from commands import add
import random
import commands

ARMOR, DEADLY_DICE, TEAMMATE, TELEP, REGEN, POISON, NADEPL = xrange(7)


def clearpowers(connection):
    connection.intel_clear()
    return "You've sucessfully lost all your powers!"


add(clearpowers)


def power(connection, value=6):
    value = int(value)
    if value > 6:
        connection.send_chat("Type /current to see current powers")
        connection.send_chat(
            "Type /powerpref for info on setting prefered power")
        connection.send_chat(
            '2 - Good Teammate     5 - Poison Bullets     6 - Nadesplosion')
        connection.send_chat('1 - Deadly Dice       4 - Regeneration')
        connection.send_chat('0 - Armor             3 - Teleportation')
        connection.send_chat("Type /power # to read about a power:")
    elif value == ARMOR:
        connection.send_chat(
예제 #20
0
파일: irc.py 프로젝트: marek-danel/pyspades
        if alias:
            message = 'aliases %s to %s' % (unaliased_name, alias)
        else:
            message = "doesn't have an alias for %s" % unaliased_name
    else:
        aliases[unaliased_name] = value
        message = 'will alias %s to %s' % (unaliased_name, value)
    connection.me(message)

@irc
def unalias(connection):
    aliases = connection.factory.aliases
    unaliased_name = connection.unaliased_name
    if unaliased_name in aliases:
        aliases.pop(unaliased_name)
        message = 'will no longer alias %s' % unaliased_name
    else:
        message = "doesn't have an alias for %s" % unaliased_name
    connection.me(message)

@irc
def colors(connection):
    connection.colors = not connection.colors
    if connection.colors:
        return '\x0312c\x0304o\x0309l\x0308o\x0306r\x0313s \x0f\x16ON!'
    else:
        return 'colors off'

for func in (who, score, alias, unalias, colors):
    commands.add(func)
예제 #21
0
        player = get_player(protocol, player)
    elif connection in protocol.players:
        player = connection
    else:
        raise ValueError()

    player.painting = not player.painting

    message = 'now painting' if player.painting else 'no longer painting'
    player.send_chat("You're %s" % message)
    if connection is not player and connection in protocol.players:
        connection.send_chat('%s is %s' % (player.name, message))
    protocol.irc_say('* %s is %s' % (player.name, message))


add(paint)


def paint_block(protocol, player, x, y, z, color):
    if x < 0 or y < 0 or z < 0 or x >= 512 or y >= 512 or z >= 62:
        return False
    if protocol.map.get_color(x, y, z) == color:
        return False
    protocol.map.set_point(x, y, z, color)
    block_action.x = x
    block_action.y = y
    block_action.z = z
    block_action.player_id = player.player_id
    block_action.value = DESTROY_BLOCK
    protocol.send_contained(block_action, save=True)
    block_action.value = BUILD_BLOCK
예제 #22
0
        message = S_PLAYER_ENABLED if player.allow_markers else S_PLAYER_DISABLED
        message = message.format(player=player.name)
        protocol.send_chat(message, irc=True)
    else:
        protocol.allow_markers = not protocol.allow_markers
        message = S_ENABLED if protocol.allow_markers else S_DISABLED
        connection.protocol.send_chat(message, irc=True)


def markers(connection):
    if connection not in connection.protocol.players:
        raise ValueError()
    connection.send_lines(S_HELP)


add(clear)
add(toggle_markers)
add(markers)


class BaseMarker():
    name = 'Marker'
    triggers = []
    background = None
    background_class = None
    duration = None
    color = None
    random_colors = None
    team_color = False
    lines = []
    points = []
예제 #23
0
        rifle_percent = 'None'
    if player.smg_count != 0:
        smg_percent = str(int(100.0 * (float(player.smg_hits)/float(player.smg_count)))) + '%'
    else:
        smg_percent = 'None'
    if player.shotgun_count != 0:
        shotgun_percent = str(int(100.0 * (float(player.shotgun_hits)/float(player.shotgun_count)))) + '%'
    else:
        shotgun_percent = 'None'
    s = ''
    if name_info:
        s += player.name + ' ha una precisione di: '
    s += 'Rifle: %s SMG: %s Shotgun: %s.' % (rifle_percent, smg_percent, shotgun_percent)
    return s

add(accuracy)

@admin
def hackinfo(connection, name):
    player = get_player(connection.protocol, name)
    return hackinfo_player(player)

def hackinfo_player(player):
    info = "%s #%s (%s) ha una precisione di: " % (player.name, player.player_id, player.address[0])
    info += accuracy_player(player, False)
    ratio = player.ratio_kills/float(max(1,player.ratio_deaths))
    info += " Rapporto uccisioni-morti di %.2f (%s uccisioni, %s morti)." % (ratio, player.ratio_kills, player.ratio_deaths)
    info += " %i uccisioni negli ultimi %i secondi." % (player.get_kill_count(), KILL_TIME)
    info += " %i headshot colpi secchi negli ultimi %i secondi." % (player.get_headshot_snap_count(), HEADSHOT_SNAP_TIME)
    return info
예제 #24
0
"""
List all players in a server.
Copyright (c) 2013 learn_more
See the file license.txt or http://opensource.org/licenses/MIT for copying permission.
"""

from commands import add, admin

@admin
def players(connection):
	fmt = '#%-2s  %-20s %s%s\n'
	protocol = connection.protocol
	message = fmt % ('id', 'Name', 'ip', ' (rights)')
	for player in protocol.players.values():
		usrt = ', '.join(player.user_types)
		if len(usrt):
			usrt = ' (' + usrt + ')'
		message += fmt % (player.player_id, player.name, player.address[0], usrt)
	return message

def apply_script(protocol, connection, config):
	return protocol, connection

add(players)
예제 #25
0
"""
Saves current map on shutdown (and optionally loads it again on startup)
/savemap manually saves the map in the format of  <mapname>.manual.<time>.vxl
new config.txt options: 
    "autosave_interval" : <minutes, 0 to disable>
    "autosave_max" : <maximum autosaves, old ones are deleted>
Maintainer: mat^2
(modified by infoguluch)
"""
import commands
from twisted.internet import reactor
from pyspades.vxl import VXLData
from twisted.internet.task import LoopingCall
from time import gmtime, strftime
from commands import add, admin
from glob import glob
import os
def get_name(map, type = 'saved', time = False):
    return './maps/%s.%s%s.vxl' % (map.rot_info.name, type, strftime(".%Y%m%d.%H%M%S", gmtime()) if time else '')
def save_map(map, name):
    open(name, 'wb').write(map.generate())
@admin
def savemap(connection):
    connection.send_chat('Saving map...')
    save_map(connection.protocol.map, get_name(connection.protocol.map_info, 'manual', True))
    return 'Map saved'
add(savemap)
def apply_script(protocol, connection, config):
    class MapSaveProtocol(protocol):
        def __init__(self, *arg, **kw):
예제 #26
0
파일: squad.py 프로젝트: NickBurrill/PiSnip
        result.append(("To join squads: /squad <squad name>. " + "/squad none to spawn normally."))
        self.send_lines(result)
        return

    if squadkey.lower() == "none":
        squad = None
        squad_pref = None
    else:
        squad = squadkey
        squad_pref = None

    return self.join_squad(squad, squad_pref)


for func in (squad, follow):
    add(func)


def apply_script(protocol, connection, config):
    protocol.squad_respawn_time = config.get("squad_respawn_time", protocol.respawn_time)
    protocol.squad_size = config.get("squad_size", 0)
    protocol.auto_squad = config.get("auto_squad", True)

    class SquadConnection(connection):
        squad = None
        squad_pref = None

        def on_login(self, name):
            if self.protocol.auto_squad:
                self.join_squad(self.find_auto_squad(), None)
            return connection.on_login(self, name)
예제 #27
0
import commands
from commands import add, admin
import json

@admin
def reloadconfig(connection):
    new_config = {}
    try:
        new_config = json.load(open('config.txt', 'r'))
        if not isinstance(new_config, dict):
            raise ValueError('config.txt is not a mapping type')
    except ValueError, v:
        print 'Error reloading config:', v
        return 'Error reloading config. Check pyspades log for details.'
    connection.protocol.config.update(new_config)
    connection.protocol.reload_passes()
    return 'Config reloaded!'

add(reloadconfig)

def apply_script(protocol, connection, config):
    class PassreloadProtocol(protocol):
        def reload_passes(self):
            self.passwords = config.get('passwords', {})
            for password in self.passwords.get('admin', []):
                if password == 'replaceme':
                    print 'REMEMBER TO CHANGE THE DEFAULT ADMINISTRATOR PASSWORD!'
                elif not password:
                    self.everyone_is_admin = True
            commands.rights.update(config.get('rights', {}))
    return PassreloadProtocol, connection
예제 #28
0
    else:
        connection.block_inspect = False
        return "No longer inspecting blocks."


@admin
def blocklog(connection):
    if not connection.protocol.block_log:
        connection.protocol.block_log = True
        return "Block removal logging enabled."
    else:
        connection.protocol.block_log = False
        return "Block removal logging disabled."


add(inspect)
add(blocklog)


def log_block_removal(self, x, y, z):
    f = open("logs/block_removal.log", "a")
    self.blockposition.x = x
    self.blockposition.y = y
    self.blockposition.z = z
    distance = int(distance_3d_vector(self.world_object.position, self.blockposition))
    sep = ";"
    info = (self.name + sep + str(self.player_id) + sep + str(self.team.id) + sep +
            str(self.tool) + sep + str(self.weapon) + sep +
            str((int(self.world_object.position.x),
                 int(self.world_object.position.y),
                 int(self.world_object.position.z))) +
예제 #29
0
파일: db.py 프로젝트: mrpizza123/pysnip
from pyspades.constants import *
from feature_server.scripts.cbc import *
import commands


@admin
def db(connection):
    if connection.deboxing > 0:
        connection.deboxing = 0
        return 'DeBox cancelled'
    else:
        connection.deboxing = 1
        return 'Break first corner block'


add(db)


def apply_script(protocol, connection, config):
    class ClearBoxMakerConnection(connection):
        deboxing = 0
        clearbox_x = 0
        clearbox_y = 0
        clearbox_z = 0

        def clear_box_solid_generator(self, x1, y1, z1, x2, y2, z2):
            block_action = BlockAction()
            block_action.value = DESTROY_BLOCK
            block_action.player_id = self.player_id
            protocol = self.protocol
            check_protected = hasattr(protocol, 'protected')
예제 #30
0
@name('nogunall')
@admin
def no_gun_all(connection):
    protocol = connection.protocol
    
    for player in protocol.players.itervalues():
        empty_weapon(player)
        player.send_chat(S_NO_GUN_SELF)
    
    message = S_NO_GUN_ALL.format(admin = connection.name)
    protocol.irc_say(message)

for func in (hacktools, ahead, inspect, no_gun, no_gun_all, toggle_spy,
    invisible, toggle_headshot, toggle_pause):
    add(func)

def pausable(func):
    def new_func(self, *arg, **kw):
        if self._paused:
            return False
        return func(self, *arg, **kw)
    return new_func

def apply_script(protocol, connection, config):
    class HackToolsConnection(connection):
        headshots = True
        tracked_by = None
        spy = False
        pause_loop = None
        _paused = False
예제 #31
0
import commands

# requires db.py


@admin
def df(connection):
    if connection.deflooring > 0:
        connection.deflooring = 0
        return "DeFloor cancelled"
    else:
        connection.deflooring = 1
        return "Break first corner block"


add(df)


def apply_script(protocol, connection, config):
    class clearfloorMakerConnection(connection):
        deflooring = 0
        clearfloor_x = 0
        clearfloor_y = 0
        clearfloor_z = 0

        def on_block_removed(self, x, y, z):
            if self.deflooring == 2:
                self.deflooring = 0
                if self.clearfloor_z != z:
                    self.send_chat("Surface is uneven! Using first height.")
                self.clear_box_solid(self.clearfloor_x, self.clearfloor_y, self.clearfloor_z, x, y, self.clearfloor_z)
예제 #32
0

@admin
@name('toggleai')
def toggle_ai(connection):
    protocol = connection.protocol
    protocol.ai_enabled = not protocol.ai_enabled
    if not protocol.ai_enabled:
        for bot in protocol.bots:
            bot.flush_input()
    state = 'enabled' if protocol.ai_enabled else 'disabled'
    protocol.send_chat('AI %s!' % state)
    protocol.irc_say('* %s %s AI' % (connection.name, state))


add(add_bot)
add(toggle_ai)


class LocalPeer:
    #address = Address(None, 0)
    address = Address('255.255.255.255', 0)
    roundTripTime = 0.0

    def send(self, *arg, **kw):
        pass

    def reset(self):
        pass

예제 #33
0
@admin
def zspawnheight(connection, value):
    protocol = connection.protocol
    val = abs(int(value))
    if val >= 10:
        protocol.ZOMBIE_SPAWN_HEIGHT = val
        connection.send_chat(S_ZOMBIE_SPAWN % val)
    elif val < 10:
        protocol.ZOMBIE_SPAWN_HEIGHT = 0
        connection.send_chat('Disabling zombie spawning up in the air')

def zombiestat(connection):
    connection.send_chat(S_ZOMBIE_VERSION)
    connection.send_chat(S_ZOMBIE_STAT % (connection.protocol.ZOMBIE_HP, connection.protocol.ZOMBIE_TELEPORT))

add(ztel)
add(zhp)
add(zombiestat)
add(zspawnheight)

def apply_script(protocol, connection, config):
    class ZombiesProtocol(protocol):
        def __init__(self, *arg, **kw):
            protocol.__init__(self, *arg, **kw)
            self.ZOMBIE_TELEPORT = 17
            self.ZOMBIE_HP = 650
            self.ZOMBIE_SPAWN_HEIGHT = 0
    
    class ZombiesConnection(connection):
        def __init__(self, *args, **kwargs):
            self.zombies_playermode = 0
예제 #34
0
        smg_percent = 'None'
    if player.shotgun_count != 0:
        shotgun_percent = str(
            int(100.0 * (float(player.shotgun_hits) /
                         float(player.shotgun_count)))) + '%'
    else:
        shotgun_percent = 'None'
    s = ''
    if name_info:
        s += player.name + ' has an accuracy of: '
    s += 'Rifle: %s SMG: %s Shotgun: %s.' % (rifle_percent, smg_percent,
                                             shotgun_percent)
    return s


add(accuracy)


@admin
def hackinfo(connection, name):
    player = get_player(connection.protocol, name)
    return hackinfo_player(player)


def hackinfo_player(player):
    info = "%s #%s (%s) has an accuracy of: " % (player.name, player.player_id,
                                                 player.address[0])
    info += accuracy_player(player, False)
    info += " Ping: %s ms." % (player.latency)
    info += ' Weapon: %s.' % (player.weapon_object.name)
    ratio = player.ratio_kills / float(max(1, player.ratio_deaths))
예제 #35
0
파일: stats.py 프로젝트: Architektor/PySnip
Statistics script to upload scores to aos.mp2.dk (or another machine running
the site program).

Maintainer: mat^2
"""

from statistics import DEFAULT_PORT, connect_statistics

import commands

def sitelogin(connection, name, password):
    value = connection.site_login(name, password)
    connection.send_chat(value) # so it doesn't appear in the log
    return False
        
commands.add(sitelogin)

def apply_script(protocol, connection, config):
    stats_config = config.get('statistics', {})
    host = stats_config.get('host', 'localhost')
    port = stats_config.get('port', DEFAULT_PORT)
    server_name = stats_config.get('server_name', 'stats server')
    password = stats_config.get('password', '')

    class StatisticsConnection(connection):
        login_defer = None
        stats_name = None
        
        def on_kill(self, killer, type, grenade):
            if killer not in (self, None):
                if killer.stats_name is not None:
예제 #36
0
        raise KeyError()
    if not connection.protocol.votemap_player_driven and not connection.admin:
        return "Player-initiated mapvotes are disabled on this server."
    return connection.protocol.start_votemap(
        VoteMap(connection, connection.protocol, connection.protocol.maps))

@commands.name('vote')
def votemap_vote(connection, value):
    if connection not in connection.protocol.players:
        raise KeyError()
    if connection.protocol.votemap is not None:
        return connection.protocol.votemap.vote(connection, value)
    else:
        return 'No map vote in progress.'

commands.add(votemap)
commands.add(votemap_vote)

def apply_script(protocol, connection, config):
    class VoteProtocol(protocol):
        # voting
        votemap_time = 120
        votemap_interval = 3 * 60
        votemap_percentage = 80.0
        votemap = None
        planned_map = None
        autoschedule_call = None

        # voting
        
        def __init__(self, interface, config):
예제 #37
0
                del analyzers[connection.name]
                connection.send_chat("You are no longer analyzing anyone.")
            elif analyzers.has_key(connection.name) and player.name != analyzers[connection.name]:
                connection.send_chat(
                    "You are no longer analyzing %s.  You are now analyzing %s."
                    % (analyzers[connection.name], player.name)
                )
                analyzers[connection.name] = player.name
                connection.hs, connection.bs, connection.ls = 0, 0, 0
            elif not analyzers.has_key(connection.name):
                analyzers[connection.name] = player.name
                connection.send_chat("You are now analyzing %s" % (player.name))
                connection.hs, connection.bs, connection.ls = 0, 0, 0


add(analyze_shot)


def apply_script(protocol, connection, config):
    class analyze_shotsConnection(connection):
        dist = ""
        weap = ""
        analyzers = {}
        hs, bs, ls = 0, 0, 0
        prev_time = None
        body_part = ""

        def on_hit(self, hit_amount, hit_player, type, grenade):
            if self.name in analyzers.values():
                body_damage_values = [49, 29, 27]
                limb_damage_values = [33, 18, 16]
예제 #38
0
# note, needs more tweaking, also might not catch hooch's aimbot
# ultimately needs lag compensation to be effective, which it doesn't have
AIMBLOCK_KICK_JERK = False

# disable if you don't want to kick people who jerk conviniently backwards onto their targets
# -- NOT IMPLEMENTED!
AIMBLOCK_KICK_SNAP = False

def aimbotcheck(connection, user, minutes):
    connection = commands.get_player(connection.protocol, user)
    if connection not in connection.protocol.players:
        raise KeyError()
    kills = connection.tally_kill_log(reactor.seconds() - int(minutes)*60)
    return ('Il giocatore %s ha fatto %s uccisioni negli ultimi %s minuti.' %
        (connection.name, kills, minutes))
commands.add(aimbotcheck)

def apply_script(protocol, connection, config):
    def aimblock(f):
        def _f1(self, *args, **kwargs):
            if self.aimbot_detect:
                return f(self, *args, **kwargs)
        return _f1
    
    class AImBlockConnection(connection):
        aimbot_detect = True
        aimbot_heur_max = 0.92
        aimbot_heur_jerk = 0.33
        aimbot_heur_leeway = 0.9
        aimbot_heur_snap_thres = -0.1
        aimbot_heur_snap_score = 1.2
예제 #39
0
from pyspades.collision import distance_3d_vector
from commands import add, admin
from map import Map
from pyspades.constants import *
from feature_server.scripts.cbc import *
import commands

@admin
def db(connection):
        if connection.deboxing > 0:
            connection.deboxing = 0
            return 'DeBox cancelled'
        else:
            connection.deboxing = 1
            return 'Break first corner block'
add(db)

def apply_script(protocol, connection, config):
    class ClearBoxMakerConnection(connection):
        deboxing = 0
        clearbox_x = 0
        clearbox_y = 0
        clearbox_z = 0
        
        def clear_box_solid_generator(self, x1, y1, z1, x2, y2, z2):
            block_action = BlockAction()
            block_action.value = DESTROY_BLOCK
            block_action.player_id = self.player_id
            protocol = self.protocol
            check_protected = hasattr(protocol, 'protected')
            for x in xrange(min(x1 , x2) , max(x1 , x2)+1):
예제 #40
0
파일: votekick.py 프로젝트: Lwgano/pyspades
    votekick.end(S_RESULT_CANCELLED)

@name('y')
def vote_yes(connection):
    protocol = connection.protocol
    if connection not in protocol.players:
        raise KeyError()
    player = connection
    
    votekick = protocol.votekick
    if not votekick:
        return S_NO_VOTEKICK
    
    votekick.vote(player)

add(start_votekick)
add(cancel_votekick)
add(vote_yes)

class Votekick(object):
    duration = 120.0 # 2 minutes
    interval = 2 * 60.0 # 3 minutes
    ban_duration = 15.0
    public_votes = True
    schedule = None
    
    def _get_votes_remaining(self):
        return self.protocol.get_required_votes() - len(self.votes) + 1
    votes_remaining = property(_get_votes_remaining)
    
    @classmethod
예제 #41
0
        return S_NO_SCORE.format(score = SCORE_REQUIREMENT)
    elif not player.airstrike:
        kills_left = STREAK_REQUIREMENT - (player.streak % STREAK_REQUIREMENT)
        return S_NO_STREAK.format(streak = STREAK_REQUIREMENT,
            remaining = kills_left)
    try:
        coord_x, coord_y = coordinates(coords)
    except (ValueError):
        return S_BAD_COORDS
    last_airstrike = getattr(player.team, 'last_airstrike', None)
    if last_airstrike and seconds() - last_airstrike < TEAM_COOLDOWN:
        remaining = TEAM_COOLDOWN - (seconds() - last_airstrike)
        return S_COOLDOWN.format(seconds = int(ceil(remaining)))
    player.start_airstrike(coord_x, coord_y)

add(airstrike)

def apply_script(protocol, connection, config):
    class AirstrikeConnection(connection):
        airstrike = False
        airstrike_grenade_calls = None
        last_streak = None
        
        def start_airstrike(self, coord_x, coord_y):
            coords = to_coordinates(coord_x, coord_y)
            message = S_ALLIED.format(player = self.name, coords = coords)
            self.protocol.send_chat(message, global_message = False,
                team = self.team)
            message = S_ENEMY.format(coords = coords)
            self.protocol.send_chat(message, global_message = False,
                team = self.team.other)
예제 #42
0
    meleekills = connection.ratio_meleekills
    grenadekills = connection.ratio_grenadekills
    
    msg += " a kill-death ratio of %.2f" % (kills/deaths)
    if HEADSHOT_RATIO:
        msg += ", headshot-death ratio of %.2f" % (headshotkills/deaths)
    msg += " (%s kills, %s deaths" % (kills, connection.ratio_deaths)
    if EXTENDED_RATIO:
        msg += ", %s headshot, %s melee, %s grenade" % (headshotkills, meleekills, grenadekills)
    if KILLS_PER_MINUTE:
        dt = (seconds() - connection.time_login) /60
        msg += ", %.2f kills per minute" % (kills/dt)
    msg += ")."
    return msg

add(ratio)

def apply_script(protocol, connection, config):
    class RatioConnection(connection):
        ratio_kills = 0
        ratio_headshotkills = 0
        ratio_meleekills = 0
        ratio_grenadekills = 0
        ratio_deaths = 0
        time_login = 0
        
        def on_kill(self, killer, type, grenade):
            if killer is not None and self.team is not killer.team:
                if self != killer:
                    killer.ratio_kills += 1
                    killer.ratio_headshotkills += type == HEADSHOT_KILL
예제 #43
0
        return S_NO_SCORE.format(score = SCORE_REQUIREMENT)
    elif not player.airstrike:
        kills_left = STREAK_REQUIREMENT - (player.streak % STREAK_REQUIREMENT)
        return S_NO_STREAK.format(streak = STREAK_REQUIREMENT,
            remaining = kills_left)
    try:
        coord_x, coord_y = coordinates(coords)
    except (ValueError):
        return S_BAD_COORDS
    last_airstrike = getattr(player.team, 'last_airstrike', None)
    if last_airstrike and seconds() - last_airstrike < TEAM_COOLDOWN:
        remaining = TEAM_COOLDOWN - (seconds() - last_airstrike)
        return S_COOLDOWN.format(seconds = int(ceil(remaining)))
    player.start_airstrike(coord_x, coord_y)

add(airstrike)

def apply_script(protocol, connection, config):
    class AirstrikeConnection(connection):
        airstrike = False
        airstrike_grenade_calls = None
        last_streak = None
        
        def start_airstrike(self, coord_x, coord_y):
            coords = to_coordinates(coord_x, coord_y)
            message = S_ALLIED.format(player = self.name, coords = coords)
            self.protocol.send_chat(message, global_message = False,
                team = self.team)
            message = S_ENEMY.format(coords = coords)
            self.protocol.send_chat(message, global_message = False,
                team = self.team.other)
예제 #44
0
파일: floor.py 프로젝트: mrpizza123/pysnip
from commands import add, admin
from map import Map
from pyspades.constants import *
import commands

# requires box.py

@admin
def floor(connection):
        if connection.flooring > 0:
            connection.flooring = 0
            return 'Floor generator cancelled'
        else:
            connection.flooring = 1
            return 'Place first corner block'
add(floor)

def apply_script(protocol, connection, config):
    class floorMakerConnection(connection):
        flooring = 0
        floor_x = 0
        floor_y = 0
        floor_z = 0
        
        def on_block_build(self, x, y, z):
            if self.flooring == 2:
                self.flooring = 0
                if self.floor_z != z:
                    self.send_chat('Surface is uneven! Using first height.')
                self.build_box_filled(self.floor_x, self.floor_y, self.floor_z, x, y, self.floor_z, self.color+(255,))
            if self.flooring == 1:
예제 #45
0
파일: tdm.py 프로젝트: megastar1212/pycubed
"""
Team Deathmatch game mode.

Maintainer: Triplefox
"""

from pyspades.constants import *

import commands

def score(connection):
    return connection.protocol.get_kill_count()

commands.add(score)

def apply_script(protocol, connection, config):
    class TDMConnection(connection):
        def on_spawn(self, pos):
            self.send_chat(self.explain_game_mode())
            self.send_chat(self.protocol.get_kill_count())
            return connection.on_spawn(self, pos)

        def on_flag_capture(self):
            result = connection.on_flag_capture(self)
            self.team.kills += self.protocol.intel_points
            self.protocol.check_end_game(self)
            return result
        
        def on_kill(self, killer, type, grenade):
            result = connection.on_kill(self, killer, type, grenade)
            self.protocol.check_end_game(killer)
예제 #46
0
    reason = join_arguments(args[0:]) # Convert reason args into one string
    if player not in protocol.players:
        raise ValueError() # If player doesn't exist, raise error
    else:
        if player.jailed:
            return 'Player ' + player.name + ' is already jailed!' # Player is already jailed!
        elif not player.jailed:
            player.jailed = True # Set player to jailed
            player.reason = reason
            player.squad  = None
            player.squad_pref = None
            player.set_location(jail_location) # Move player to jail
            connection.protocol.send_chat("%s was sent to jail by %s for reason(s): %s" % (player.name, connection.name, reason)) # Message
            connection.protocol.irc_say("* %s jailed %s for reason: %s" % (connection.name, player.name, reason)) # Message
            jail_list.append(player.name)
add(jail_player) # Add command

@name('jailed')
def is_jailed(connection, value = None):
    if value is None:
        if not jail_list:
            return 'No jailed players.'
        else:
            return "Jailed players: " + ", ".join(jail_list)
    elif value is not None:
        protocol = connection.protocol
        player = get_player(protocol, value)
        if player not in protocol.players:
            raise ValueError()
        else:
            if player.jailed:
예제 #47
0
파일: ratio.py 프로젝트: mrpizza123/pysnip
    msg += " a kill-death ratio of %.2f" % (kills / deaths)
    if HEADSHOT_RATIO:
        msg += ", headshot-death ratio of %.2f" % (headshotkills / deaths)
    msg += " (%s kills, %s deaths" % (kills, connection.ratio_deaths)
    if EXTENDED_RATIO:
        msg += ", %s headshot, %s melee, %s grenade" % (
            headshotkills, meleekills, grenadekills)
    if KILLS_PER_MINUTE:
        dt = (seconds() - connection.time_login) / 60
        msg += ", %.2f kills per minute" % (kills / dt)
    msg += ")."
    return msg


add(ratio)


def apply_script(protocol, connection, config):
    class RatioConnection(connection):
        ratio_kills = 0
        ratio_headshotkills = 0
        ratio_meleekills = 0
        ratio_grenadekills = 0
        ratio_deaths = 0
        time_login = 0

        def on_kill(self, killer, type, grenade):
            if killer is not None and self.team is not killer.team:
                if self != killer:
                    killer.ratio_kills += 1
예제 #48
0
	return (not slur_pattern.match(msg) is None)

def grief_match(player, msg):
	return (not grief_pattern.match(msg) is None)

def aimbot_match(player, msg):
	return (not aimbot_pattern.match(msg) is None)

@admin
def badmin(connection, var=None):
    if var == None:
        return ("@Badmin (r%s): Filtro Lingua(FL) [%s], Blank Votekick Blocker(BV) "
        "[%s], Grief Votekick Protection(GV) [%s], Aimbot Votekick Protection(AV) [%s]" 
        % (BADMIN_VERSION, LANGUAGE_FILTER_ENABLED, BLANK_VOTEKICK_ENABLED, 
        SCORE_GRIEF_ENABLED, SCORE_AIMBOT_ENABLED))
add(badmin)

@admin
def investigate(connection, player):
    player = get_player(connection.protocol, player)
    score = score_grief(connection, player)
    kdr = round(player.ratio_kills/float(max(1,player.ratio_deaths)))
    percent = round(check_percent(player))
    message = "Risultati per %s: Punteggio Grief - %s / KDR - %s / Hit Acc. - %s" % (player.name, score, kdr, percent)
add(investigate)

def score_grief(connection, player, time=None): #302 = blue (0), #303 = green (1)
    print "Avvio punteggio grief"
    color = connection not in connection.protocol.players and connection.colors
    minutes = float(time or 2)
    if minutes < 0.0:
예제 #49
0
import commands
from commands import add, admin
import json

@admin
def reloadconfig(connection):
    new_config = {}
    try:
        new_config = json.load(open('config.txt', 'r'))
        if not isinstance(new_config, dict):
            raise ValueError('config.txt is not a mapping type')
    except ValueError, v:
        print 'Error reloading config:', v
        return 'Error reloading config. Check pyspades log for details.'
    connection.protocol.config.update(new_config)
    connection.protocol.reload_passes()
    return 'Config reloaded!'

add(reloadconfig)

def apply_script(protocol, connection, config):
    class PassreloadProtocol(protocol):
        def reload_passes(self):
            self.passwords = config.get('passwords', {})
            for password in self.passwords.get('admin', []):
                if password == 'replaceme':
                    print 'REMEMBER TO CHANGE THE DEFAULT ADMINISTRATOR PASSWORD!'
                elif not password:
                    self.everyone_is_admin = True
            commands.rights.update(config.get('rights', {}))
    return PassreloadProtocol, connection
예제 #50
0
    player.send_chat("You're %s" % message)
    if connection is not player and connection in protocol.players:
        connection.send_chat('%s is %s' % (player.name, message))
    protocol.irc_say('* %s is %s' % (player.name, message))


def resend_tool(player):
    set_tool.player_id = player.player_id
    set_tool.value = player.tool
    if player.weapon_object.shoot:
        player.protocol.send_contained(set_tool)
    else:
        player.send_contained(set_tool)


add(toggle_rapid)


def apply_script(protocol, connection, config):
    class RapidConnection(connection):
        rapid = False
        rapid_loop = None

        def on_login(self, name):
            self.rapid = ALWAYS_RAPID
            self.rapid_hack_detect = not self.rapid
            connection.on_login(self, name)

        def on_reset(self):
            if self.rapid_loop and self.rapid_loop.running:
                self.rapid_loop.stop()
예제 #51
0
                result = S_LOADED.format(filenames=', '.join(loaded))
            if failed:
                player.send_chat(S_FAILED.format(filenames=', '.join(failed)))
                player.send_chat(S_PIVOT_TIP)
            if models:
                player.grenade_models = models
    elif player.grenade_models:
        player.grenade_models = None
        result = S_CANCEL
    else:
        result = S_SPECIFY_FILES
    if result:
        player.send_chat(result)


add(model_grenades)

KV6Voxel = namedtuple('KV6Voxel', 'b g r a z neighbors normal_index')
NonSurfaceKV6Voxel = KV6Voxel(40, 64, 103, 128, 0, 0, 0)


class KV6Model:
    """
    Custom implementation that also generates non-surface voxels.
    Not suitable for general purpose.
    """

    size = None
    pivot = None
    voxels = None
    for username, passwd in connection.protocol.users.iteritems():
        if password == passwd:
            connection.username = username
            return connection.on_user_login(username, True)
    if connection.login_retries is None:
        connection.login_retries = connection.protocol.login_retries - 1
    else:
        connection.login_retries -= 1
    if not connection.login_retries:
        connection.kick('Ran out of login attempts')
        return
    return 'Invalid password - you have %s tries left' % (
        connection.login_retries)


commands.add(login)


def whois(connection, player):
    """
    Gets the user that a player is logged in as

    usage: \whois playername
    """
    player = commands.get_player(connection.protocol, player)
    username = player.username
    if username is None:
        message = ' is not logged in.'
    else:
        message = ' is logged in as ' + username
    return player.name + message
예제 #53
0

def mode(connection):
    msg = []
    msg.append("You are a %s. Choose a mode by typing:" %
               ("sapper" if connection.class_mode == SAPPER else "builder"))
    msg.append(
        "/builder for %s refill(s) after last block, heal teammates with spade, "
        "build grenade." % connection.block_refills_max)
    msg.append(
        "/sapper for %s ammo refill(s), less body damage, deadly grenade." %
        connection.ammo_refills_max)
    connection.send_lines(msg)


add(builder)
add(sapper)
add(mode)


def is_invalid_coord(x, y, z):
    return x < 0 or y < 0 or z < 0 or x > 511 or y > 511 or z > 61


def build_block(connection, x, y, z, color):
    if is_invalid_coord(x, y, z):
        return
    set_color = SetColor()
    set_color.value = make_color(*color)
    set_color.player_id = 32
    connection.protocol.send_contained(set_color)
예제 #54
0
파일: day.py 프로젝트: tom288/PySnip
import commands

COL_DAY = (68, 138, 255) # Blue daytime sky
COL_NIGHT = (0, 0, 0) # Black night sky
DAY_SECS = 60 * 15 # Real-life seconds per in-game day
DAY_TICKS = 1024 # Ticks per in-game day, powers of 2 avoid rounding errors

@commands.name('starttime') # Begin the day night cycle
@commands.admin
def start_time(connection):
    if (connection.protocol.day_enable):
        return ('Time is already running')
    else:
        connection.protocol.day_enable = True
        return ('Time has been started')
commands.add(start_time)

@commands.name('stoptime') # Pause the day night cycle
@commands.alias('pausetime')
@commands.admin
def stop_time(connection):
    if (connection.protocol.day_enable):
        connection.protocol.day_enable = False
        return ('Time has been stopped')
    else:
        return ('Time is already stopped')
commands.add(stop_time)

@commands.name('toggletime') # Toggle the day night cycle
@commands.admin
def toggle_time(connection):
예제 #55
0
    return 'Recording started.'

@commands.admin
@commands.name('stoprecord')
def stop_record(connection):
    connection.protocol.stop_record()
    return 'Recording stopped.'

@commands.admin
@commands.name('saverecord')
def save_record(connection, value):
    if not connection.protocol.save_record(value):
        return 'No record file available.'
    return 'Record saved.'

commands.add(start_timer)
commands.add(stop_timer)
commands.add(start_record)
commands.add(stop_record)
commands.add(save_record)

def apply_script(protocol, connection, config):
    class MatchConnection(connection):
        def on_flag_take(self):
            self.add_message("%s took %s's flag!" %
                (self.printable_name, self.team.other.name.lower()))
            return connection.on_flag_take(self)
        
        def on_flag_drop(self):
            self.add_message("%s dropped %s's flag!" %
                (self.printable_name, self.team.other.name.lower()))