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 1 of 2 First unread post
Slyph
Deuce
Posts: 2
Joined: Tue Jan 08, 2013 6:19 am


I would kindly like to ask why no one has emplimented an /ignore Command. This has been one thing I've hated about Aos, is no /ignore command.
So is it possiable to implement?

Fyi:obviously this would work well for ignore the 60% population of kids on Aos.

-Slyph
Sasquatch
Mapper
Mapper
Posts: 141
Joined: Wed Nov 14, 2012 5:18 pm


Would be nice but you would have to type a lost of people you want to ignore each game. Maybe an option on the controls file where you can add names that you can ignore?
Slyph
Deuce
Posts: 2
Joined: Tue Jan 08, 2013 6:19 am


Sasquatch wrote:
Would be nice but you would have to type a lost of people you want to ignore each game. Maybe an option on the controls file where you can add names that you can ignore?
Ya, like a text documents listing people who you ignored.
GreaseMonkey
Coder
Coder
Posts: 733
Joined: Tue Oct 30, 2012 11:07 pm


How about /ignorefrom? That would make it much easier.
Sasquatch
Mapper
Mapper
Posts: 141
Joined: Wed Nov 14, 2012 5:18 pm


GreaseMonkey wrote:
How about /ignorefrom? That would make it much easier.
elaborate
mr.f
Deuced Up
Posts: 37
Joined: Thu Jan 03, 2013 5:16 am


Slyph wrote:
Sasquatch wrote:
Would be nice but you would have to type a lost of people you want to ignore each game. Maybe an option on the controls file where you can add names that you can ignore?
Ya, like a text documents listing people who you ignored.
I don't think this is possible currently.. cause the server would need access to a client-side text document. Maybe a client-side hack would work. But I don't really know what I'm talking about haha

I did whip up a server-side script for this, but it ended up being really ugly. There was no good way to intercept the chats without making it so that no one got them. I ended up overriding send_contained.. which is bad.

Well it seems to work anyway, but someone else should probably take a look over to make sure. And maybe see if there's a better way to implement the actual ignoring part, while you're at it.
Code: Select all
"""
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

Last edited by mr.f on Tue Jan 08, 2013 9:17 pm, edited 1 time in total.
rakiru
Coder
Coder
Posts: 1349
Joined: Sun Nov 11, 2012 12:26 pm


Rather than copy-pasting send_contained and modifying it, I'd suggest checking if it's a chat packet, and if not, passing it on to the regular send_contained function.
mr.f
Deuced Up
Posts: 37
Joined: Thu Jan 03, 2013 5:16 am


Thanks for the tip. Ended up using the rule parameter for send_contained.. much cleaner now.
Jdrew
Mapper
Mapper
Posts: 4808
Joined: Tue Oct 30, 2012 10:48 pm


I don't think it is needed because most people never PM anyone let alone spam there PMs.
mr.f
Deuced Up
Posts: 37
Joined: Thu Jan 03, 2013 5:16 am


jdrew wrote:
I don't think it is needed because most people never PM anyone let alone spam there PMs.
It ignores certain people in the main chat. At least that's what I assume everyone was talking about.
Jdrew
Mapper
Mapper
Posts: 4808
Joined: Tue Oct 30, 2012 10:48 pm


mr.f wrote:
jdrew wrote:
I don't think it is needed because most people never PM anyone let alone spam there PMs.
It ignores certain people in the main chat. At least that's what I assume everyone was talking about.
Ohh I get it so like a local mute thing for chat? It probably isn't posable but maybe?
White Hot
Deuced Up
Posts: 360
Joined: Tue Nov 06, 2012 1:33 am


I think it could be possible if the script worked so that it could detect when players talked, and check who had them local muted, (locally muted?) and not display the text for them. Would probably cause chat lag though.
rakiru
Coder
Coder
Posts: 1349
Joined: Sun Nov 11, 2012 12:26 pm


jdrew wrote:
mr.f wrote:
jdrew wrote:
I don't think it is needed because most people never PM anyone let alone spam there PMs.
It ignores certain people in the main chat. At least that's what I assume everyone was talking about.
Ohh I get it so like a local mute thing for chat? It probably isn't posable but maybe?
Of course it's fucking possible. Ignoring the fact that he just wrote a script to do exactly that, the server is in complete control of who gets sent to what. Something as simple as allowing users to ignore other users is easy.
White Hot
Deuced Up
Posts: 360
Joined: Tue Nov 06, 2012 1:33 am


rakiru wrote:
jdrew wrote:

Ohh I get it so like a local mute thing for chat? It probably isn't posable but maybe?
Of course it's fucking possible. Ignoring the fact that he just wrote a script to do exactly that, the server is in complete control of who gets sent to what. Something as simple as allowing users to ignore other users is easy.
No, Rakiru, he said it's not posable. He's right, you can't really make a script pose. Green_Wink1
mr.f
Deuced Up
Posts: 37
Joined: Thu Jan 03, 2013 5:16 am


White Hot wrote:
rakiru wrote:
jdrew wrote:

Ohh I get it so like a local mute thing for chat? It probably isn't posable but maybe?
Of course it's fucking possible. Ignoring the fact that he just wrote a script to do exactly that, the server is in complete control of who gets sent to what. Something as simple as allowing users to ignore other users is easy.
No, Rakiru, he said it's not posable. He's right, you can't really make a script pose. Green_Wink1
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
22 posts Page 1 of 2 First unread post
Return to “Ace of Spades 0.x Discussion”

Who is online

Users browsing this forum: No registered users and 14 guests