def done(update, context):
    broadcast_channel = '@otaniemirecycles'
    sent_message = ""
    picture_message = ""
    picture_message_ids = ""
    update.message.reply_text("Thank you for your item, it will now be posted to the broadcasting channel! Once someone claims the item, I will notify you with a message!")
    if len(i.myphotos) == 0:
        sent_message = context.bot.send_message(chat_id = broadcast_channel, text = str(i), reply_markup = dibsKeyboard)
    elif len(i.myphotos) == 1:
        picture_message = context.bot.send_photo(chat_id = broadcast_channel, photo = i.myphotos[0][0], caption = i.myphotos[0][1])
        picture_message_ids = picture_message['message_id']
        sent_message = context.bot.send_message(chat_id = broadcast_channel, text= "The items related can be seen in the picture above.\n\n" + str(i), reply_markup = dibsKeyboard)
    else:
        mediagroup = []
        for j in  range(len(i.myphotos)):
            mediagroup.append(InputMediaPhoto(i.myphotos[j][0],i.myphotos[j][1]))
        picture_message = context.bot.send_media_group(chat_id = broadcast_channel, media = mediagroup)
        picture_message_ids = ",".join(map(lambda x: str(x['message_id']),picture_message))
        sent_message = context.bot.send_message(chat_id = broadcast_channel, text= "The items related can be seen in the album above.\n\n" + str(i), reply_markup = dibsKeyboard)
    print(picture_message_ids)
    item = (update.message.from_user.id, #seller_id
            "done",
            sent_message['message_id'],#channel_message_id
            datetime.date(datetime.now()),#posted_date
            i.myname,#name
            i.mydesc,#description
            i.myprice,#price
            picture_message_ids) #picture_message_id
    print(item)
    try: 
        dbMan = dbManager(db_file_path)
        dbMan.create_item_for_sale(item)
    except Error as e:
        print(e)

    for pic in i.myphotos:
        picture = ("","","")
        pass
        #The loop needs to create a db input for each picture and it's caption. The id for the specific item needs to be fetched first though
        #i.myphotos)#photos

    
    i.clear()
    return ConversationHandler.END
Exemple #2
0
def main():
    # create a database connection
    dbMan = dbManager(db_file_path)
    dbMan.initiate_tables()

    updater = Updater(token=APItoken, use_context=True)
    dp = updater.dispatcher

    conv_handler = ConversationHandler(
        entry_points=[CommandHandler('newitem', newitem)],
        states={
            NAME:
            [MessageHandler(Filters.text & (~Filters.regex('^Quit$')), name)],
            DESC: [
                MessageHandler(Filters.text & (~Filters.regex('^Quit$')),
                               description)
            ],
            PRICE:
            [MessageHandler(Filters.text & (~Filters.regex('^Quit$')), price)],
            PICTURE: [
                MessageHandler(Filters.photo, photo),
                CommandHandler('next', done),
                MessageHandler(
                    Filters.text & (~Filters.regex('^Next$')) &
                    (~Filters.regex('^Quit$')), need_pic)
            ]
        },
        fallbacks=[MessageHandler(Filters.regex('^Quit$'), quit)])

    dp.add_handler(conv_handler)
    dp.add_handler(CallbackQueryHandler(dibs, pattern='^dibs$'))
    dp.add_handler(CallbackQueryHandler(dibs, pattern='^queue$'))

    dp.add_handler(CommandHandler('test', test))
    dp.add_handler(CommandHandler('start', start))
    dp.add_handler(MessageHandler(Filters.command, unknown))

    updater.start_polling()
    updater.idle()
Exemple #3
0
from db_manager import dbManager
from models import *
from sqlalchemy import func

DBM = dbManager()
  ci = 26409963
  debt = '434a29ac-e361-4cc3-b2c4-43f6ba741e3c'
  purchase = 'ebfa672f-4c5a-4996-bb95-155cebda6ac7'
  query = DBM.session.query(Purchase)
"""for ci in DBM.getClientsCI():
    query = DBM.existAutoIncrease(ci, 'Lipton')
    if query is not None:
        for increase in query:
            if increase.pay_date == None:
                print(increase)
                #DBM.payIncrease(increase.increase_id)
                #print(DBM.refreshClientDebt(ci))"""
Exemple #4
0
    def __init__(self, server, parent=None):
        #--------------------------------------------------------------------------------------------------------------
        # INICIAR Y CONFIGURAR LA INSTANCIA
        #--------------------------------------------------------------------------------------------------------------

        super(sessionManager,
              self).__init__(parent)  # Construcción de la instancia
        self.setupUi(self)  # Configuración de la plantilla

        #--------------------------------------------------------------------------------------------------------------
        # INICIAR LOS MANEJADORES PARA LA BASE DE DATOS Y EL CORREO ELECTRÓNICO
        #--------------------------------------------------------------------------------------------------------------

        self.db = dbManager(
            parent=self)  # Iniciar el manejador de la base de datos
        self.mail = emailManager(
        )  # Iniciar el manejador del correo electrónico

        #--------------------------------------------------------------------------------------------------------------
        # CREAR Y DESPLEGAR LA IMAGEN SPLASH
        #--------------------------------------------------------------------------------------------------------------

        self.splash_img = QPixmap(join(
            splashPath, splashName))  # Cargar imagen para la pantalla Splash
        self.splash = QSplashScreen(
            self.splash_img,
            Qt.WindowStaysOnTopHint)  # Crear la pantalla Splash

        #--------------------------------------------------------------------------------------------------------------
        # CONECTAR E INICIAR EL ICONO DE LA BARRA DE NOTIFICACIONES
        #--------------------------------------------------------------------------------------------------------------

        self.trayIcon = trayIcon(
            server, QIcon(join(iconTrayPath, iconTrayName)),
            self)  # Crear el icono de la barra de notificaciones
        self.trayIcon.show()  # Mostrar el icono de la barra de notificaciones

        #--------------------------------------------------------------------------------------------------------------
        # VARIABLES PARA FACILITAR EL USO DE VARIOS MÉTODOS DE LA CLASE
        #--------------------------------------------------------------------------------------------------------------

        self.clicked = False  # Variable de control para los QPushButton
        self.userDef = False  # Variable para saber si ya se definio un usuario para iniciar sesión
        self.passDef = False  # Variable para saber si ya se definio una contraseña para iniciar sesión
        self.guiExist = False  # Variable para saber si ya se creó la ventana principal previamente
        self.isOpenSession = False  # Variable para determinar si existe una sesión abierta

        #--------------------------------------------------------------------------------------------------------------
        # PREFERENCIAS DE USUARIO
        #--------------------------------------------------------------------------------------------------------------

        self.theme = "blue.qss"

        #--------------------------------------------------------------------------------------------------------------
        # LISTAS DE PROPOSITO GENERAL
        #--------------------------------------------------------------------------------------------------------------

        # Campos del formulario de login:
        self.loginLEs = [self.lineEd0, self.lineEd1]

        # Campos del formulario de registro:
        self.registerLEs = [
            self.lineEd2, self.lineEd3, self.lineEd4, self.lineEd5,
            self.lineEd6, self.lineEd7
        ]

        # Campos del formulario de recuperación de contraseña:
        self.recoveryLEs = [self.lineEd8]

        #--------------------------------------------------------------------------------------------------------------
        # CARGAR CONFIGURACIONES INICIALES
        #--------------------------------------------------------------------------------------------------------------

        QMetaObject.connectSlotsByName(
            self
        )  # Se conectan los botones entre otras cosas con algunos de los métodos definidos a continuación
        self.generalSetup()  # Aplicar configuraciones generales de la interfaz
Exemple #5
0
import sys
sys.path.insert(0, '../dbutils/')
sys.path.insert(0, '../models/')

from db_manager import dbManager
from models import *

dbm = dbManager()

# # p = ProductModel()
# # p.setSku('1234')
# # p.setName('asdad')
# # p.setPrice(99.0)
# # p.setParent('asdasd')
# # dbm.create_product(p)
# #dbm.delete_product('1234')
# ps = dbm.search_products(parent='asdasd')

# print(ps[0].__dict__)


invoN = '1235'
p = PurchaseModel()
p.invoice_number = invoN
p.document = '9999'
p.total = 123.33
p.branch = 'abasto'

i = PurchaseItemModel()
i.invoice_number = invoN
i.sku = '123444'