def run(self, args, conn): u = user.find_by_prefix_for_user(args[0], conn) if u: if not admin.checker.check_user_operation(conn.user, u): conn.write("You need a higher adminlevel to change the email address of %s.\n" % u.name) return if u.is_guest: conn.write(A_('You can only set the email for registered players.\n')) return email = args[1] if email is None: # TODO? assert(False) else: if '@' not in email: conn.write(A_('That does not look like an email address.\n')) return old_email = u.email u.set_email(email) db.add_comment(conn.user.id, u.id, 'Changed email address from "%s" to "%s".' % ( old_email, email)) if u.is_online: u.write_('%(aname)s has changed your email address to "%(email)s".\n', {'aname': conn.user.name, 'email': email}) conn.write(A_('Email address of %(uname)s changed to "%(email)s".\n') % {'uname': u.name, 'email': email})
def run(self, args, conn): if args[0] is None: conn.write( _('Use "clearmessages *" to clear all your messages.\n')) return if args[0] == '*': count = db.clear_messages_all(conn.user.id) elif type(args[0]) == type(1): i = int(args[0]) count = db.clear_messages_range(conn.user.id, i, i) if count == 0: conn.write(_('There is no such message.\n')) return else: m = self.range_re.match(args[0]) if m: (start, end) = (int(m.group(1)), int(m.group(2))) # sanity checks if start < 1 or start > end or end > 9999: conn.write(_('Invalid message range.\n')) return count = db.clear_messages_range(conn.user.id, start, end) else: sender = user.find_by_prefix_for_user(args[0], conn) if not sender: return count = db.clear_messages_from_to(sender.id, conn.user.id) conn.write( ngettext('Cleared %d message.\n', 'Cleared %d messages.\n', count) % count)
def sub(self, item, conn): u = user.find_by_prefix_for_user(item, conn, online_only=True) if u: if conn.user not in u.session.idlenotified_by: raise ListError(_('%s is not on your idlenotify list.\n') % u.name) conn.user.remove_idlenotification(u) conn.write(_('%s removed from your idlenotify list.\n') % u.name)
def run(self, args, conn): if conn.user.is_muted: conn.write(_('You are muted.\n')) return u2 = user.find_by_prefix_for_user(args[0], conn) if u2: if conn.user.name in u2.censor and not conn.user.is_admin(): conn.write(_('%s is censoring you.\n') % u2.name) return msgs = db.get_messages_range(conn.user.id, args[1], args[1]) if msgs: msg = msgs[0] message_id = msg['message_id'] msg['forwarder_name'] = conn.user.name db.forward_message(conn.user.id, u2.id, message_id) msg_str_u2 = self._format_msg(msg, u2) # localized for receiver if u2.vars['mailmess']: email.send_mail(conn.user, u2, msg_str_u2) conn.write(_('The following message was forwarded and emailed to %s:\n') % u2.name) else: conn.write(_('The following message was forwarded to %s:\n') % u2.name) if u2.is_online: u2.write_('The following message was received:\n') u2.write(msg_str_u2) self._write_msg(msg, conn.user) else: conn.write(_('There is no such message.\n'))
def add(self, item, conn): u = user.find_by_prefix_for_user(item, conn) if u: if u.name in conn.user.noplay: raise ListError(_('%s is already on your noplay list.\n') % u.name) conn.user.add_noplay(u) conn.write(_('%s added to your noplay list.\n') % u.name)
def sub(self, item, conn): u = user.find_by_prefix_for_user(item, conn) if u: if u.name not in conn.user.noplay: raise ListError(_('%s is not on your noplay list.\n') % u.name) conn.user.remove_noplay(u) conn.write(_('%s removed from your noplay list.\n') % (u.name))
def run(self, args, conn): if args[0] is None: conn.write(_('Use "clearmessages *" to clear all your messages.\n')) return if args[0] == '*': count = db.clear_messages_all(conn.user.id) elif type(args[0]) == type(1): i = int(args[0]) count = db.clear_messages_range(conn.user.id, i, i) if count == 0: conn.write(_('There is no such message.\n')) return else: m = self.range_re.match(args[0]) if m: (start, end) = (int(m.group(1)), int(m.group(2))) # sanity checks if start < 1 or start > end or end > 9999: conn.write(_('Invalid message range.\n')) return count = db.clear_messages_range(conn.user.id, start, end) else: sender = user.find_by_prefix_for_user(args[0], conn) if not sender: return count = db.clear_messages_from_to(sender.id, conn.user.id) conn.write(ngettext('Cleared %d message.\n', 'Cleared %d messages.\n', count) % count)
def run(self, args, conn): if conn.user.is_muted: conn.write(_('You are muted.\n')) return u2 = user.find_by_prefix_for_user(args[0], conn) if u2: if conn.user.name in u2.censor and not conn.user.is_admin(): conn.write(_('%s is censoring you.\n') % u2.name) return msgs = db.get_messages_range(conn.user.id, args[1], args[1]) if msgs: msg = msgs[0] message_id = msg['message_id'] msg['forwarder_name'] = conn.user.name db.forward_message(conn.user.id, u2.id, message_id) msg_str_u2 = self._format_msg(msg, u2) # localized for receiver if u2.vars['mailmess']: email.send_mail(conn.user, u2, msg_str_u2) conn.write( _('The following message was forwarded and emailed to %s:\n' ) % u2.name) else: conn.write( _('The following message was forwarded to %s:\n') % u2.name) if u2.is_online: u2.write_('The following message was received:\n') u2.write(msg_str_u2) self._write_msg(msg, conn.user) else: conn.write(_('There is no such message.\n'))
def sub(self, item, conn): u = user.find_by_prefix_for_user(item, conn) if u: if u.name not in conn.user.noplay: raise ListError(_('%s is not on your noplay list.\n') % u.name) conn.user.remove_noplay(u) conn.write(_('%s removed from your noplay list.\n') % (u.name))
def _do_tell(self, args, conn): if conn.user.is_muted: # mute now prevents *all* tells conn.write(_('You are muted.\n')) return (None, None) u = None ch = None if args[0] == '.': u = conn.session.last_tell_user if not u: conn.write(_("No previous tell.\n")) elif not u.is_online: # try to find the user if he or she has logged off # and since reconnected name = u.name u = online.online.find_exact(name) if not u: conn.write(_('%s is no longer online.\n') % name) elif args[0] == ',': ch = conn.session.last_tell_ch if not ch: conn.write(_('No previous channel.\n')) else: if type(args[0]) != str: try: ch = channel.chlist[args[0]] except KeyError: conn.write(_('Invalid channel number.\n')) else: if conn.user not in ch.online and ( not conn.user.has_title('TD')): conn.user.write( _('''(Not sent because you are not in channel %s.)\n''' ) % ch.id) ch = None else: u = user.find_by_prefix_for_user(args[0], conn, online_only=True) if ch: count = ch.tell(args[1], conn.user) conn.write( ngettext('(told %d player in channel %d)\n', '(told %d players in channel %d)\n', count) % (count, ch.id)) elif u: if conn.user.name in u.censor and not conn.user.is_admin(): conn.write(_("%s is censoring you.\n") % u.name) elif conn.user.is_guest and not u.vars['tell']: conn.write( _('''Player "%s" isn't listening to unregistered users' tells.\n''' % u.name)) else: u.write_('\n%s tells you: %s\n', (conn.user.get_display_name(), args[1])) self._told(u, conn) return (u, ch)
def run(self, args, conn): u = None if args[0] is not None: u = user.find_by_prefix_for_user(args[0], conn, min_len=2) else: u = conn.user if u: history.show_for_user(u, conn)
def add(self, item, conn): u = user.find_by_prefix_for_user(item, conn) if u: if u.name in conn.user.noplay: raise ListError( _('%s is already on your noplay list.\n') % u.name) conn.user.add_noplay(u) conn.write(_('%s added to your noplay list.\n') % u.name)
def run(self, args, conn): u = user.find_by_prefix_for_user(args[0], conn) if u: if u.is_guest: conn.write(A_('Unregistered players cannot have comments.\n')) else: db.add_comment(conn.user.id, u.id, args[1]) conn.write(A_('Comment added for %s.\n') % u.name)
def sub(self, item, conn): u = user.find_by_prefix_for_user(item, conn, online_only=True) if u: if conn.user not in u.session.idlenotified_by: raise ListError( _('%s is not on your idlenotify list.\n') % u.name) conn.user.remove_idlenotification(u) conn.write(_('%s removed from your idlenotify list.\n') % u.name)
def sub(self, item, conn): if conn.user.is_guest: raise ListError(_('Only registered players can have gnotify lists.\n')) u = user.find_by_prefix_for_user(item, conn) if u: if u.name not in conn.user.gnotifiers: raise ListError(_('[%s] is not on your gnotify list.\n') % u.name) conn.user.remove_gnotification(u) conn.write(_('[%s] removed from your gnotify list.\n') % u.name)
def sub(self, item, conn): if conn.user.is_guest: raise ListError( _('Only registered players can have notify lists.\n')) u = user.find_by_prefix_for_user(item, conn) if u: if u.name not in conn.user.notifiers: raise ListError(_('%s is not on your notify list.\n') % u.name) conn.user.remove_notification(u) conn.write(_('%s removed from your notify list.\n') % u.name)
def sub(self, item, conn): self._require_admin(conn.user) u = user.find_by_prefix_for_user(item, conn) if u: if not u.is_muted: raise ListError(_('%s is not on the mute list.\n') % u.name) u.set_muted(False) if not u.is_guest: db.add_comment(conn.user.id, u.id, 'Unmuted.') self._notify_removed(conn, u)
def add(self, item, conn): u = user.find_by_prefix_for_user(item, conn, online_only=True) if u: if u == conn.user: raise ListError(_('You cannot idlenotify yourself.\n')) if conn.user in u.session.idlenotified_by: raise ListError( _('%s is already on your idlenotify list.\n') % u.name) conn.user.add_idlenotification(u) conn.write(_('%s added to your idlenotify list.\n') % u.name)
def add(self, item, conn): u = user.find_by_prefix_for_user(item, conn, online_only=True) if u: if u == conn.user: raise ListError(_('You cannot idlenotify yourself.\n')) if conn.user in u.session.idlenotified_by: raise ListError(_('%s is already on your idlenotify list.\n') % u.name) conn.user.add_idlenotification(u) conn.write(_('%s added to your idlenotify list.\n') % u.name)
def sub(self, item, conn): self._require_admin(conn.user) u = user.find_by_prefix_for_user(item, conn) if u: if not u.is_playbanned: raise ListError(_('%s is not on the playban list.\n') % u.name) u.set_playbanned(False) if not u.is_guest: db.add_comment(conn.user.id, u.id, 'Removed from the playbanned list.') self._notify_removed(conn, u)
def run(self, args, conn): u2 = user.find_by_prefix_for_user(args[0], conn.user, online_only=True) if u2: if not admin.checker.check_user_operation(conn.user, u2): conn.write(A_('You can only pose as players below your adminlevel.\n')) else: conn.write(A_('Command issued as %s.\n') % u2.name) u2.write_('%s has issued the following command on your behalf: %s\n', (conn.user.name, args[1])) # XXX set u2.session.timeseal_last_timestamp? command_parser.parser.parse(args[1], u2.session.conn)
def run(self, args, conn): (chid, name) = args u = user.find_by_prefix_for_user(name, conn) if not u: return try: ch = channel.chlist[chid] except KeyError: conn.write(_('Invalid channel number.\n')) return ch.kick(u, conn.user)
def sub(self, item, conn): self._require_admin(conn.user) u = user.find_by_prefix_for_user(item, conn) if u: if u.is_guest: raise ListError(A_('Only registered players can be ratedbanned.\n')) if not u.is_ratedbanned: raise ListError(_('%s is not on the ratedban list.\n') % u.name) u.set_ratedbanned(False) db.add_comment(conn.user.id, u.id, 'Removed from the ratedbanned list.') self._notify_removed(conn, u)
def run(self, args, conn): if args[0] is not None: u2 = user.find_by_prefix_for_user(args[0], conn) else: u2 = conn.user if u2: log = u2.get_log() if not log: conn.write('%s has not logged on.\n' % u2.name) else: self._display_log(log, conn)
def sub(self, item, conn): self._require_admin(conn.user) u = user.find_by_prefix_for_user(item, conn) if u: if u.is_guest: raise ListError(A_('Only registered players can be banned.\n')) if not u.is_banned: raise ListError(_('%s is not on the ban list.\n') % u.name) u.set_banned(False) db.add_comment(conn.user.id, u.id, 'Unbanned.') self._notify_removed(conn, u)
def run(self, args, conn): if not conn.user.has_title('TD'): conn.write(_('Only TD programs are allowed to use this command.\n')) return u1 = user.find_by_prefix_for_user(args[0], conn, online_only=True) if not u1: return u2 = user.find_by_prefix_for_user(args[1], conn, online_only=True) if not u2: return # ignore censor lists, noplay lists, and open var if u1 == u2: conn.write(_("A player cannot match himself or herself.\n")) return if u1.session.game: conn.write(_("%s is playing a game.\n") % u1.name) return if u2.session.game: conn.write(_("%s is playing a game.\n") % u2.name) return match.Challenge(u1, u2, args[2])
def run(self, args, conn): u = user.find_by_prefix_for_user(args[0], conn) if u: if u.is_guest: conn.write(A_('Unregistered players cannot have comments.\n')) else: comments = db.get_comments(u.id) if not comments: conn.write(A_('There are no comments for %s.\n') % u.name) else: for c in comments: conn.write(A_('%s at %s: %s\n') % (c['admin_name'], c['when_added'], c['txt']))
def add(self, item, conn): self._require_admin(conn.user) u = user.find_by_prefix_for_user(item, conn) if u: if u.is_admin(): raise ListError(A_('Admins cannot be playbanned.\n')) if u.is_playbanned: raise ListError(_('%s is already on the playban list.\n') % u.name) u.set_playbanned(True) if not u.is_guest: db.add_comment(conn.user.id, u.id, 'Playbanned.') self._notify_added(conn, u)
def sub(self, item, conn): self._require_admin(conn.user) u = user.find_by_prefix_for_user(item, conn) if u: if u.is_guest: raise ListError(_("Only registered users may have titles.\n")) try: u.remove_title(self.id) except DeleteError: raise ListError(_('%(uname)s is not on the %(lname)s list.\n') % {'uname': u.name, 'lname': self.name }) self._notify_removed(conn, u)
def add(self, item, conn): self._require_admin(conn.user) u = user.find_by_prefix_for_user(item, conn) if u: if u.is_guest: raise ListError(A_('Only registered players can be ratedbanned.\n')) if u.is_admin(): raise ListError(A_('Admins cannot be ratedbanned.\n')) if u.is_ratedbanned: raise ListError(_('%s is already on the ratedban list.\n') % u.name) u.set_ratedbanned(True) db.add_comment(conn.user.id, u.id, 'Ratedbanned.') self._notify_added(conn, u)
def add(self, item, conn): self._require_admin(conn.user) u = user.find_by_prefix_for_user(item, conn) if u: if u.is_guest: raise ListError(_("Only registered users may have titles.\n")) try: u.add_title(self.id) except DuplicateKeyError: raise ListError(_('%(uname)s is already on the %(lname)s list.\n') % {'uname': u.name, 'lname': self.name }) self._notify_added(conn, u)
def add(self, item, conn): self._require_admin(conn.user) u = user.find_by_prefix_for_user(item, conn) if u: if u.is_admin(): raise ListError(A_('Admins cannot be playbanned.\n')) if u.is_playbanned: raise ListError( _('%s is already on the playban list.\n') % u.name) u.set_playbanned(True) if not u.is_guest: db.add_comment(conn.user.id, u.id, 'Playbanned.') self._notify_added(conn, u)
def run(self, args, conn): if not conn.user.has_title('TD'): conn.write( _('Only TD programs are allowed to use this command.\n')) return u1 = user.find_by_prefix_for_user(args[0], conn, online_only=True) if not u1: return u2 = user.find_by_prefix_for_user(args[1], conn, online_only=True) if not u2: return # ignore censor lists, noplay lists, and open var if u1 == u2: conn.write(_("A player cannot match himself or herself.\n")) return if u1.session.game: conn.write(_("%s is playing a game.\n") % u1.name) return if u2.session.game: conn.write(_("%s is playing a game.\n") % u2.name) return match.Challenge(u1, u2, args[2])
def add(self, item, conn): if conn.user.is_guest: raise ListError(_('Only registered players can have gnotify lists.\n')) u = user.find_by_prefix_for_user(item, conn) if u: if u == conn.user: raise ListError(_('You cannot gnotify yourself.\n')) if u.is_guest: raise ListError(_('You cannot add an unregistered user to your gnotify list.\n')) if u.name in conn.user.gnotifiers: raise ListError(_('[%s] is already on your gnotify list.\n') % u.name) conn.user.add_gnotification(u) conn.write(_('[%s] added to your gnotify list.\n') % u.name)
def _do_tell(self, args, conn): if conn.user.is_muted: # mute now prevents *all* tells conn.write(_('You are muted.\n')) return (None, None) u = None ch = None if args[0] == '.': u = conn.session.last_tell_user if not u: conn.write(_("No previous tell.\n")) elif not u.is_online: # try to find the user if he or she has logged off # and since reconnected name = u.name u = online.online.find_exact(name) if not u: conn.write(_('%s is no longer online.\n') % name) elif args[0] == ',': ch = conn.session.last_tell_ch if not ch: conn.write(_('No previous channel.\n')) else: if type(args[0]) != str: try: ch = channel.chlist[args[0]] except KeyError: conn.write(_('Invalid channel number.\n')) else: if conn.user not in ch.online and ( not conn.user.has_title('TD')): conn.user.write(_('''(Not sent because you are not in channel %s.)\n''') % ch.id) ch = None else: u = user.find_by_prefix_for_user(args[0], conn, online_only=True) if ch: count = ch.tell(args[1], conn.user) conn.write(ngettext('(told %d player in channel %d)\n', '(told %d players in channel %d)\n', count) % (count, ch.id)) elif u: if conn.user.name in u.censor and not conn.user.is_admin(): conn.write(_("%s is censoring you.\n") % u.name) elif conn.user.is_guest and not u.vars['tell']: conn.write(_('''Player "%s" isn't listening to unregistered users' tells.\n''' % u.name)) else: u.write_('\n%s tells you: %s\n', (conn.user.get_display_name(), args[1])) self._told(u, conn) return (u, ch)
def add(self, item, conn): self._require_admin(conn.user) u = user.find_by_prefix_for_user(item, conn) if u: if u.is_guest: raise ListError( A_('Only registered players can be ratedbanned.\n')) if u.is_admin(): raise ListError(A_('Admins cannot be ratedbanned.\n')) if u.is_ratedbanned: raise ListError( _('%s is already on the ratedban list.\n') % u.name) u.set_ratedbanned(True) db.add_comment(conn.user.id, u.id, 'Ratedbanned.') self._notify_added(conn, u)
def run(self, args, conn): if conn.user.session.game: if conn.user.session.game.gtype == game.EXAMINED: conn.write(_("You can't challenge while you are examining a game.\n")) else: conn.write(_("You can't challenge while you are playing a game.\n")) return u = user.find_by_prefix_for_user(args[0], conn, online_only=True) if not u: return if u == conn.user: conn.write(_("You can't match yourself.\n")) return match.Challenge(conn.user, u, args[1])
def sub(self, item, conn): self._require_admin(conn.user) u = user.find_by_prefix_for_user(item, conn) if u: if u.is_guest: raise ListError(_("Only registered users may have titles.\n")) try: u.remove_title(self.id) except DeleteError: raise ListError( _('%(uname)s is not on the %(lname)s list.\n') % { 'uname': u.name, 'lname': self.name }) self._notify_removed(conn, u)
def add(self, item, conn): self._require_admin(conn.user) u = user.find_by_prefix_for_user(item, conn) if u: if u.is_guest: raise ListError(_("Only registered users may have titles.\n")) try: u.add_title(self.id) except DuplicateKeyError: raise ListError( _('%(uname)s is already on the %(lname)s list.\n') % { 'uname': u.name, 'lname': self.name }) self._notify_added(conn, u)
def run(self, args, conn): if not conn.user.has_title('TD'): conn.write(_('Only TD programs are allowed to use this command.\n')) return u2 = user.find_by_prefix_for_user(args[0], conn, online_only=True) if not u2: return g = game.from_name_or_number(args[1], conn) if g: if u2 in g.observers or u2 in g.players: # TODO: how to print error message to TD? pass else: g.observe(u2)
def run(self, args, conn): u = user.find_by_prefix_for_user(args[0], conn, online_only=True) if not u: return if u == conn.user: conn.write(_("You can't summon yourself.\n")) if not conn.user.is_admin(): if conn.user.name in u.censor: conn.write(_("%s is censoring you.\n") % u.name) return if conn.user.name not in u.notifiers: conn.write(_('You cannot summon a player who doesn\'t have you on his or her notify list.\n')) return u.write('\a\n') u.write_('%s needs to speak to you. To contact him or her type "tell %s hello".\n', ((conn.user.name, conn.user.name))) conn.write(_('Summoning sent to "%s".\n') % u.name) conn.user.add_idlenotification(u)
def run(self, args, conn): if not conn.user.has_title('TD'): conn.write( _('Only TD programs are allowed to use this command.\n')) return u2 = user.find_by_prefix_for_user(args[0], conn, online_only=True) if not u2: return g = game.from_name_or_number(args[1], conn) if g: if u2 in g.observers or u2 in g.players: # TODO: how to print error message to TD? pass else: g.observe(u2)
def add(self, item, conn): if conn.user.is_guest: raise ListError( _('Only registered players can have gnotify lists.\n')) u = user.find_by_prefix_for_user(item, conn) if u: if u == conn.user: raise ListError(_('You cannot gnotify yourself.\n')) if u.is_guest: raise ListError( _('You cannot add an unregistered user to your gnotify list.\n' )) if u.name in conn.user.gnotifiers: raise ListError( _('[%s] is already on your gnotify list.\n') % u.name) conn.user.add_gnotification(u) conn.write(_('[%s] added to your gnotify list.\n') % u.name)
def from_name_or_number(arg, conn): g = None try: num = int(arg) if num in games: g = games[num] else: conn.write(_("There is no such game.\n")) except ValueError: # user name u = user.find_by_prefix_for_user(arg, conn, online_only=True) if u: if not u.session.game: conn.write(_("%s is not playing or examining a game.\n") % u.name) else: g = u.session.game return g
def add(self, item, conn): if conn.user.is_guest: raise ListError(_('Only registered players can have notify lists.\n')) u = user.find_by_prefix_for_user(item, conn) if u: if u == conn.user: raise ListError(_('You cannot notify yourself.\n')) if u.is_guest: raise ListError(_('You cannot add an unregistered user to your notify list.\n')) if u.name in conn.user.notifiers: raise ListError(_('%s is already on your notify list.\n') % u.name) conn.user.add_notification(u) conn.write(_('%s added to your notify list.\n') % u.name) if u.is_online and u.vars['notifiedby']: # new feature: inform the added user u.write_('\nYou have been added to the notify list of %s.\n', (conn.user.name,))
def run(self, args, conn): if args[0] is not None: u2 = user.find_by_prefix_for_user(args[0], conn, online_only=True) else: u2 = conn.user if u2: pt = u2.session.ping_time if not u2.has_timeseal(): conn.write(_('Ping time not available; %s is not using zipseal.\n') % u2.name) elif len(pt) < 2: conn.write(_('Ping time not available; please wait.\n')) else: conn.write(_('Ping time for %s, based on %d samples:\n') % (u2.name, len(pt))) avg = 1000.0 * sum(pt) / len(pt) conn.write(_('Average: %.3fms\n') % (avg))
def run(self, args, conn): if not conn.user.has_title('TD'): conn.write(_('Only TD programs are allowed to use this command.\n')) return u2 = user.find_by_prefix_for_user(args[0], conn, online_only=True) if not u2: return # XXX how to handle guests? if args[1] not in [0, 1]: raise BadCommandError u2.vars['tourney'] = str(args[1]) if args[1]: u2.write_('\n%s has set your tourney variable to ON.\n', (conn.user.name,)) else: u2.write_('\n%s has set your tourney variable to OFF.\n', (conn.user.name,))
def run(self, args, conn): if not conn.user.has_title('TD'): conn.write( _('Only TD programs are allowed to use this command.\n')) return u2 = user.find_by_prefix_for_user(args[0], conn, online_only=True) if not u2: return # XXX how to handle guests? if args[1] not in [0, 1]: raise BadCommandError u2.vars['tourney'] = str(args[1]) if args[1]: u2.write_('\n%s has set your tourney variable to ON.\n', (conn.user.name, )) else: u2.write_('\n%s has set your tourney variable to OFF.\n', (conn.user.name, ))
def run(self, args, conn): u = user.find_by_prefix_for_user(args[0], conn, online_only=True) if not u: return if u == conn.user: conn.write(_("You can't summon yourself.\n")) if not conn.user.is_admin(): if conn.user.name in u.censor: conn.write(_("%s is censoring you.\n") % u.name) return if conn.user.name not in u.notifiers: conn.write( _('You cannot summon a player who doesn\'t have you on his or her notify list.\n' )) return u.write('\a\n') u.write_( '%s needs to speak to you. To contact him or her type "tell %s hello".\n', ((conn.user.name, conn.user.name))) conn.write(_('Summoning sent to "%s".\n') % u.name) conn.user.add_idlenotification(u)
def add(self, item, conn): if conn.user.is_guest: raise ListError( _('Only registered players can have notify lists.\n')) u = user.find_by_prefix_for_user(item, conn) if u: if u == conn.user: raise ListError(_('You cannot notify yourself.\n')) if u.is_guest: raise ListError( _('You cannot add an unregistered user to your notify list.\n' )) if u.name in conn.user.notifiers: raise ListError( _('%s is already on your notify list.\n') % u.name) conn.user.add_notification(u) conn.write(_('%s added to your notify list.\n') % u.name) if u.is_online and u.vars['notifiedby']: # new feature: inform the added user u.write_('\nYou have been added to the notify list of %s.\n', (conn.user.name, ))
def run(self, args, conn): if not args[0]: if conn.user.session.partner: p = conn.user.session.partner assert (p.is_online) assert (p.session.partner == conn.user) p.write_('\n%s has left the partnership.\n', conn.user.name) partner.end_partnership(conn.user, p) else: conn.write(_('You do not have a bughouse partner.\n')) else: u = user.find_by_prefix_for_user(args[0], conn, online_only=True) if not u: return if conn.user.name in u.censor: conn.write(_('%s is censoring you.\n') % u.name) return if u == conn.user: conn.write(_("You can't be your own bughouse partner.\n")) return if conn.user.session.partner: conn.write( _("You are already %s's bughouse partner.\n") % conn.user.session.partner.name) return if u.session.partner: conn.write(_('%s already has a partner.\n') % u.name) return if not u.vars['bugopen']: conn.write(_('%s is not open for bughouse.\n') % u.name) return if not conn.user.vars['bugopen']: conn.write(_('Setting you open for bughouse.\n')) var.vars['bugopen'].set(conn.user, '1') partner.Partner(conn.user, u)