コード例 #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 % "группа")
コード例 #2
0
ファイル: project_func.py プロジェクト: vstanka/BotanNET
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 % "проект")
コード例 #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 % "группа")
コード例 #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 % "пользователя")
コード例 #5
0
ファイル: task_func.py プロジェクト: vstanka/BotanNET
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 % "таск")
コード例 #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 % "пользователя")