Example #1
0
class ChanAddCmd(Command):
    """
    @chanadd <channel>=<alias>

    Adds a channel to your personal channel aliases.
    """
    aliases = ('@chanadd', '@addchan')
    syntax = '<channel> {=} <alias>'
    arg_parsers = {
        'channel': MatchDescendants(cls=Channel,
                                    search_for='channel',
                                    show=True)
    }
    lock = locks.all_pass

    def run(self, this, actor, args):
        """
        :type this: mudslingcore.channels.ChannelUser
        :type actor: mudslingcore.channels.ChannelUser
        :type args: dict
        """
        try:
            actor.add_channel(args['channel'], args['alias'])
        except (ValueError, errors.AccessDenied) as e:
            actor.msg('{y' + e.message)
Example #2
0
 def __init__(self, *args, **kwargs):
     # Avoid circular reference issues.
     self.arg_parsers = {
         'player':
         MatchDescendants(cls=ChannelUser, search_for='player', show=True),
     }
     super(ChannelUninviteCmd, self).__init__(*args, **kwargs)
Example #3
0
class PageCmd(Command):
    """
    page <player>=<message>
    """
    aliases = ('page', '@page', 'p', '@p')
    # Using {=} instead of just = allows the equals to work with no spaces.
    syntax = '<player> {=} <message>'
    arg_parsers = {
        'player': MatchDescendants(cls=BasePlayer,
                                   search_for='player',
                                   show=True)
    }
    lock = locks.all_pass

    def run(self, this, actor, args):
        """
        @type this: mudslingcore.objects.Player
        @type actor: mudslingcore.objects.Player
        @type args: dict
        """
        msg = args['message']
        recipient = args['player']
        if msg.startswith(':'):
            msg = msg[1:]
            if msg.startswith(':'):
                msg = msg[1:]
                send = [actor, msg]
            else:
                send = [actor, ' ', msg]
            echo = ['{YTo ', recipient, ': ']
            echo.extend(send)
            send.insert(0, '{yFrom afar, ')
        else:
            send = ['{y', actor, ' pages, "', msg, '".']
            echo = ['{YYou page ', recipient, ' with, "', msg, '".']
        actor.tell(*echo)
        recipient.tell(*send)
Example #4
0
class ChanDelCmd(Command):
    """
    @chandel <channel>

    Deletes a channel.
    """
    aliases = ('@chandel', '@delchan')
    syntax = '<channel>'
    arg_parsers = {
        'channel': MatchDescendants(cls=Channel,
                                    search_for='channel',
                                    show=True)
    }
    lock = 'perm(delete channels)'

    def run(self, this, actor, args):
        """
        :type this: mudslingcore.channels.ChannelUser
        :type actor: mudslingcore.channels.ChannelUser
        :type args: dict
        """
        name = actor.name_for(args['channel'])
        args['channel'].delete()
        actor.tell('{c', name, '{r deleted.')