Esempio n. 1
0
 def send_manage_bill(self, bot, bill_id, chat_id, user_id, trans):
     text, pm = utils.get_complete_bill_text(bill_id, trans)
     keyboard = DisplayManageBillKB.get_manage_bill_keyboard(bill_id, trans)
     trans.reset_session(chat_id, user_id)
     bot.sendMessage(chat_id=chat_id,
                     text=text,
                     parse_mode=pm,
                     reply_markup=keyboard)
Esempio n. 2
0
 def share_all_items(self, bot, cbq, bill_id, user_id, trans):
     print("4. Toggle share: " + str(datetime.datetime.now().time()))
     trans.toggle_all_bill_shares(bill_id, user_id)
     print("5. Toggled: " + str(datetime.datetime.now().time()))
     text, pm = utils.get_complete_bill_text(bill_id, trans)
     kb = DisplayShareItemsKB.get_appropriate_keyboard(
         bill_id, user_id, trans, proxy_uid=cbq.from_user.id)
     print("6. Prepared: " + str(datetime.datetime.now().time()))
     cbq.edit_message_text(text=text, parse_mode=pm, reply_markup=kb)
 def get_appropriate_response(bill_id, user_id, trans):
     text, pm = utils.get_complete_bill_text(bill_id, trans)
     kb = None
     __, owner_id, __, is_closed = trans.get_bill_gen_info(bill_id)
     if user_id == owner_id:
         kb = DisplayManageBillKB.get_manage_bill_keyboard(bill_id, trans)
     else:
         kb = DisplayShareItemsKB.get_share_items_keyboard(bill_id, trans)
     return text, pm, kb
Esempio n. 4
0
    def send_items_list(self, bot, msg, bill_id, trans):
        try:
            is_valid = False
            user_id = 0
            fname = None
            lname = None
            if Filters.contact.filter(msg):
                is_valid = True
                contact = msg.contact
                if contact is None:
                    raise Exception(ERROR_INVALID_CONTACT)
                user_id = contact.user_id
                fname = contact.first_name
                lname = contact.last_name

            if Filters.text.filter(msg):
                is_valid = True
                text = msg.text
                if (text is None or len(text) < 1 or len(text) > 250):
                    Exception(ERROR_INVALID_CONTACT)
                fname = text

            if not is_valid:
                raise Exception(ERROR_INVALID_CONTACT)

            user_id = trans.add_user(user_id,
                                     fname,
                                     lname,
                                     None,
                                     is_ignore_id=(user_id == 0))

            text, pm = utils.get_complete_bill_text(bill_id, trans)
            kb = DisplayShareItemsKB.get_appropriate_keyboard(
                bill_id, user_id, trans, proxy_uid=msg.from_user.id)
            bot.sendMessage(chat_id=msg.chat_id,
                            text=text,
                            parse_mode=pm,
                            reply_markup=kb)
            trans.reset_session(msg.chat_id, msg.from_user.id)
        except Exception as e:
            return bot.sendMessage(chat_id=msg.chat_id, text=str(e))