コード例 #1
0
def gallery(bot, update):
    import db
    galleryItams = db.getGalleryItems()

    for i in galleryItams:
        photo_id = i['id']
        title = i['title']
        url = i['url']
        filename = 'photos/' + i['filename']

        if url is None:
            # If there is no URL, upload the photo
            logging.info('Uploading {}'.format(filename))
            with open(filename, "rb") as file:
                photo = file
        else:
            logging.info('Sending {} from url'.format(filename))
            photo = url

        bot.send_photo(
            chat_id=update.message.chat_id,
            photo=photo,
        )

        keyboard = InlineKeyboardMarkup([[
            (InlineKeyboardButton(text='More...',
                                  callback_data="info_{}".format(photo_id)))
        ]])

        bot.send_message(chat_id=update.message.chat_id,
                         text=title,
                         parse_mode='Markdown',
                         reply_markup=keyboard)
コード例 #2
0
def gallery(bot,update):
    import db
    galleryItams = db.getGalleryItems()
    
    for i in galleryItams:
        photo_id = i['id']
        title = i['title']
        filename = 'photos/'+ i['filename']
        
        command = 'buy: /buy_{}'.format(photo_id)
        
        logging.info('Uploading {}'.format(filename))
        
        with open(filename, "rb") as file:
            bot.send_photo(chat_id=update.message.chat_id, 
                           photo=file,
                           caption=title+' | '+command)
コード例 #3
0
ファイル: bot.py プロジェクト: zdanchuyk/telegramShop
def gallery(bot, update):
    galleryItams = db.getGalleryItems()

    for i in galleryItams:

        bot.send_photo(
            chat_id=update.message.chat_id,
            photo=i['file_id'],
        )

        keyboard = InlineKeyboardMarkup([[
            (InlineKeyboardButton(text='More...',
                                  callback_data="info_{}".format(i['id'])))
        ]])

        bot.send_message(chat_id=update.message.chat_id,
                         text=i['title'],
                         parse_mode='Markdown',
                         reply_markup=keyboard)