import random
media_ids = {
'photos': [],
'videos': []
}
@bot.message_handler(content_types=['photo', 'video'])
def save_media(message):
group_id_1 = 'MYGROUP_ID'
if message.chat.id == int(group_id_1):
if message.content_type == 'photo':
file_id = message.photo[-1].file_id
media_ids['photos'].append(file_id)
elif message.content_type == 'video':
file_id = message.video.file_id
media_ids['videos'].append(file_id)
@bot.message_handler(content_types=['text'])
def media_frwrd(message):
if message.chat.type == 'private':
if message.text == 'Фото':
if media_ids['photos']:
random_photo_id = random.choice(media_ids['photos'])
bot.send_photo(message.chat.id, random_photo_id)
else:
bot.send_message(message.chat.id, "Нет доступных фото.")
elif message.text == 'Видео':
if media_ids['videos']:
random_video_id = random.choice(media_ids['videos'])
bot.send_video(message.chat.id, random_video_id)
else:
bot.send_message(message.chat.id, "Нет доступных видео.")
text buttons are unallowed in the inline keyboard
callback_data
или url
допустим.>>> l = ['abc', 'apple', 'pen', 'abc', 'pen', 'pc']
>>> index_els = {v: k for k, v in reversed(tuple(enumerate(l)))}
>>> result = [index_els[k] for k in l]
>>> result
[0, 1, 2, 0, 2, 5]
lt= ['abc', 'apple', 'pen', 'abc', 'pen', 'pc']
lt_num=[sorted(list(set(lt))).index(x) for x in lt]
[0, 1, 3, 0, 3, 2]
cd ~
dd if=/windows.iso of=/dev/sdX
sudo dd if=/windows.iso of=/dev/sdX