Beispiel #1
0
def create_group(bot, update, args):
    if util.too_few_args(bot, util.get_chat_id(update), args, 1) is None:
        return

    if re.fullmatch("\w+", args[0]) is None:
        bot.send_message(chat_id=util.get_chat_id(update),
                         text=answers.incorrect_name)
        return
    try:
        print("cursor = ", util.cursor)
        BD.create_group(util.cursor, util.get_user_id(update), args[0])
    except util.GroupAlreadyExistsException:
        bot.send_message(chat_id=util.get_chat_id(update),
                         text=answers.already_exists_name % "группа")
Beispiel #2
0
def delete_project(bot, update, args):
    if util.too_few_args(bot, util.get_chat_id(update), args, 1) is None:
        return
    if re.fullmatch("\w+", args[0]) is None:
        bot.send_message(chat_id=util.get_chat_id(update),
                         text=answers.incorrect_name + "(проекта)")
        return
    try:
        BD.delete_project(util.cursor, util.get_user_id(update), args[0])
    except util.ProjectNotExistsException:
        bot.send_message(chat_id=util.get_chat_id(update),
                         text=answers.no_exists_name % "проект")
    except util.UserIsNotAdmin:
        bot.send_message(chat_id=util.get_chat_id(update),
                         text=answers.delete_no_admin % "проект")
Beispiel #3
0
def enter_group(bot, update, args):
    if util.too_few_args(bot, util.get_chat_id(update), args, 1) is None:
        return
    if re.fullmatch("\w+", args[0]) is None:
        bot.send_message(chat_id=util.get_chat_id(update),
                         text=answers.incorrect_name)
        return
    try:
        admin_id = BD.get_admin(util.cursor, args[0])
        bot.send_message(chat_id=admin_id,
                         text="Пожалуйста присоедините меня к " + args[0] +
                         " мой ID: " + util.get_user_id(update))
    except util.GroupNotExistsException:
        bot.send_message(chat_id=util.get_chat_id(update),
                         text=answers.no_exists_name % "группа")
Beispiel #4
0
def unjoin_user(bot, update, args):
    if util.too_few_args(bot, util.get_chat_id(update), args, 2) is None:
        return
    if re.fullmatch("\w+", args[0]) is None:
        bot.send_message(chat_id=util.get_chat_id(update),
                         text=answers.incorrect_name)
        return
    try:
        BD.unjoin_user(util.cursor, args[1], args[0], util.get_user_id(update))
    except util.GroupNotExistsException:
        bot.send_message(chat_id=util.get_chat_id(update),
                         text=answers.no_exists_name % "группа")
    except util.UserIsNotAdmin:
        bot.send_message(chat_id=util.get_chat_id(update),
                         text=answers.delete_no_admin % "пользователя")
Beispiel #5
0
def hide_task(bot, update, args):
    if util.too_few_args(bot, util.get_chat_id(update), args, 2) is None:
        return
    names = ("(проекта)", "(таска)")
    for i in range(2):
        if re.fullmatch("\w+", args[i]) is None:
            bot.send_message(chat_id=util.get_chat_id(update), text=answers.incorrect_name + names[i])
            return
    try:
        BD.set_task(util.cursor, util.get_user_id(update), args[1], None, True)#,args[0])
    except util.ProjectNotExistsException:
        bot.send_message(chat_id=util.get_chat_id(update), text=answers.no_exists_name % "проект")
    except util.TaskNotExistsException:
        bot.send_message(chat_id=util.get_chat_id(update), text=answers.already_exists_name % "таск")
    except util.UserHasNotTask:
        bot.send_message(chat_id=util.get_chat_id(update), text=answers.create_no_admin % "таск")
Beispiel #6
0
def exit_group(bot, update, args):
    if util.too_few_args(bot, util.get_chat_id(update), args, 1) is None:
        return
    if re.fullmatch("\w+", args[0]) is None:
        bot.send_message(chat_id=util.get_chat_id(update),
                         text=answers.incorrect_name)
        return
    try:
        admin_id = BD.get_admin(util.cursor, args[0])
        BD.unjoin_user(util.cursor,
                       user_id=util.get_user_id(update),
                       admin_id=admin_id,
                       group_name=args[0])
        bot.send_message(chat_id=admin_id,
                         text="Человек с ID " + str(util.get_user_id(update)) +
                         "покинул группу " + args[0])
    except util.GroupNotExistsException:
        bot.send_message(chat_id=util.get_chat_id(update),
                         text=answers.no_exists_name % "группа")
    except util.UserIsNotAdmin:
        bot.send_message(chat_id=util.get_chat_id(update),
                         text=answers.delete_no_admin % "пользователя")
Beispiel #7
0
def find_botan(bot, update, args):
    if len(args) % 2 == 0:
        bot.send_message(chat_id=util.get_chat_id(update), text=answers.incorrect_input_tasks)
        return
    for i in range(1, len(args), 2):
        if args[i] != 'u' and args[i] != 'd':
            bot.send_message(chat_id=util.get_chat_id(update), text=answers.incorrect_input_tasks)

    tasks = [(args[i], args[i + 1] == 'd') for i in range(1, len(args), 2)]

    try:
        botans = BD.find_botan(util.cursor, tasks)#,args[0])
        bot.send_message(chat_id=util.get_chat_id(update), text='\n'.join(botans))
    except util.ProjectNotExistsException:
        bot.send_message(chat_id=util.get_chat_id(update), text=answers.no_exists_name % "проект")
    except util.TaskNotExistsException:
        bot.send_message(chat_id=util.get_chat_id(update), text=answers.already_exists_name % "таск")
    except util.UserHasNotTask:
        bot.send_message(chat_id=util.get_chat_id(update), text=answers.create_no_admin % "таск")