<commit_before>#!/usr/bin/python3
import extensions.users
import logger


def s_show_user_admin(user_id, _):
    if users.is_user_admin(user_id):
        return 'User {} is admin'.format(user_id)
    else:
        return 'User {} isn\'t admin'.format(user_id)


def s_set_user_admin(user_id, admin_flag):
    users.set_user_admin(user_id, admin_flag == 'true')
    return 'User {} admin status is now {}'.format(user_id, admin_flag)


def s_add_user_group(user_id, group_name):
    users.add_user_to_group(user_id, group_name)
    return 'User {} added to group {}'.format(user_id, group_name)


def s_delete_user_group(user_id, group_name):
    users.delete_user_from_group(user_id, group_name)
    return 'User {} deleted from group {}'.format(user_id, group_name)


def s_show_user_groups(user_id, _):
    user_groups = users.list_groups(user_id)
    return 'User {} is in following groups: {}'.format(user_id, ', '.join(user_groups))


def run(message):
    logger.info('Starting user control')
    if not users.is_user_admin(message['from']['id']):
        return 'Sorry, this option avaible only for admins'
    subcommands = {
        ('set', 'admin'): s_set_user_admin,
        ('show', 'admin'): s_show_user_admin,
        ('add', 'group'): s_add_user_group,<commit_msg>Extensions bug fix #2<commit_after>#!/usr/bin/python3
import extensions.users
import logger


def s_show_user_admin(user_id, _):
    if extensions.users.is_user_admin(user_id):
        return 'User {} is admin'.format(user_id)
    else:
        return 'User {} isn\'t admin'.format(user_id)


def s_set_user_admin(user_id, admin_flag):
    extensions.users.set_user_admin(user_id, admin_flag == 'true')
    return 'User {} admin status is now {}'.format(user_id, admin_flag)


def s_add_user_group(user_id, group_name):
    extensions.users.add_user_to_group(user_id, group_name)
    return 'User {} added to group {}'.format(user_id, group_name)


def s_delete_user_group(user_id, group_name):
    extensions.users.delete_user_from_group(user_id, group_name)
    return 'User {} deleted from group {}'.format(user_id, group_name)


def s_show_user_groups(user_id, _):
    user_groups = extensions.users.list_groups(user_id)
    return 'User {} is in following groups: {}'.format(user_id, ', '.join(user_groups))


def run(message):
    logger.info('Starting user control')
    if not extensions.users.is_user_admin(message['from']['id']):
        return 'Sorry, this option avaible only for admins'
    subcommands = {
        ('set', 'admin'): s_set_user_admin,
        ('show', 'admin'): s_show_user_admin,
        ('add', 'group'): s_add_user_group,
{'fraction_non_alphanumeric': 0.1310790273556231, 'fraction_numerical': 0.0011398176291793312, 'mean_word_length': 4.440082644628099, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3776307', 'n_tokens_mistral': 913, 'n_tokens_neox': 896, 'n_words': 190}