当前位置: 首页>>代码示例>>Python>>正文


Python User.exists方法代码示例

本文整理汇总了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
开发者ID:Cloudxtreme,项目名称:python-ircd,代码行数:28,代码来源:privmsg.py

示例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)
开发者ID:Cloudxtreme,项目名称:python-ircd,代码行数:13,代码来源:nick.py

示例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
开发者ID:Slach,项目名称:python-ircd,代码行数:41,代码来源:privmsg.py


注:本文中的models.user.User.exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。