本文整理汇总了Python中evennia.server.sessionhandler.SESSIONS.account_count方法的典型用法代码示例。如果您正苦于以下问题:Python SESSIONS.account_count方法的具体用法?Python SESSIONS.account_count怎么用?Python SESSIONS.account_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类evennia.server.sessionhandler.SESSIONS
的用法示例。
在下文中一共展示了SESSIONS.account_count方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: func
# 需要导入模块: from evennia.server.sessionhandler import SESSIONS [as 别名]
# 或者: from evennia.server.sessionhandler.SESSIONS import account_count [as 别名]
def func(self):
"""returns the list of online characters"""
count_accounts = (SESSIONS.account_count())
self.caller.msg("[%s] Through the fog you see:" % self.key)
session_list = SESSIONS.get_sessions()
table = evtable.EvTable(border='none')
table.add_row('Character', 'On for', 'Idle', 'Location')
for session in session_list:
if not session.logged_in:
continue
delta_cmd = time.time() - session.cmd_last_visible
delta_conn = time.time() - session.conn_time
puppet = session.get_puppet()
location = puppet.location.key if puppet and puppet.location else 'Nothingness'
table.add_row(puppet.key if puppet else 'None', utils.time_format(delta_conn, 0),
utils.time_format(delta_cmd, 1), location)
table.reformat_column(0, width=25, align='l')
table.reformat_column(1, width=12, align='l')
table.reformat_column(2, width=7, align='l')
table.reformat_column(3, width=25, align='l')
is_one = count_accounts == 1
string = '%s' % 'A' if is_one else str(count_accounts)
string += ' single ' if is_one else ' unique '
plural = ' is' if is_one else 's are'
string += 'account%s logged in.' % plural
self.caller.msg(table)
self.caller.msg(string)
示例2: func
# 需要导入模块: from evennia.server.sessionhandler import SESSIONS [as 别名]
# 或者: from evennia.server.sessionhandler.SESSIONS import account_count [as 别名]
def func(self):
"""
Get all connected accounts by polling session.
"""
account = self.account
session_list = SESSIONS.get_sessions()
session_list = sorted(session_list, key=lambda o: o.account.key)
if self.cmdstring == "doing":
show_session_data = False
else:
show_session_data = account.check_permstring("Developer") or account.check_permstring("Admins")
naccounts = (SESSIONS.account_count())
if show_session_data:
# privileged info
table = evtable.EvTable("|wAccount Name",
"|wOn for",
"|wIdle",
"|wPuppeting",
"|wRoom",
"|wCmds",
"|wProtocol",
"|wHost")
for session in session_list:
if not session.logged_in:
continue
delta_cmd = time.time() - session.cmd_last_visible
delta_conn = time.time() - session.conn_time
account = session.get_account()
puppet = session.get_puppet()
location = puppet.location.key if puppet and puppet.location else "None"
table.add_row(utils.crop(account.name, width=25),
utils.time_format(delta_conn, 0),
utils.time_format(delta_cmd, 1),
utils.crop(puppet.key if puppet else "None", width=25),
utils.crop(location, width=25),
session.cmd_total,
session.protocol_key,
isinstance(session.address, tuple) and session.address[0] or session.address)
else:
# unprivileged
table = evtable.EvTable("|wAccount name", "|wOn for", "|wIdle")
for session in session_list:
if not session.logged_in:
continue
delta_cmd = time.time() - session.cmd_last_visible
delta_conn = time.time() - session.conn_time
account = session.get_account()
table.add_row(utils.crop(account.key, width=25),
utils.time_format(delta_conn, 0),
utils.time_format(delta_cmd, 1))
is_one = naccounts == 1
self.msg("|wAccounts:|n\n%s\n%s unique account%s logged in."
% (table, "One" if is_one else naccounts, "" if is_one else "s"))
示例3: _form_and_send_request
# 需要导入模块: from evennia.server.sessionhandler import SESSIONS [as 别名]
# 或者: from evennia.server.sessionhandler.SESSIONS import account_count [as 别名]
def _form_and_send_request(self):
agent = Agent(reactor, pool=self._conn_pool)
headers = {
'User-Agent': ['Evennia Game Index Client'],
'Content-Type': ['application/x-www-form-urlencoded'],
}
egi_config = self._get_config_dict()
# We are using `or` statements below with dict.get() to avoid sending
# stringified 'None' values to the server.
values = {
# Game listing stuff
'game_name': settings.SERVERNAME,
'game_status': egi_config['game_status'],
'game_website': egi_config.get('game_website') or '',
'short_description': egi_config['short_description'],
'long_description': egi_config.get('long_description') or '',
'listing_contact': egi_config['listing_contact'],
# How to play
'telnet_hostname': egi_config.get('telnet_hostname') or '',
'telnet_port': egi_config.get('telnet_port') or '',
'web_client_url': egi_config.get('web_client_url') or '',
# Game stats
'connected_account_count': SESSIONS.account_count(),
'total_account_count': AccountDB.objects.num_total_accounts() or 0,
# System info
'evennia_version': get_evennia_version(),
'python_version': platform.python_version(),
'django_version': django.get_version(),
'server_platform': platform.platform(),
}
data = urllib.urlencode(values)
d = agent.request(
'POST', self.report_url,
headers=Headers(headers),
bodyProducer=StringProducer(data))
d.addCallback(self.handle_egd_response)
return d
示例4: test_info_command
# 需要导入模块: from evennia.server.sessionhandler import SESSIONS [as 别名]
# 或者: from evennia.server.sessionhandler.SESSIONS import account_count [as 别名]
def test_info_command(self):
expected = "## BEGIN INFO 1.1\nName: %s\nUptime: %s\nConnected: %d\nVersion: Evennia %s\n## END INFO" % (
settings.SERVERNAME,
datetime.datetime.fromtimestamp(gametime.SERVER_START_TIME).ctime(),
SESSIONS.account_count(), utils.get_evennia_version())
self.call(unloggedin.CmdUnconnectedInfo(), "", expected)
示例5: func
# 需要导入模块: from evennia.server.sessionhandler import SESSIONS [as 别名]
# 或者: from evennia.server.sessionhandler.SESSIONS import account_count [as 别名]
def func(self):
"""Get all connected accounts by polling session."""
you = self.account
session_list = SESSIONS.get_sessions()
cmd = self.cmdstring
show_session_data = you.check_permstring('Immortals') and not you.attributes.has('_quell')
account_count = (SESSIONS.account_count())
table = evtable.EvTable(border='none', pad_width=0, border_width=0, maxwidth=79)
if cmd == 'wa' or cmd == 'where':
# Example output expected:
# Occ, Location, Avg Time, Top 3 Active, Directions
# #3 Park 5m Rulan, Amber, Tria Taxi, Park
# Other possible sort methods: Alphabetical by name, by occupant count, by activity, by distance
# Nick = Global Nick (no greater than five A/N or randomly created if not a Global Nick
#
# WA with name parameters to pull up more extensive information about the direction
# Highest Occupants (since last reboot), Last Visited, Last Busy (3+) etc. (more ideas here)
table.add_header('|wOcc', '|wLocation', '|wAvg Time', '|cTop 3 Active', '|gDirections')
table.reformat_column(0, width=4, align='l')
table.reformat_column(1, width=25, align='l')
table.reformat_column(2, width=6, align='l')
table.reformat_column(3, width=16, pad_right=1, align='l')
table.reformat_column(4, width=20, align='l')
locations = {} # Create an empty dictionary to gather locations information.
for session in session_list: # Go through connected list and see who's where.
if not session.logged_in:
continue
character = session.get_puppet()
if not character:
continue
if character.location not in locations:
locations[character.location] = []
locations[character.location].append(character) # Build the list of who's in a location
for place in locations:
location = place.get_display_name(you) if place else '|222Nothingness|n'
table.add_row(len(locations[place]), location, '?',
', '.join(each.get_display_name(you) for each in locations[place]),
'Summon or walk')
elif cmd == 'ws':
my_character = self.caller.get_puppet(self.session)
if not (my_character and my_character.location):
self.msg("You can't see anyone here.")
return
table.add_header('|wCharacter', '|wOn for', '|wIdle')
table.reformat_column(0, width=45, align='l')
table.reformat_column(1, width=8, align='l')
table.reformat_column(2, width=7, pad_right=1, align='r')
for element in my_character.location.contents:
if not element.has_account:
continue
delta_cmd = time.time() - max([each.cmd_last_visible for each in element.sessions.all()])
delta_con = time.time() - min([each.conn_time for each in element.sessions.all()])
name = element.get_display_name(you)
type = element.attributes.get('species', default='')
table.add_row(name + ', ' + type if type else name,
utils.time_format(delta_con, 0), utils.time_format(delta_cmd, 1))
elif cmd == 'what' or cmd == 'wot':
table.add_header('|wCharacter - Doing', '|wIdle')
table.reformat_column(0, width=72, align='l')
table.reformat_column(1, width=7, align='r')
for session in session_list:
if not session.logged_in or not session.get_puppet():
continue
delta_cmd = time.time() - session.cmd_last_visible
character = session.get_puppet()
doing = character.get_display_name(you, pose=True)
table.add_row(doing, utils.time_format(delta_cmd, 1))
else: # Default to displaying who
if show_session_data: # privileged info shown to Immortals and higher only when not quelled
table.add_header('|wCharacter', '|wAccount', '|wQuell', '|wCmds', '|wProtocol', '|wAddress')
table.reformat_column(0, align='l')
table.reformat_column(1, align='r')
table.reformat_column(2, width=7, align='r')
table.reformat_column(3, width=6, pad_right=1, align='r')
table.reformat_column(4, width=11, align='l')
table.reformat_column(5, width=16, align='r')
session_list = sorted(session_list, key=lambda o: o.account.key)
for session in session_list:
if not session.logged_in:
continue
account = session.get_account()
puppet = session.get_puppet()
table.add_row(puppet.get_display_name(you) if puppet else 'None',
account.get_display_name(you),
'|gYes|n' if account.attributes.get('_quell') else '|rNo|n',
session.cmd_total, session.protocol_key,
isinstance(session.address, tuple) and session.address[0] or session.address)
else: # unprivileged info shown to everyone, including Immortals and higher when quelled
table.add_header('|wCharacter', '|wOn for', '|wIdle')
table.reformat_column(0, width=40, align='l')
table.reformat_column(1, width=8, align='l')
table.reformat_column(2, width=7, align='r')
for session in session_list:
if not session.logged_in:
continue
delta_cmd = time.time() - session.cmd_last_visible
delta_conn = time.time() - session.conn_time
character = session.get_puppet()
if not character:
continue
#.........这里部分代码省略.........
示例6: func
# 需要导入模块: from evennia.server.sessionhandler import SESSIONS [as 别名]
# 或者: from evennia.server.sessionhandler.SESSIONS import account_count [as 别名]
def func(self):
self.caller.msg("## BEGIN INFO 1.1\nName: %s\nUptime: %s\nConnected: %d\nVersion: Evennia %s\n## END INFO" % (
settings.SERVERNAME,
datetime.datetime.fromtimestamp(gametime.SERVER_START_TIME).ctime(),
SESSIONS.account_count(), utils.get_evennia_version()))