本文整理汇总了Python中server.Server.msg方法的典型用法代码示例。如果您正苦于以下问题:Python Server.msg方法的具体用法?Python Server.msg怎么用?Python Server.msg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类server.Server
的用法示例。
在下文中一共展示了Server.msg方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MSG
# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import msg [as 别名]
def MSG(self, args):
target = args[0]
message = " ".join(args[1:])
# can't send a message if not logged in
if self.__nickname is None:
ERRMSG(self.__sobj, "Not logged in")
return
# we won't ACK this on this side - the server has to do it,
# before it fires the callback. kind of lame and sphagetti like
try:
Server.msg(self.__nickname, target, message, self)
except Exception, errmsg:
ERRMSG(self.__sobj, errmsg)
示例2: BaskitCLI
# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import msg [as 别名]
#.........这里部分代码省略.........
impending server outage.
-p/--no-players Wait to stop server until no players are
online. Please note that this will cause
baskit to wait a potentially long period
of time.
-n/--notify Notifies the players of the current wait
status for the server shutdown.
'''
if not self.server.running():
print 'Minecraft service already stopped.'
return
notify = False
pwait = False
wait = datetime.datetime.now()
opts, args = getopt.getopt(s.split(), 'npt:',
['timer=', 'no-players', 'notify'])
for opt, val in opts:
if opt in ('-t', '--timer'):
wait = wait + datetime.timedelta(seconds=int(val))
if opt in ('-p', '--no-players'):
players = True
if opt in ('-n', '--notify'):
notify = True
# Here is the wait loop for shutting down the server.
while wait > datetime.datetime.now() and not players:
if players:
if len(self.server.players) < 1:
players = False
if notify:
msg = 'SERVER WILL SHUT DOWN IN %s SECONDS' %\
(wait - datetime.datetime.now()).seconds
if players:
msg += ' WHEN ALL PLAYERS HAVE LEFT'
self.server.msg(msg)
time.sleep(10)
self.server.stop()
print 'Minecraft service has been stopped'
def do_restart(self, s):
'''restart
Convenience function to restart the server. No options are provided.
'''
self.server.stop()
self.server.start()
def do_server(self, s):
'''server
Returns the current server status as well as some known configuration
information about the server.
'''
d1 = {True: 'running', False: 'stopped'}
print 'Server Binary Information\n-------------------------'
print 'Status : %s' % d1[self.server.running()]
print 'Type : %s' % self.server.server_type
print 'Branch : %s' % self.server.server_branch
print 'Build : %s' % self.server.server_build
print 'Worlds : %s' % ', '.join(self.server.worlds)
def do_status(self, s):