def build_who(ch=None): """returns a formatted list of all the people currently online""" buf = [] buf.append(display.seperator) # build character info count = len(mudsock.socket_list()) playing = 0 for sock in mudsock.socket_list(): if not (sock.ch == None or sock.ch.room == None): desc = sock.ch.name if ch != None: desc = ch.see_as(sock.ch) buf.append(" %-12s %-10s %53s" % (desc, sock.ch.race, sock.ch.user_groups)) playing = playing + 1 conn_end = "s" if count == 1: conn_end = "" play_end = "s" if playing == 1: play_end = "" # build our footer buf.append(display.seperator) buf.append( (" %d socket" % count) + conn_end + " logged in." + (" %d player" % playing) + play_end + " currently playing." ) buf.append(display.seperator) buf.append("") return "\r\n".join(buf)
def build_who(ch=None): '''returns a formatted list of all the people currently online''' buf = [] buf.append(display.seperator) # build character info count = len(mudsock.socket_list()) playing = 0 for sock in mudsock.socket_list(): if not (sock.ch == None or sock.ch.room == None): desc = sock.ch.name if ch != None: desc = ch.see_as(sock.ch) buf.append(" %-12s %-10s %53s" % (desc, sock.ch.race, sock.ch.user_groups)) playing = playing + 1 conn_end = "s" if count == 1: conn_end = "" play_end = "s" if playing == 1: play_end = "" # build our footer buf.append(display.seperator) buf.append((" %d socket" % count) + conn_end + " logged in." + (" %d player" % playing) + play_end + " currently playing.") buf.append(display.seperator) buf.append("") return "\r\n".join(buf)
def cmd_connections(ch, cmd, arg): '''lists all of the currently connected sockets, their status, and where they are connected from.''' tosend = [] fmt = " %2s %-11s %-11s %-11s %s" tosend.append( ("{w" + fmt) % ("Id", "Character", "Account", "Status", "Host")) tosend.append("{b" + display.seperator + "{c") for sock in mudsock.socket_list(): chname = "none" accname = "none" state = sock.state host = sock.hostname id = sock.uid if sock.ch != None: chname = sock.ch.name if sock.account != None: accname = sock.account.name tosend.append(fmt % (id, chname, accname, state, host)) tosend.append("{n") ch.page("\r\n".join(tosend))
def cmd_wiz(ch, cmd, arg): if arg == '': ch.send("WizChat what?") else: mssg = "{b%s WizChats, '{c%s{b'{n" % (ch.name, arg) for sock in mudsock.socket_list(): if sock.ch != None and sock.ch.isInGroup("wizard"): sock.ch.send(mssg)
def build_who(ch=None): '''returns a formatted list of all the people currently online''' buf = [] f = open("/home/ubuntu/ngenmud/lib/txt/who", "r") buf.append(f.read()) buf.append("%s%s" % ("{n", display.seperator)) # build character info count = len(mudsock.socket_list()) playing = 0 groups = [] for sock in mudsock.socket_list(): if not (sock.ch == None or sock.ch.room == None): desc = sock.ch.name if ch != None: desc = ch.see_as(sock.ch) groups = sock.ch.user_groups if 'admin' in groups: group = "{Y(wizard){n" if 'wizard' in groups: group = "{G(wizard){n" if 'builder' in groups: group = "{B(builder){n" buf.append(" %-12s %-10s %53s" % (desc, sock.ch.race, group)) playing = playing + 1 conn_end = "s" if count == 1: conn_end = "" play_end = "s" if playing == 1: play_end = "" # build our footer buf.append(display.seperator) buf.append((" %d socket" % count) + conn_end + " logged in." + (" %d player" % playing) + play_end + " currently playing.") buf.append(display.seperator) buf.append("") return "\r\n".join(buf)
def cmd_disconnect(ch, cmd, arg): """Usage: disconnect <uid> Disconnects a socket with the given uid. Use 'connections' to see current connected sockets.""" try: uid, = mud.parse_args(ch, True, cmd, arg, "int(uid)") except: return for sock in mudsock.socket_list(): if sock.uid == uid: ch.send("You disconnect socket %d." % uid) sock.close() break
def cmd_connections(ch, cmd, arg): '''lists all of the currently connected sockets, their status, and where they are connected from.''' tosend = [ ] fmt = " %2s %-11s %-11s %-11s %s" tosend.append(("{w"+fmt) % ("Id", "Character", "Account", "Status", "Host")) tosend.append("{b" + display.seperator + "{c") for sock in mudsock.socket_list(): chname = "none" accname = "none" state = sock.state host = sock.hostname id = sock.uid if sock.ch != None: chname = sock.ch.name if sock.account != None: accname = sock.account.name tosend.append(fmt % (id, chname, accname, state, host)) tosend.append("{n") ch.page("\r\n".join(tosend))