コード例 #1
0
ファイル: filter_accounts.py プロジェクト: ocf/create-old
def filter_accounts(users, options):
    """Filter accounts into accepted, needs-staff-approval, and rejected."""
    accepted = list(users)
    needs_approval = []
    rejected = []

    # Check for log duplicates
    # accepted, needs_approval, rejected = \
    #   _filter_log_duplicates(accepted, needs_approval, rejected, options)

    # Check for account name duplicates
    accepted, needs_approval, rejected = \
        _filter_account_name_duplicates(accepted, needs_approval, rejected,
                                        options)

    # Check for owner duplicates
    accepted, needs_approval, rejected = \
        _filter_owner_duplicates(accepted, needs_approval, rejected, options)

    # Check for CalNet UID duplicates
    accepted, needs_approval, rejected = \
        _filter_university_uid_duplicates(accepted, needs_approval, rejected,
                                          options)

    # Check for email address duplicates
    # accepted, needs_approval, rejected = \
    #   _filter_email_duplicates(accepted, needs_approval, rejected, options)

    # Check for OCF existing account duplicates
    accepted, needs_approval, rejected = \
        _filter_ocf_duplicates(accepted, needs_approval, rejected,
                               options)

    # Check CalNet registration status
    accepted, needs_approval, rejected = \
        _filter_registration_status(accepted, needs_approval, rejected,
                                    options)

    # Check for expletives and restrictions in requested usernames
    accepted, needs_approval, rejected = \
        _filter_restricted_names(accepted, needs_approval, rejected, options)

    # Check that requested username is based on real name
    accepted, needs_approval, rejected = \
        _filter_real_names(accepted, needs_approval, rejected, options)

    # Write the accepted users to a staging file, allowing them marinate
    with fancy_open(options.mid_approve, "a", lock=True) as f:
        write_users(f, accepted)

    # Email out this information
    _send_rejection_mail(rejected, options)

    return needs_approval
コード例 #2
0
ファイル: create.py プロジェクト: ocf/create-old
def filter_stage(options):
    """Filter accounts in the first stage into mid-approval."""
    # Process all of the recently requested accounts
    with fancy_open(options.users_file, lock = True,
                    pass_missing = True) as f:
        needs_approval = filter_accounts(get_users(f, options), options)

    for user, comment in needs_approval:
        msg = "`{}` ({}) needs approval: {}".format(user['account_name'], user['owner'], comment)
        write_and_alert('/srv/atool/pending', msg, all=True)

    # Write the users needing staff approval back to the users file
    with fancy_open(options.users_file, "w", lock = True) as f:
        write_users(f, [user for user, comment in needs_approval])
コード例 #3
0
ファイル: bot.py プロジェクト: ignatovskiy/Tagger
def community_handling(message, user_id):
    bot = updater.bot

    users = utils.read_users()

    message = message.replace("https://vk.com/", "")
    photo_name = 'test1.jpg'

    group_id = vk_bot.get_group_id(message)

    users[user_id] = str(group_id)
    utils.write_users(users)

    if group_id is not False:
        bot.send_message(
            chat_id=user_id,
            text=
            "Идет обработка постов сообщества. Пожалуйста, подождите (~50 секунд)"
        )
        pics = vk_bot.get_wall_pics_by_id(group_id, 10)

        all_tags = []
        pics_dict = dict()

        for pic in pics:
            vk_bot.save_pic(pic[0])
            tags = get_tags(photo_name)

            all_tags.extend(tags)
            pics_dict[pic[1]] = tags

        with open(str(group_id), "w", encoding="UTF-8") as f:
            json.dump(pics_dict, f)

        tags = ", ".join(set(all_tags))
        text = "Сообщество {} зарегистрировано, теперь выберите интересующий вас тег " \
               "или отправьте ссылку на другое сообщество. \n\nТеги:\n\n".format(message)

        bot.send_message(chat_id=user_id, text=text + tags)

    else:
        bot.send_message(
            chat_id=user_id,
            text="Ошибка, данного сообщества не существует или оно закрытое.")