本文整理汇总了Python中models.user.User.exists方法的典型用法代码示例。如果您正苦于以下问题:Python User.exists方法的具体用法?Python User.exists怎么用?Python User.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.user.User
的用法示例。
在下文中一共展示了User.exists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_user
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import exists [as 别名]
def from_user(self, receivers=None, text=None, *_):
if receivers is None:
return ERR_NORECIPIENT(self.command, self.actor)
if text is None:
return ERR_NOTEXTTOSEND(self.actor)
resp = []
# TODO: check for ERR_TOOMANYTARGETS
for receiver in receivers.split(','):
if Channel.exists(receiver):
users = [user
for user in Channel.get(receiver).users
if user is not self.user]
resp.append(M(
ActorCollection(users),
self.command, str(receiver), text,
prefix=str(self.user)))
elif User.exists(receiver):
resp.append(M(
Actor.by_user(User.get(receiver)),
self.command, str(receiver), text,
prefix=str(self.user)))
# TODO: Implement wildcards
# TODO: check for ERR_WILDTOPLEVEL, RPL_AWAY, ERR_NOTOPLEVEL
else:
resp.append(ERR_NOSUCHNICK(receiver, self.actor))
return resp
示例2: check_local_nickcollision
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import exists [as 别名]
def check_local_nickcollision(self):
# no such nick yet
if not User.exists(self.params.nick):
return
# client sending its own nickname
if self.user.registered.nick and\
self.user.registered.user and\
self.user is User.get(self.params.nick):
return ReturnNone
# real collision
return ERR_NICKNAMEINUSE(self.params.nick, self.actor)
示例3: from_user
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import exists [as 别名]
def from_user(self, receivers=None, text=None, *_):
if receivers is None:
return ERR_NORECIPIENT(self.command, self.actor)
if text is None:
return ERR_NOTEXTTOSEND(self.actor)
resp = []
# TODO: check for ERR_TOOMANYTARGETS
for receiver in receivers.split(','):
if Channel.exists(receiver):
channel_log = '%s/%s.log' % ( config.get('server', 'channel_log_dir'), receiver.replace('#',''))
# if not PrivmsgCommand.channel_log_files.get(channel_log):
# PrivmsgCommand.channel_log_files[channel_log] = open(channel_log,'a')
# PrivmsgCommand.channel_log_files[channel_log].write("%s::%s::%s::%s\n" % (
# time.time(), time.strftime('%Y-%m-%d %H:%I:%S'), self.user.nickname, text
# ))
# PrivmsgCommand.channel_log_files[channel_log].flush()
with open(channel_log,'a') as f:
f.write("%s::%s::%s::%s\n" % (
time.time(), time.strftime('%Y-%m-%d %H:%I:%S'), self.user.nickname, text
))
f.flush()
users = [user for user in Channel.get(receiver).users if user is not self.user]
resp.append(M(
ActorCollection(users),
self.command, str(receiver), text,
prefix=str(self.user)
))
elif User.exists(receiver):
resp.append(M(
Actor.by_user(User.get(receiver)),
self.command, str(receiver), text,
prefix=str(self.user)
))
# TODO: Implement wildcards
# TODO: check for ERR_WILDTOPLEVEL, RPL_AWAY, ERR_NOTOPLEVEL
else:
resp.append(ERR_NOSUCHNICK(receiver, self.actor))
return resp