本文整理匯總了Python中evennia.comms.channelhandler.CHANNELHANDLER.update方法的典型用法代碼示例。如果您正苦於以下問題:Python CHANNELHANDLER.update方法的具體用法?Python CHANNELHANDLER.update怎麽用?Python CHANNELHANDLER.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類evennia.comms.channelhandler.CHANNELHANDLER
的用法示例。
在下文中一共展示了CHANNELHANDLER.update方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: func
# 需要導入模塊: from evennia.comms.channelhandler import CHANNELHANDLER [as 別名]
# 或者: from evennia.comms.channelhandler.CHANNELHANDLER import update [as 別名]
def func(self):
"Implement the command"
caller = self.caller
if not self.args:
self.msg("Usage @ccreate <channelname>[;alias;alias..] = description")
return
description = ""
if self.rhs:
description = self.rhs
lhs = self.lhs
channame = lhs
aliases = None
if ';' in lhs:
channame, aliases = lhs.split(';', 1)
aliases = [alias.strip().lower() for alias in aliases.split(';')]
channel = ChannelDB.objects.channel_search(channame)
if channel:
self.msg("A channel with that name already exists.")
return
# Create and set the channel up
lockstring = "send:all();listen:all();control:id(%s)" % caller.id
new_chan = create.create_channel(channame.strip(),
aliases,
description,
locks=lockstring)
new_chan.connect(caller)
CHANNELHANDLER.update()
self.msg("Created channel %s and connected to it." % new_chan.key)
示例2: delete
# 需要導入模塊: from evennia.comms.channelhandler import CHANNELHANDLER [as 別名]
# 或者: from evennia.comms.channelhandler.CHANNELHANDLER import update [as 別名]
def delete(self):
"""
Deletes channel while also cleaning up channelhandler
"""
self.attributes.clear()
self.aliases.clear()
super(DefaultChannel, self).delete()
from evennia.comms.channelhandler import CHANNELHANDLER
CHANNELHANDLER.update()
示例3: func
# 需要導入模塊: from evennia.comms.channelhandler import CHANNELHANDLER [as 別名]
# 或者: from evennia.comms.channelhandler.CHANNELHANDLER import update [as 別名]
def func(self):
"""implement the function"""
if not self.args or not self.rhs:
string = "Usage: @cboot[/quiet] <channel> = <account> [:reason]"
self.msg(string)
return
channel = find_channel(self.caller, self.lhs)
if not channel:
return
reason = ""
if ":" in self.rhs:
accountname, reason = self.rhs.rsplit(":", 1)
searchstring = accountname.lstrip('*')
else:
searchstring = self.rhs.lstrip('*')
account = self.caller.search(searchstring, account=True)
if not account:
return
if reason:
reason = " (reason: %s)" % reason
if not channel.access(self.caller, "control"):
string = "You don't control this channel."
self.msg(string)
return
if not channel.subscriptions.has(account):
string = "Account %s is not connected to channel %s." % (account.key, channel.key)
self.msg(string)
return
if "quiet" not in self.switches:
string = "%s boots %s from channel.%s" % (self.caller, account.key, reason)
channel.msg(string)
# find all account's nicks linked to this channel and delete them
for nick in [nick for nick in
account.character.nicks.get(category="channel") or []
if nick.value[3].lower() == channel.key]:
nick.delete()
# disconnect account
channel.disconnect(account)
CHANNELHANDLER.update()
示例4: func
# 需要導入模塊: from evennia.comms.channelhandler import CHANNELHANDLER [as 別名]
# 或者: from evennia.comms.channelhandler.CHANNELHANDLER import update [as 別名]
#.........這裏部分代碼省略.........
elif 'desc' in self.switches:
if not self.rhs:
self.msg("Usage: %s/desc <channel> = <description>" % self.cmdstring)
return
channel = find_channel(caller, self.lhs)
if not channel:
self.msg("Channel '%s' not found." % self.lhs)
return
if not channel.access(caller, 'control'): # check permissions
self.msg("You cannot describe this channel.")
return
channel.db.desc = self.rhs # set the description
channel.save()
self.msg("Description of channel '%s' set to '%s'." % (channel.key, self.rhs))
elif 'all' in self.switches:
if not args:
caller.execute_cmd("@channels")
self.msg("Usage: %s/all on || off || who || clear" % self.cmdstring)
return
if args == "on": # get names of all channels available to listen to and activate them all
channels = [chan for chan in ChannelDB.objects.get_all_channels()
if chan.access(caller, 'listen')]
for channel in channels:
caller.execute_cmd("@command/join %s" % channel.key)
elif args == 'off':
# get names all subscribed channels and disconnect from them all
channels = ChannelDB.objects.get_subscriptions(caller)
for channel in channels:
caller.execute_cmd("@command/part %s" % channel.key)
elif args == 'who':
# run a who, listing the subscribers on visible channels.
string = "\n|CChannel subscriptions|n"
channels = [chan for chan in ChannelDB.objects.get_all_channels()
if chan.access(caller, 'listen')]
if not channels:
string += "No channels."
for channel in channels:
if not channel.access(self.caller, "control"):
continue
string += "\n|w%s:|n\n" % channel.key
subs = channel.db_subscriptions.all()
if subs:
string += " " + ", ".join([account.key for account in subs])
else:
string += " <None>"
self.msg(string.strip())
else:
# wrong input
self.msg("Usage: %s/all on | off | who | clear" % self.cmdstring)
elif 'remove' in self.switches or 'quiet' in self.switches:
if not self.args or not self.rhs:
switch = 'remove' if 'remove' in self.switches else 'quiet'
string = "Usage: %s/%s <channel> = <account> [:reason]" % (self.cmdstring, switch)
self.msg(string)
return
channel = find_channel(self.caller, self.lhs)
if not channel:
return
reason = ''
if ":" in self.rhs:
account_name, reason = self.rhs.rsplit(":", 1)
search_string = account_name.lstrip('*')
else:
search_string = self.rhs.lstrip('*')
account = self.caller.search(search_string, account=True)
if not account:
return
if reason:
reason = " (reason: %s)" % reason
if not channel.access(self.caller, "control"):
string = "You don't control this channel."
self.msg(string)
return
if account not in channel.db_subscriptions.all():
string = "Account %s is not connected to channel %s." % (account.key, channel.key)
self.msg(string)
return
if 'quiet' not in self.switches:
string = "%s boots %s from channel.%s" % (self.caller, account.key, reason)
channel.msg(string)
# find all account's nicks linked to this channel and delete them
for nick in [nick for nick in
account.character.nicks.get(category="channel") or []
if nick.db_real.lower() == channel.key]:
nick.delete()
channel.disconnect(account) # disconnect account
CHANNELHANDLER.update()
else: # just display the subscribed channels with no extra info
com_table = evtable.EvTable("|wchannel|n", "|wmy aliases|n",
"|wdescription|n", align="l", maxwidth=_DEFAULT_WIDTH)
for chan in subs:
c_lower = chan.key.lower()
nicks = caller.nicks.get(category="channel", return_obj=True)
com_table.add_row(*["%s%s" % (chan.key, chan.aliases.all() and
"(%s)" % ",".join(chan.aliases.all()) or ""),
"%s" % ",".join(nick.db_key for nick in make_iter(nicks)
if nick and nick.strvalue.lower() == c_lower),
chan.db.desc])
caller.msg("\n|wChannel subscriptions|n (use |[email protected]/list|n to list all, " +
"|w/join|n |w/part|n to join or part):|n\n%s" % com_table)