Force web page previews
This commit is contained in:
parent
125baec439
commit
606eeebe85
@ -33,13 +33,13 @@ def handle_messages(m, vk_user, bot, chat_id, mainmessage=None):
|
|||||||
user = vk.API(vk_user.session).users.get(user_ids=m["uid"], fields=[])[0]
|
user = vk.API(vk_user.session).users.get(user_ids=m["uid"], fields=[])[0]
|
||||||
if 'body' in m and not 'attachment' in m and not 'geo' in m and not 'fwd_messages' in m:
|
if 'body' in m and not 'attachment' in m and not 'geo' in m and not 'fwd_messages' in m:
|
||||||
data = add_reply_info(m, user["first_name"], user["last_name"])
|
data = add_reply_info(m, user["first_name"], user["last_name"])
|
||||||
bot.send_message(chat_id, data, parse_mode='HTML',
|
bot.send_message(chat_id, data, parse_mode='HTML', disable_web_page_preview=False,
|
||||||
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
||||||
if 'attachment' in m:
|
if 'attachment' in m:
|
||||||
attachment_handler(m, user, bot, chat_id, mainmessage)
|
attachment_handler(m, user, bot, chat_id, mainmessage)
|
||||||
if 'geo' in m:
|
if 'geo' in m:
|
||||||
data = add_reply_info(m, user["first_name"], user["last_name"])
|
data = add_reply_info(m, user["first_name"], user["last_name"])
|
||||||
geo = bot.send_message(chat_id, data, parse_mode='HTML',
|
geo = bot.send_message(chat_id, data, parse_mode='HTML', disable_web_page_preview=False,
|
||||||
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
||||||
bot.send_venue(chat_id, m['geo']['coordinates'].split(' ')[0], m['geo']['coordinates'].split(' ')[1],
|
bot.send_venue(chat_id, m['geo']['coordinates'].split(' ')[0], m['geo']['coordinates'].split(' ')[1],
|
||||||
m['geo']['place']['title'], m['geo']['place']['city'],
|
m['geo']['place']['title'], m['geo']['place']['city'],
|
||||||
@ -47,7 +47,7 @@ def handle_messages(m, vk_user, bot, chat_id, mainmessage=None):
|
|||||||
reply_to_message_id=geo.message_id).wait()
|
reply_to_message_id=geo.message_id).wait()
|
||||||
if 'fwd_messages' in m:
|
if 'fwd_messages' in m:
|
||||||
data = add_reply_info(m, user["first_name"], user["last_name"]) + '<i>Пересланные сообщения</i>'
|
data = add_reply_info(m, user["first_name"], user["last_name"]) + '<i>Пересланные сообщения</i>'
|
||||||
reply = bot.send_message(chat_id, data, parse_mode='HTML',
|
reply = bot.send_message(chat_id, data, parse_mode='HTML', disable_web_page_preview=False,
|
||||||
disable_notification=check_notification(m),
|
disable_notification=check_notification(m),
|
||||||
reply_to_message_id=mainmessage).wait().message_id
|
reply_to_message_id=mainmessage).wait().message_id
|
||||||
for forwared in m['fwd_messages']:
|
for forwared in m['fwd_messages']:
|
||||||
@ -65,21 +65,21 @@ def attachment_handler(m, user, bot, chat_id, mainmessage=None):
|
|||||||
for photo in m['attachments']:
|
for photo in m['attachments']:
|
||||||
data = add_reply_info(m, user['first_name'], user['last_name']) + '<a href="{}">Фото</a>'.format(
|
data = add_reply_info(m, user['first_name'], user['last_name']) + '<a href="{}">Фото</a>'.format(
|
||||||
get_max_src(photo['photo']))
|
get_max_src(photo['photo']))
|
||||||
bot.send_message(chat_id, data, parse_mode='HTML',
|
bot.send_message(chat_id, data, parse_mode='HTML', disable_web_page_preview=False,
|
||||||
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
||||||
if m['attachment']['type'] == 'video':
|
if m['attachment']['type'] == 'video':
|
||||||
for vid in m['attachments']:
|
for vid in m['attachments']:
|
||||||
link = 'https://vk.com/video{}_{}'.format(vid['video']['owner_id'],
|
link = 'https://vk.com/video{}_{}'.format(vid['video']['owner_id'],
|
||||||
vid['video']['vid'])
|
vid['video']['vid'])
|
||||||
data = add_reply_info(m, user['first_name'], user['last_name']) + '<a href="{}">Видео</a>'.format(link)
|
data = add_reply_info(m, user['first_name'], user['last_name']) + '<a href="{}">Видео</a>'.format(link)
|
||||||
bot.send_message(chat_id, data, parse_mode='HTML',
|
bot.send_message(chat_id, data, parse_mode='HTML', disable_web_page_preview=False,
|
||||||
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
||||||
if m['attachment']['type'] == 'audio':
|
if m['attachment']['type'] == 'audio':
|
||||||
for audio in m['attachments']:
|
for audio in m['attachments']:
|
||||||
data = add_reply_info(m, user['first_name'], user['last_name']) + '🎵 <code>{} - {}</code>'.format(
|
data = add_reply_info(m, user['first_name'], user['last_name']) + '🎵 <code>{} - {}</code>'.format(
|
||||||
audio['audio']['artist'],
|
audio['audio']['artist'],
|
||||||
audio['audio']['title'])
|
audio['audio']['title'])
|
||||||
bot.send_message(chat_id, data, parse_mode='HTML',
|
bot.send_message(chat_id, data, parse_mode='HTML', disable_web_page_preview=False,
|
||||||
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
||||||
if m['attachment']['type'] == 'doc':
|
if m['attachment']['type'] == 'doc':
|
||||||
for doc in m['attachments']:
|
for doc in m['attachments']:
|
||||||
@ -88,7 +88,7 @@ def attachment_handler(m, user, bot, chat_id, mainmessage=None):
|
|||||||
link = doc['doc']['url']
|
link = doc['doc']['url']
|
||||||
data = add_reply_info(m, user["first_name"], user["last_name"]) + '<a href="{}">GIF</a>'.format(
|
data = add_reply_info(m, user["first_name"], user["last_name"]) + '<a href="{}">GIF</a>'.format(
|
||||||
link)
|
link)
|
||||||
bot.send_message(chat_id, data, parse_mode='HTML',
|
bot.send_message(chat_id, data, parse_mode='HTML', disable_web_page_preview=False,
|
||||||
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
||||||
except:
|
except:
|
||||||
send_doc_link(doc, m, user, bot, chat_id, mainmessage)
|
send_doc_link(doc, m, user, bot, chat_id, mainmessage)
|
||||||
@ -99,7 +99,7 @@ def attachment_handler(m, user, bot, chat_id, mainmessage=None):
|
|||||||
data = add_reply_info(m, user["first_name"],
|
data = add_reply_info(m, user["first_name"],
|
||||||
user["last_name"], ) + '<a href="{}">Документ</a>'.format(
|
user["last_name"], ) + '<a href="{}">Документ</a>'.format(
|
||||||
link)
|
link)
|
||||||
bot.send_message(chat_id, data, parse_mode='HTML',
|
bot.send_message(chat_id, data, parse_mode='HTML', disable_web_page_preview=False,
|
||||||
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
||||||
except:
|
except:
|
||||||
send_doc_link(doc, m, user, bot, chat_id, mainmessage)
|
send_doc_link(doc, m, user, bot, chat_id, mainmessage)
|
||||||
@ -123,7 +123,7 @@ def attachment_handler(m, user, bot, chat_id, mainmessage=None):
|
|||||||
link = doc['doc']['url']
|
link = doc['doc']['url']
|
||||||
data = add_reply_info(m, user["first_name"], user["last_name"], ) + \
|
data = add_reply_info(m, user["first_name"], user["last_name"], ) + \
|
||||||
'<a href="{}">Аудио</a>'.format(link)
|
'<a href="{}">Аудио</a>'.format(link)
|
||||||
bot.send_message(chat_id, data, parse_mode='HTML',
|
bot.send_message(chat_id, data, parse_mode='HTML', disable_web_page_preview=False,
|
||||||
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
||||||
except:
|
except:
|
||||||
send_doc_link(doc, m, user, bot, chat_id, mainmessage)
|
send_doc_link(doc, m, user, bot, chat_id, mainmessage)
|
||||||
@ -151,7 +151,7 @@ def attachment_handler(m, user, bot, chat_id, mainmessage=None):
|
|||||||
if m['attachment']['type'] == 'sticker':
|
if m['attachment']['type'] == 'sticker':
|
||||||
link = m['attachment']['sticker']['photo_512']
|
link = m['attachment']['sticker']['photo_512']
|
||||||
data = add_reply_info(m, user["first_name"], user["last_name"], ) + '<a href="{}">Стикер</a>'.format(link)
|
data = add_reply_info(m, user["first_name"], user["last_name"], ) + '<a href="{}">Стикер</a>'.format(link)
|
||||||
bot.send_message(chat_id, data, parse_mode='HTML',
|
bot.send_message(chat_id, data, parse_mode='HTML', disable_web_page_preview=False,
|
||||||
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
||||||
# TODO: Wall Posts and comments
|
# TODO: Wall Posts and comments
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ def send_doc_link(doc, m, user, bot, chat_id, mainmessage=None):
|
|||||||
data = add_reply_info(m, user["first_name"], user["last_name"]) + \
|
data = add_reply_info(m, user["first_name"], user["last_name"]) + \
|
||||||
'<i>Документ</i>\n<a href="{}">{}</a>'.format(link,
|
'<i>Документ</i>\n<a href="{}">{}</a>'.format(link,
|
||||||
doc['doc']['title'] + '.' + doc['doc']['ext'])
|
doc['doc']['title'] + '.' + doc['doc']['ext'])
|
||||||
bot.send_message(chat_id, data, parse_mode='HTML',
|
bot.send_message(chat_id, data, parse_mode='HTML', disable_web_page_preview=False,
|
||||||
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
disable_notification=check_notification(m), reply_to_message_id=mainmessage).wait()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user