Esempio n. 1
0
    def get_action_handler(self, action_type):
        if action_type == create_bill_handler.MODULE_ACTION_TYPE:
            return create_bill_handler.BillCreationHandler()
        if action_type == manage_bill_handler.MODULE_ACTION_TYPE:
            return manage_bill_handler.BillManagementHandler()
        if action_type == share_bill_handler.MODULE_ACTION_TYPE:
            return share_bill_handler.BillShareHandler()

        raise Exception("Action type '{}' unknown".format(action_type))
Esempio n. 2
0
 def set_bill_done(self, bot, update, trans, data):
     bill_id = data.get(const.JSON_BILL_ID)
     cbq = update.callback_query
     trans.set_bill_done(bill_id, cbq.from_user.id)
     manage_bill_handler.BillManagementHandler().execute(
         bot,
         update,
         trans,
         manage_bill_handler.ACTION_GET_MANAGE_BILL,
         data=data)
Esempio n. 3
0
 def start(self, bot, update, args):
     # TODO: make command list screen
     if args is not None and len(args) == 1:
         handler = manage_bill_handler.BillManagementHandler()
         conn = self.db.get_connection()
         data = {const.JSON_BILL_ID: args[0]}
         with Transaction(conn) as trans:
             handler.execute(bot,
                             update,
                             trans,
                             action_id=manage_bill_handler.ACTION_SEND_BILL,
                             data=data)
         return
     bot.sendMessage(chat_id=update.message.chat_id, text="Start screen")
Esempio n. 4
0
 def start(self, bot, update, args):
     # TODO: make command list screen
     if args is not None and len(args) == 1:
         handler = manage_bill_handler.BillManagementHandler()
         conn = self.db.get_connection()
         data = {const.JSON_BILL_ID: args[0]}
         with Transaction(conn) as trans:
             msg = update.message
             trans.reset_session(msg.chat_id, msg.from_user.id)
             handler.execute(bot,
                             update,
                             trans,
                             action_id=manage_bill_handler.ACTION_SEND_BILL,
                             data=data)
         return
     self.send_help_msg(bot, update)