コード例 #1
0
ファイル: players.py プロジェクト: carriercomm/mudsling
    def run(self, this, actor, args):
        """
        @type this: L{mudslingcore.objects.Player}
        @type actor: L{mudslingcore.objects.Player}
        @type args: C{dict}
        """
        what = args['what']

        if self.switches['ip']:
            existing = bans.find_bans(ban_type=bans.IPBan, ip_pattern=what,
                                      is_active=True)
        else:
            existing = bans.find_bans(ban_type=bans.PlayerBan, player=what,
                                      is_active=True)
        if existing:
            if len(existing) > 1:
                actor.tell('{m', what, "{y already has multiple bans!")
            else:
                expires = existing[0].expires
                if expires is None:
                    actor.tell('{m', what, "{y is already banned forever.")
                    return
                actor.tell('{m', what, "{y is already banned until {c",
                           utils.time.format_timestamp(expires, 'long'))
            prompt = "{yAre you sure you want to impose an additional ban?"
            actor.prompt_yes_no(prompt,
                                yes_callback=self._prompt_for_ban,
                                no_callback=self._ban_abort)
        else:
            self._prompt_for_ban()
コード例 #2
0
ファイル: players.py プロジェクト: joshbenner/mudsling
    def run(self, this, actor, args):
        """
        @type this: L{mudslingcore.objects.Player}
        @type actor: L{mudslingcore.objects.Player}
        @type args: C{dict}
        """
        what = args['what']

        if self.switches['ip']:
            existing = bans.find_bans(ban_type=bans.IPBan,
                                      ip_pattern=what,
                                      is_active=True)
        else:
            existing = bans.find_bans(ban_type=bans.PlayerBan,
                                      player=what,
                                      is_active=True)
        if existing:
            if len(existing) > 1:
                actor.tell('{m', what, "{y already has multiple bans!")
            else:
                expires = existing[0].expires
                if expires is None:
                    actor.tell('{m', what, "{y is already banned forever.")
                    return
                actor.tell('{m', what, "{y is already banned until {c",
                           utils.time.format_timestamp(expires, 'long'))
            prompt = "{yAre you sure you want to impose an additional ban?"
            actor.prompt_yes_no(prompt,
                                yes_callback=self._prompt_for_ban,
                                no_callback=self._ban_abort)
        else:
            self._prompt_for_ban()
コード例 #3
0
ファイル: players.py プロジェクト: carriercomm/mudsling
 def _do_unban(self):
     what = self.parsed_args['what']
     ban_type = bans.IPBan if self.switches['ip'] else bans.PlayerBan
     attr = 'ip_pattern' if self.switches['ip'] else 'player'
     kwargs = {'ban_type': ban_type, attr: what, 'is_active': True}
     bans_to_expire = bans.find_bans(**kwargs)
     now = time.time()
     for ban in bans_to_expire:
         ban.expires = now
     self.actor.tell("{c", len(bans_to_expire), "{g ",
                     'IP' if self.switches['ip'] else 'player',
                     " bans for {m", what, "{g have been manually expired.")
コード例 #4
0
ファイル: players.py プロジェクト: joshbenner/mudsling
 def _do_unban(self):
     what = self.parsed_args['what']
     ban_type = bans.IPBan if self.switches['ip'] else bans.PlayerBan
     attr = 'ip_pattern' if self.switches['ip'] else 'player'
     kwargs = {'ban_type': ban_type, attr: what, 'is_active': True}
     bans_to_expire = bans.find_bans(**kwargs)
     now = time.time()
     for ban in bans_to_expire:
         ban.expires = now
     self.actor.tell("{c", len(bans_to_expire), "{g ",
                     'IP' if self.switches['ip'] else 'player',
                     " bans for {m", what, "{g have been manually expired.")
コード例 #5
0
ファイル: players.py プロジェクト: carriercomm/mudsling
 def run(self, this, actor, args):
     active_bans = bans.find_bans(is_active=True)
     if len(active_bans):
         table = ui.Table([
             ui.Column('Type', data_key='type', align='l'),
             ui.Column('Target', align='l',
                       cell_formatter=self.format_target),
             ui.Column('Expiration', data_key='expires', align='l',
                       cell_formatter=self.format_expiration),
             ui.Column('Reason', data_key='reason', align='l')
         ])
         table.add_rows(*active_bans)
         actor.msg(ui.report('Active Bans', table))
     else:
         actor.tell("{yThere are currently no active bans.")
コード例 #6
0
ファイル: players.py プロジェクト: joshbenner/mudsling
 def run(self, this, actor, args):
     active_bans = bans.find_bans(is_active=True)
     if len(active_bans):
         table = ui.Table([
             ui.Column('Type', data_key='type', align='l'),
             ui.Column('Target',
                       align='l',
                       cell_formatter=self.format_target),
             ui.Column('Expiration',
                       data_key='expires',
                       align='l',
                       cell_formatter=self.format_expiration),
             ui.Column('Reason', data_key='reason', align='l')
         ])
         table.add_rows(*active_bans)
         actor.msg(ui.report('Active Bans', table))
     else:
         actor.tell("{yThere are currently no active bans.")