本文整理汇总了Python中model.User.open_id方法的典型用法代码示例。如果您正苦于以下问题:Python User.open_id方法的具体用法?Python User.open_id怎么用?Python User.open_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.open_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reply_game
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import open_id [as 别名]
def reply_game(**kwargs):
from model import User
username = kwargs.get('sender')
sender = kwargs.get('receiver')
message_type = kwargs.get('type')
content = kwargs.get('content', message_type)
user = User.objects(open_id = username)
if len(user) == 0:
user = User()
user.open_id = username
user.save()
if message_type == 'text':
return weixin.reply(
username, sender=sender, content=u'回复\"猜数字\"开始按照GUNNER提示进行猜数字!')
示例2: reply_check
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import open_id [as 别名]
def reply_check(**kwargs):
from model import User
username = kwargs.get('sender')
sender = kwargs.get('receiver')
message_type = kwargs.get('type')
content = kwargs.get('content', message_type)
user = User.objects(open_id = username)
if len(user) == 0:
user = User()
user.open_id = username
user.check_count = 1
user.save()
else:
try:
last_checked_day = user[0].checked_at.replace(hour=0,minute=0,second=0,microsecond=0)
c = user[0].check_count
delta = datetime.datetime.now() - last_checked_day
delta_days = delta.days
if delta_days < 1:
content=u'今日已签过了, 已连续签到%d日' %user[0].check_count
elif delta_days < 2 and delta_days >= 1:
user[0].update(inc__check_count=1)
content=u'签到完成, 已连续签到%d日' %user[0].check_count
user[0].update(inc__point=user[0].check_count)
else:
user[0].update(set__check_count=1)
content=u'签到完成, 已连续签到%d日' %user[0].check_count
user[0].update(inc__point=user[0].check_count)
except:
user[0].update(set__check_count=1)
content=u'签到完成, 已连续签到%d日' %user[0].check_count
user[0].update(inc__point=user[0].check_count)
finally:
user[0].update(set__checked_at=datetime.datetime.now())
return weixin.reply(
username, sender=sender, content=content
)
示例3: reply_all
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import open_id [as 别名]
def reply_all(**kwargs):
from model import User
username = kwargs.get('sender')
sender = kwargs.get('receiver')
message_type = kwargs.get('type')
content = kwargs.get('content', message_type)
if message_type == 'event':
event = kwargs.get('event')
if event == 'subscribe':
user = User.objects(open_id = username)
if len(user) == 0:
user = User()
user.open_id = username
user.save()
return weixin.reply(
username, sender=sender, content=u"欢迎来到GUNNER闲扯平台!\n回复“梦见 XX”可以解梦!\n例如回复:\"梦见 小偷\"(\"梦见\"后面有空格)\n回复\"游戏\"可以玩游戏!游戏有积分!\n回复【签到】,每天进行签到,签到有积分!\n回复【积分】查看积分\n闲的蛋疼可以聊天!\n也可以给我留言哦!"
)
elif event == 'unsubscribe':
pass
if message_type == 'voice':
recognition = kwargs.get('recognition')
return weixin.reply(
username, sender=sender, content=recognition
)
if content == 'news':
return weixin.reply(
username, type='news', sender=sender,
articles=[
{
'title': 'Weixin News',
'description': 'weixin description',
'picurl': '',
'url': 'http://xdream.info/',
}
]
)
else:
user = User.objects(open_id=username)
if len(user) > 0 and content.isdigit():
game_json = user[0].current_game
game = json.loads(game_json)
if game['name'] == 'guess_num':
guess_num = GuessNum(game['num'], int(game['count']), game['state'])
content = guess_num.game_routine(int(content))
game['count'] = guess_num.count
game['state'] = guess_num.state
if(game['state'] == 'finished'):
game['name'] = ''
count = 15 - guess_num.count
if count <= 0:
count = 0.1
point = count * 10
user[0].update(inc__point=point)
content = content + u'\n本次获得%d点积分' %point
j = json.dumps(game)
user[0].update(set__current_game=j)
#if game['name'] == '':
# content=u'请输入你要玩的游戏名!'
else:
content = xiaoi.chat(content, username)
return weixin.reply(
username, sender=sender, content=content
)