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


Python User.find_or_create_by_nick方法代码示例

本文整理汇总了Python中model.User.find_or_create_by_nick方法的典型用法代码示例。如果您正苦于以下问题:Python User.find_or_create_by_nick方法的具体用法?Python User.find_or_create_by_nick怎么用?Python User.find_or_create_by_nick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.User的用法示例。


在下文中一共展示了User.find_or_create_by_nick方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: game_on_game_in_progress

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import find_or_create_by_nick [as 别名]
    def game_on_game_in_progress(self, g):
        for player in g.players:
            self.send_message(player.name, message.game.in_progress, server=g.server.name, password=g.password, \
                              ip=g.server.address[0], port=g.server.address[1])
            
            user = User.find_or_create_by_nick(player.name)
            if not user.games_played: user.games_played = 0
            user.games_played += 1
            user.save()
        
        user = User.find_or_create_by_nick(g.owner)
        if not user.games_admined: user.games_admined = 0
        user.games_admined += 1
        user.save()
        
        game_mode = "highlander" if g.is_highlander else "%sv%s" % (g.max_players / 2, g.max_players / 2)
        team_groups = (g.get_class_groups() if g.is_highlander else g.get_team_groups())
        team_groups = dict(map(lambda k: (str(k), team_groups[k]), team_groups))
        game = Game(created_at=datetime.datetime.now(), mode=game_mode, server=g.server.name, \
                    map=g.map, admin=g.owner, teams=team_groups)
        game.save()

        #self.set_topic_game_inprogress()
        self.game_end()

        self.send_message(message.game.sent_password)
开发者ID:bawNg,项目名称:pyPickup,代码行数:28,代码来源:bot.py

示例2: cmd_set

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import find_or_create_by_nick [as 别名]
 def cmd_set(self, c, e):
     if e.payload == "user":
         user = User.find_or_create_by_nick(e.args[1])
         attr, value = e.args[2].split("=", 1)
         setattr(user, attr, int(value) if value.isdigit() else value)
         user.save()
         self.send_msg("Set attribute [%s] for user [%s] to value [%s]." % (attr, user.nickname, value))
开发者ID:bawNg,项目名称:pyPickup,代码行数:9,代码来源:command_handler.py

示例3: on_dcc_connect

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import find_or_create_by_nick [as 别名]
 def on_dcc_connect(self, c, e):
     #user = User.find_one({'nickname': c.nick})
     user = User.find_or_create_by_nick(c.nick)
     user.last_ip_address = e.source()
     user.save()
     print "[on_dcc_connect] Updated ip address from nickname [%s] to [%s]." % (c.nick, e.source())
     c.privmsg("Your IP has been authorized for web interface access.")
     c.disconnect()
     self.httpd.status[c.nick] = "updated"
开发者ID:bawNg,项目名称:pyPickup,代码行数:11,代码来源:bot.py


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