Add /ignore Command

The original, free Ace of Spades game powered by the Voxlap engine. Known as “Classic,” 0.75, 0.76, and all 0.x versions. Created by Ben Aksoy.
22 posts Page 2 of 2 First unread post
White Hot
Deuced Up
Posts: 360
Joined: Tue Nov 06, 2012 1:33 am


mr.f wrote:

Hmm.. I'll have to make some modifications...

EDIT:
Code: Select all
"""
  O
 /|\/
/ |
  /\
 /  \

ignore.py
Adds the ability to 'ignore' certain players (all their chats will not be
received).  Use the command again to unignore.  No arguments returns the list
of people you're currently ignoring.

Author: mr.f
"""

from pyspades import contained as loaders
from functools import partial
from twisted.internet import reactor

from commands import add, get_player

S_IGNORE = "You're now ignoring {player}"
S_UNIGNORE = "You've unignored {player}"
S_IGNORED = "{player} is ignoring you"
S_IGNORE_LIST = "You're currently ignoring: "

NOTIFY_IGNORED_PLAYER = True
ANON_NOTIFICATION = True

def ignore(connection, player = None):

    #no args tells you everyone you're ingoring
    if player is None:
        return S_IGNORE_LIST  + ", ".join(connection.ignoreList)
    
    player = get_player(connection.protocol, player)
##    if player is connection: return

    #optionally notify ignored player
    name = "Anon" if ANON_NOTIFICATION else connection.name
    if NOTIFY_IGNORED_PLAYER:
        player.send_chat(S_IGNORED.format(player = name))

    if connection.add_ignore(player.name):
        return S_IGNORE.format(player = player.name)
    
    return S_UNIGNORE.format(player = player.name)

add(ignore)

def apply_script(protocol, connection, config):
    
    class IgnoreConnection(connection):

        def __init__(self, *arg, **kw):
            connection.__init__(self, *arg, **kw)
            self.ignoreList = [] #names of people this player is ignoring
        
        def add_ignore(self, player_name):
            if player_name not in self.ignoreList:
                self.ignoreList.append(player_name)
                return True
            
            self.ignoreList.remove(player_name)
            return False

                
    class IgnoreProtocol(protocol):

        def can_hear(self, target,chatter):
            return chatter.name not in target.ignoreList

        #copied from BaseProtocol
        def send_contained(self, contained, unsequenced = False, sender = None,
                    team = None, save = False, rule = None):

            if contained.id == loaders.ChatMessage.id:
                chatter = self.players[contained.player_id]
                rule = partial(self.can_hear, chatter)

            protocol.send_contained(self,contained,unsequenced,sender,
                                    team,save,rule)
                
    return IgnoreProtocol, IgnoreConnection
There. Now fully posable. Blue_Tongue
You my friend are a genius.
rakiru
Coder
Coder
Posts: 1349
Joined: Sun Nov 11, 2012 12:26 pm


White Hot wrote:
No, Rakiru, he said it's not posable. He's right, you can't really make a script pose. Green_Wink1
Oh, my bad, so he did...

Also, rakiru, not Rakiru.
AlMualim
League Participant
League Participant
Posts: 47
Joined: Thu Nov 22, 2012 9:25 pm


rakiru wrote:
White Hot wrote:
No, Rakiru, he said it's not posable. He's right, you can't really make a script pose. Green_Wink1
Oh, my bad, so he did...

Also, rakiru, not Rakiru.
What's the problem if people call you Rakiru instead of rakiru?
I don't want to be harsh, but that seems cocky.
rakiru
Coder
Coder
Posts: 1349
Joined: Sun Nov 11, 2012 12:26 pm


AlMualim wrote:
rakiru wrote:
White Hot wrote:
No, Rakiru, he said it's not posable. He's right, you can't really make a script pose. Green_Wink1
Oh, my bad, so he did...

Also, rakiru, not Rakiru.
What's the problem if people call you Rakiru instead of rakiru?
I don't want to be harsh, but that seems cocky.
How the fuck does that seem cocky? My name is rakiru, so I'd prefer people spelled it that way - simple!
AlMualim
League Participant
League Participant
Posts: 47
Joined: Thu Nov 22, 2012 9:25 pm


people say Rakiru because they want to be nice with you. but it's your call.
White Hot
Deuced Up
Posts: 360
Joined: Tue Nov 06, 2012 1:33 am


It's not a problem, his name is rakiru, that's what I should have called him.
MKU
Artist
Artist
Posts: 383
Joined: Wed Oct 31, 2012 12:20 am


AlMualim wrote:
rakiru wrote:
White Hot wrote:
No, Rakiru, he said it's not posable. He's right, you can't really make a script pose. Green_Wink1
Oh, my bad, so he did...

Also, rakiru, not Rakiru.
What's the problem if people call you Rakiru instead of rakiru?
I don't want to be harsh, but that seems cocky.
Yeah rAkIrU, quit being so god damn cocky. Do you wake up in the morning and have a nice big bowl of cocky-o's? Do you go on youtube and watch Tay Zonday's Cockylate Rain? aLmUALIM, if you are going to attempt to be an asshole, you should probably do it well.
jdrew wrote:
I don't think it is needed because most people never PM anyone let alone spam there PMs.
Holy shit, Jdrew. Do you ever post anything critically constructive? It's just a damn suggestion. At least people come up with their own ideas, Jdrew, opposed to you stealing other's ideas like in the past.
22 posts Page 2 of 2 First unread post
Return to “Ace of Spades 0.x Discussion”

Who is online

Users browsing this forum: No registered users and 20 guests