示例#1
0
文件: app.py 项目: cchgene/test123
def handle_follow(event):
    profile = line_bot_api.get_profile(event.source.user_id)
    name = profile.display_name
    uid = profile.user_id
    print(name)
    print(uid)

    if mongodb.find_user(uid, 'vusers') <= 0:
        dic = {
            'userid': uid,
            'username': name,
            'creattime': datetime.now(),
            'Note': 'user',
            'ready': 0
        }
        mongodb.insert_one(dic, 'vusers')
        add_mes = str(name) + '已經加入小鮮盒囉'
        line_bot_api.push_message(os.environ['gene_uid'],
                                  TextSendMessage(text=add_mes))
示例#2
0
def handle_follow(event):
    '''
    當使用者加入時觸動
    '''
    # 取得使用者資料
    profile = line_bot_api.get_profile(event.source.user_id)
    name = profile.display_name
    uid = profile.user_id
    
    print(name)
    print(uid)
    # Udbddac07bac1811e17ffbbd9db459079
    if mongodb.find_user(uid,'users')<= 0:
        # 整理資料
        dic = {'userid':uid,
               'username':name,
               'creattime':datetime.now(),
               'Note':'user',
               'ready':0}
        
        mongodb.insert_one(dic,'users')
                            'not found in anonymization map.'
                        sys.exit(1)
                    else:
                        new_user_id = anonymize.find_or_encode(fields[0])
                fields[0] = new_user_id

            if len(fields) != check_length:
                print >> sys.stderr, 'Line', line_number, 
                print >> sys.stderr, 'with incorrect number of elements'
                sys.exit(1)

            # Select the person with the ID and leave it in the cursor_obj
            if create_new_users:
                user_doc = mongodb.find_or_add_user(fields[0])
            else:
                user_doc = mongodb.find_user(fields[0])
            if user_doc == None:
                print >> sys.stderr, 'ID', fields[0], \
                    'not found in users. Skipping'
                skip_count += 1
                continue

            # Update the user with the data

            # Either print or execute the query
            label_dict = dict(zip(labels, fields[1:]))
            if dryRun:
                print >> sys.stderr, "Insert {'_id': " + str(user_doc) + '}'
                print >> sys.stderr, label_dict
            else:
                print >> sys.stderr, "Insert {'_id': " + str(user_doc) + '}'