cursor.execute("""CREATE TABLE IF NOT EXISTS username_id(
id INTEGER,
file_id INTEGER
)""")
user_id = ["message.chat.id"]
file_id = ["message.photo.file_id"]
cursor.execute("INSERT INTO username_id VALUES(?,?);",user_id, file_id)
photos = []
@bot.message_handler(commands=['start'])
def start(message):
msg = bot.send_message(message.chat.id, 'введите текст')
bot.register_next_step_handler(msg, create_request)
def create_request(message):
bot.send_message(message.chat.id, 'ваш текст опубликован')
bot.send_message(-idgruppy_cyfry, '{0}\n{1}\n{2}\n{3}'.format(message.text, message.from_user.first_name, message.from_user.username, message.chat.id))
for elem in os.listdir('photos'):
with open(elem) as f:
photos.append(InputMediaPhoto(f))
bot.send_media_group(-idgruppy_cyfry, photos)
File "testbot.py", line 19, in create_request
with open('files/1.jpg', 'rb') as f1, open('files/2.jpg', 'rb') as f2:
FileNotFoundError: [Errno 2] No such file or directory: 'files/1.jpg'
def create_request(message):
bot.send_message(message.chat.id, 'ваш текст опубликован')
bot.send_message(-idgruppy_cyfry, '{0}\n{1}\n{2}\n{3}'.format(message.text, message.from_user.first_name, message.from_user.username, message.chat.id))
with open('files/1.jpg', 'rb') as f1, open('files/2.jpg', 'rb') as f2:
bot.send_media_group(chat.id, [InputMediaPhoto(f1),InputMediaPhoto(f2)])
bot.send_photo(-idgruppy_cyfry, message.photo[-1].file_id)
with open('files/1.jpg', 'rb') as f1, open('files/2.jpg', 'rb') as f2:
Вот код,как это будет.