Exemplo n.º 1
0
def start(message):
    user_type = message.text.split(" ")[1]
    users[message.chat.id] = user_info()
    if user_type == "admin":
        users[message.chat.id].user = Admin()
        bot.send_message(message.chat.id,
                         "Choose action",
                         reply_markup=bot_features.get_inline_markup(
                             u.keyboard_admin_buttons_home))
    elif user_type == "student":
        users[message.chat.id].user = Student(id=message.chat.id,
                                              alias=message.chat.username,
                                              name=(message.chat.first_name +
                                                    message.chat.last_name),
                                              mail="somemail",
                                              number="someNumber",
                                              address="SomeAddress")
        bot.send_message(message.chat.id,
                         "Now choose what you want to do",
                         reply_markup=bot_features.get_inline_markup(
                             u.keyboard_patron_buttons_home))
    elif user_type == "librarian":
        users[message.chat.id].user = Librarian(id=message.chat.id,
                                                alias=message.chat.username,
                                                name=(message.chat.first_name +
                                                      message.chat.last_name),
                                                mail="somemail",
                                                number="someNumber",
                                                address="SomeAddress",
                                                priv=3)
        bot.send_message(message.chat.id,
                         "Now choose what you want to do",
                         reply_markup=bot_features.get_inline_markup(
                             u.keyboard_librarian_buttons_home))
Exemplo n.º 2
0
def back(call):
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
                          text="Now choose what you want to do")
    if not aut.if_librarian(call.message.chat.id):
        bot.edit_message_reply_markup(chat_id=call.message.chat.id, message_id=call.message.message_id,
                                      reply_markup=bot_features.get_inline_markup(u.keyboard_patron_buttons_home))
    else:
        bot.edit_message_reply_markup(chat_id=call.message.chat.id, message_id=call.message.message_id,
                                      reply_markup=bot_features.get_inline_markup(u.keyboard_librarian_buttons_home))
Exemplo n.º 3
0
def back(call):
    if type(users[call.message.chat.id].user) == Admin:
        markup = bot_features.get_inline_markup(u.keyboard_admin_buttons_home)
    elif type(users[call.message.chat.id].user) == Librarian:
        markup = bot_features.get_inline_markup(
            u.keyboard_librarian_buttons_home)
    else:
        markup = bot_features.get_inline_markup(u.keyboard_patron_buttons_home)
    bot.edit_message_text(chat_id=call.message.chat.id,
                          message_id=call.message.message_id,
                          text="Now choose what you want to do",
                          reply_markup=markup)
Exemplo n.º 4
0
def library(call):
    users[call.message.chat.id].action = call.data
    bot.edit_message_text(chat_id=call.message.chat.id,
                          message_id=call.message.message_id,
                          text="Choose type of doc",
                          reply_markup=bot_features.get_inline_markup(
                              u.keyboard_buttons_library))
Exemplo n.º 5
0
def delete(call):
    print(user[call.message.chat.id].type)
    print(user[call.message.chat.id].object)
    print(user[call.message.chat.id].object.summary())
    if is_human(call.message.chat.id):
        if type(user[call.message.chat.id].me) == Admin:
            u.current.name = user[call.message.chat.id].object.get_id()
            Admin().remove(user[call.message.chat.id].object.get_id())
        else:
            u.current.name = user[call.message.chat.id].object.get_id()
            print(u.current.name)
            user[call.message.chat.id].me.remove(
                user[call.message.chat.id].object.get_id())
            # db.delete(id=user[call.message.chat.id].object.get_id())
    else:
        u.current.name = user[call.message.chat.id].object.get_title()
        user[call.message.chat.id].me.remove_document(
            user[call.message.chat.id].object.get_title())
        # db.delete(title=user[call.message.chat.id].object.get_title())
    bot.edit_message_text(chat_id=call.message.chat.id,
                          message_id=call.message.message_id,
                          text="{} is deleted from list of {}".format(
                              u.current.name, user[call.message.chat.id].type),
                          reply_markup=bot_features.get_inline_markup(
                              u.keyboard_button_back))
Exemplo n.º 6
0
def reserve(call):
    bot.edit_message_text(
        chat_id=call.message.chat.id,
        message_id=call.message.message_id,
        text=b.booking(user[call.message.chat.id].me,
                       user[call.message.chat.id].object, call.data),
        reply_markup=bot_features.get_inline_markup(u.keyboard_button_back))
Exemplo n.º 7
0
def patron_waiting_list(call):
    # TODO:прикрутить сам вейтинг лист и какое то уведомление молодого о том, когда появится книга
    b.booking(usr=db.get(id=call.chat.id)[0], document=u.multithreading[str(call.message.chat.id)].current_object)
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
                          text="You are added to the waiting list for {}".format(u.multithreading[str(call.message.chat.id)].current_object.get_id()))
    bot.edit_message_reply_markup(chat_id=call.message.chat.id, message_id=call.message.message_id,
                                  reply_markup=bot_features.get_inline_markup(u.keyboard_button_back))
Exemplo n.º 8
0
def address(call):
    print(call.text)
    u.multithreading[str(call.chat.id)].auth_val_arr.append(call.text)
    # TODO: сохранить адрес(call.text) в дб
    temp = dict()
    for i in range(3):
        temp[u.multithreading[str(call.chat.id)].auth_arr[i]] = u.multithreading[str(call.chat.id)].auth_val_arr[i]
    temp["id"] = call.chat.id
    temp["alias"] = call.from_user.username
    temp["mail"] = u.multithreading[str(call.chat.id)].current_email

    id = temp["id"]
    name = temp["name"]
    mail = temp["mail"]
    number = temp["number"]
    alias = temp["alias"]
    address = temp["address"]

    if facbase.is_instructor(id):
        usr = Instructor(id, alias, name, mail, number, address)
    elif facbase.is_ta(id):
        usr = TA(id, alias, name, mail, number, address)
    elif facbase.is_professor(id):
        usr = Professor(id, alias, name, mail, number, address)
    elif facbase.is_vp(id):
        usr = VP(id, alias, name, mail, number, address)
    else:
        usr = Student(id, alias, name, mail, number, address)

    db.insert(usr.summary())
    print(temp)

    u.multithreading[str(call.chat.id)] = u.current()
    bot.send_message(call.chat.id, "Congratulations, registration is finished. Now choose, what do you want to do",
                     reply_markup=bot_features.get_inline_markup(u.keyboard_patron_buttons_home))
Exemplo n.º 9
0
def admin(call):
    user[call.chat.id] = user_info()
    user[call.chat.id].me = Admin()
    bot.send_message(call.chat.id,
                     "Choose action",
                     reply_markup=bot_features.get_inline_markup(
                         u.keyboard_admin_buttons_home))
Exemplo n.º 10
0
def greeting(message):
    # TODO: Проверить, есть ли чел в дб, если да, то на его стартовый экран, если нет - то инициализация
    exist = aut.check(message.chat.id)
    u.multithreading[str(message.chat.id)] = u.current()
    if not exist:
        print(message)
        message = bot.send_message(message.chat.id, "Please send your e-mail with @innopolis.ru")
        bot.register_next_step_handler(message, auth)
    else:
        if aut.if_librarian(message.chat.id):
            print("librarian")
            bot.send_message(message.chat.id, "Now choose what you want to do",
                             reply_markup=bot_features.get_inline_markup(u.keyboard_librarian_buttons_home))
        else:
            bot.send_message(message.chat.id, "Now choose what you want to do",
                             reply_markup=bot_features.get_inline_markup(u.keyboard_patron_buttons_home))
        print(str(u.multithreading))
Exemplo n.º 11
0
def docs_on_hands(call):
    u.multithreading[str(call.message.chat.id)].field = "Patron docs"  # TODO: обратиться по типу
    all_docs_objects = db.get(type_book="Book") + db.get(type_book="Article") + db.get(type_book="AV")
    u.multithreading[str(call.message.chat.id)].db_to_search = [all_docs_objects[i].get_title() for i in range(len(all_docs_objects))]
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
                          text="docs on hands are {}".format(u.multithreading[str(call.message.chat.id)].db_to_search))
    bot.edit_message_reply_markup(chat_id=call.message.chat.id, message_id=call.message.message_id,
                                  reply_markup=bot_features.get_inline_markup([["OK!", "Back"]]))
Exemplo n.º 12
0
def initialize_librarian(call):
    queue = users[call.message.chat.id].object.get_queue()
    bot.edit_message_text(chat_id=call.message.chat.id,
                          message_id=call.message.message_id,
                          text="{} are now in the waiting list".format(queue),
                          reply_markup=bot_features.get_inline_markup(
                              [["Make request", "Outstanding Request"],
                               ["OK", "Back"]]))
Exemplo n.º 13
0
def initialize_librarian(call):
    users[call.message.chat.id].user.set_outstanding(
        get_property(users[call.message.chat.id].object, 0))
    bot.edit_message_text(chat_id=call.message.chat.id,
                          message_id=call.message.message_id,
                          text="Request is done",
                          reply_markup=bot_features.get_inline_markup(
                              u.keyboard_button_back))
Exemplo n.º 14
0
def docs_on_hands(call):
    u.field = "Patron docs"  # TODO: обратиться по типу                 DEFUNCT (slojna)
    # u.db_to_search = get_db(id=call.message.chat.id)
    bot.edit_message_text(chat_id=call.message.chat.id,
                          message_id=call.message.message_id,
                          text="docs of user users are {}".format(),
                          reply_markup=bot_features.get_inline_markup(
                              [["OK!", "Back"]]))
Exemplo n.º 15
0
def my_docs(call):
    u.multithreading[str(call.message.chat.id)].field = "Patron docs"
    u.multithreading[str(call.message.chat.id)].db_to_search = list(db.get(id=call.message.chat.id)[0].get_docs_list().keys())
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
                          text="Enter doc from list {}".format(u.multithreading[str(call.message.chat.id)].db_to_search))
    bot.edit_message_reply_markup(chat_id=call.message.chat.id, message_id=call.message.message_id,
                                  reply_markup=bot_features.get_inline_markup(u.keyboard_button_back))
    bot.register_next_step_handler(call.message, search)
Exemplo n.º 16
0
def renew(call):
    u.multithreading[str(call.message.chat.id)].field = "Patron docs"  # TODO: обратиться в дб по полю
    # u.db_to_search = get_db(u.field)
    # u.db_to_search.append(u.current_object.text)
    b.booking(usr=db.get(id=call.message.chat.id)[0], document=u.multithreading[str(call.message.chat.id)].current_object, time=u.multithreading[str(call.message.chat.id)].time)
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
                          text="{} is added to {}".format(u.multithreading[str(call.message.chat.id)].current_object.get_title(), u.multithreading[str(call.message.chat.id)].field))
    bot.edit_message_reply_markup(chat_id=call.message.chat.id, message_id=call.message.message_id,
                                  reply_markup=bot_features.get_inline_markup(u.keyboard_button_back))
Exemplo n.º 17
0
def edit(call):
    buttons = u.get_buttoms(
        users[call.message.chat.id].object.summary()["type"])
    buttons += [["Back", "Back"]]
    bot.edit_message_text(chat_id=call.message.chat.id,
                          message_id=call.message.message_id,
                          text="Choose parameter to edit:",
                          reply_markup=bot_features.get_inline_markup(buttons),
                          parse_mode="markdown")
Exemplo n.º 18
0
def search_patron(call):
    u.multithreading[str(call.message.chat.id)].field = "Emails"  # TODO: list of emails
    u.multithreading[str(call.message.chat.id)].db_to_search = db.get_all_similar_info(mail="yes")
    print("Hello, these are emails " + str(u.multithreading[str(call.message.chat.id)].db_to_search))
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
                          text="Enter e-mail from list {} \n or type e-mail of new user".format(u.multithreading[str(call.message.chat.id)].db_to_search))
    bot.edit_message_reply_markup(chat_id=call.message.chat.id, message_id=call.message.message_id,
                                  reply_markup=bot_features.get_inline_markup(u.keyboard_button_back))
    bot.register_next_step_handler(call.message, search)
Exemplo n.º 19
0
def my_docs(call):
    users[call.message.chat.id].action = call.data
    user_docs = users[call.message.chat.id].user.get_docs_list()
    bot.edit_message_text(chat_id=call.message.chat.id,
                          message_id=call.message.message_id,
                          text="Enter doc from list {}".format(user_docs),
                          reply_markup=bot_features.get_inline_markup(
                              u.keyboard_button_back))
    bot.register_next_step_handler(call.message, search)
Exemplo n.º 20
0
def initialize_librarian(call):
    # TODO: прикрутить сам лист
    l = list(db.get(title=u.multithreading[str(call.message.chat.id)].current_object.get_title())[0].get_queue().values())
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
                          text="{} now in the waiting list".format(l))
    bot.edit_message_reply_markup(chat_id=call.message.chat.id, message_id=call.message.message_id,
                                  reply_markup=bot_features.get_inline_markup(
                                      [["Make  outsanding request", "Outstanding Request"],
                                       ["Back", "Back"]]))
Exemplo n.º 21
0
def initialize_librarian(call):
    # TODO: проверить работоспособность
    user[call.message.chat.id].me.set_outstanding(
        user[call.message.chat.id].object.get_title())
    bot.edit_message_text(chat_id=call.message.chat.id,
                          message_id=call.message.message_id,
                          text="Request is done",
                          reply_markup=bot_features.get_inline_markup(
                              u.keyboard_button_back))
Exemplo n.º 22
0
def man_lib(call):

    pass
    bot.edit_message_text(
        chat_id=call.message.chat.id,
        message_id=call.message.message_id,
        text="type email of Librarian from list\n{}".format(list_of_libs),
        reply_markup=bot_features.get_inline_markup(u.keyboard_button_back))
    bot.register_next_step_handler(call.message, smart_search)
Exemplo n.º 23
0
def editing(call):
    user[call.message.chat.id].attr = call.data[1:]

    bot.edit_message_text(
        chat_id=call.message.chat.id,
        message_id=call.message.message_id,
        text="Enter new parameter for {} of {}".format(
            call.data[1:], user[call.message.chat.id].title_or_name),
        reply_markup=bot_features.get_inline_markup(u.keyboard_button_back))
    bot.register_next_step_handler(call.message, edited)
Exemplo n.º 24
0
def edit(call):
    print(user[call.message.chat.id].type)
    buttons = u.get_buttoms(user[call.message.chat.id].type)
    buttons += [["Back", "Back"]]
    print(buttons)
    bot.edit_message_text(chat_id=call.message.chat.id,
                          message_id=call.message.message_id,
                          text="Choose parameter to edit:",
                          reply_markup=bot_features.get_inline_markup(buttons),
                          parse_mode="markdown")
Exemplo n.º 25
0
def delete(call):
    db.delete(id=aut.check_user(u.multithreading[str(call.message.chat.id)].current_object.summary()), title=aut.check_doc(u.multithreading[str(call.message.chat.id)].current_object.summary()))
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
                          text="{} is deleted from {}".format(
                              u.multithreading[str(call.message.chat.id)].current_object.get_title() if isinstance(u.multithreading[str(call.message.chat.id)].current_object, Book) or isinstance(
                                  u.multithreading[str(call.message.chat.id)].current_object, Article) or isinstance(u.multithreading[str(call.message.chat.id)].current_object,
                                                                           AV_Materials) else u.multithreading[str(call.message.chat.id)].current_object.get_id(),
                              u.multithreading[str(call.message.chat.id)].field))
    bot.edit_message_reply_markup(chat_id=call.message.chat.id, message_id=call.message.message_id,
                                  reply_markup=bot_features.get_inline_markup(u.keyboard_button_back))
Exemplo n.º 26
0
def log(call):
    date = get_date()
    get_log()
    doc = open('log.txt', mode='rb')
    bot.send_document(chat_id=call.message.chat.id, data=doc)
    bot.edit_message_text(chat_id=call.message.chat.id,
                          message_id=call.message.message_id,
                          text="Log for: " + date,
                          reply_markup=bot_features.get_inline_markup(
                              u.keyboard_button_back))
Exemplo n.º 27
0
def edit(call):
    types = get_type(u.multithreading[str(call.message.chat.id)].field)
    text_types = ""  # TODO: update of one field
    print(str(types))
    for i in range(0, len(types)):
        text_types += ("{}\n".format(types[i][0]))
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
                          text="Choose parameter to edit:".format(text_types))
    bot.edit_message_reply_markup(chat_id=call.message.chat.id, message_id=call.message.message_id,
                                  reply_markup=bot_features.get_inline_markup(types))
Exemplo n.º 28
0
def add(call):
    list = ""
    print(u.current.field)
    print(get_type(u.current.field)[1][0])
    for i in range(len(get_type(u.current.field))):
        list+="{}, ".format(get_type(u.current.field)[i][0])
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
                          text="Enter values for the following fields using new line and commas: {}".format(list))#(get_type(u.current_object)))#TODO: fields этого объекта
    bot.edit_message_reply_markup(chat_id=call.message.chat.id, message_id=call.message.message_id,
                                  reply_markup=bot_features.get_inline_markup(u.keyboard_button_back))
    bot.register_next_step_handler(call.message, adding)
Exemplo n.º 29
0
def get_info(call):
    temp = user[call.message.chat.id].object.summary()
    obj = ""
    for i in temp:
        if i != "queue":
            obj += str(i) + " : " + str(temp.get(i)) + "\n"
    obj.strip()
    bot.edit_message_text(chat_id=call.message.chat.id,
                          message_id=call.message.message_id,
                          text=obj,
                          reply_markup=bot_features.get_inline_markup(
                              u.keyboard_button_back))
Exemplo n.º 30
0
def my_docs(call):
    user[call.message.chat.id].type = "Emails"
    user[call.message.chat.id].list_of_objects = db.get(
        id=call.message.chat.id)[0].get_docs_list()
    print(type(user[call.message.chat.id].list_of_objects) == dict)
    bot.edit_message_text(chat_id=call.message.chat.id,
                          message_id=call.message.message_id,
                          text="Enter doc from list {}".format(
                              user[call.message.chat.id].list_of_objects),
                          reply_markup=bot_features.get_inline_markup(
                              u.keyboard_button_back))
    bot.register_next_step_handler(call.message, search)