calculate image hash for images sent in chat
This commit is contained in:
@@ -5,7 +5,9 @@ from tempfile import TemporaryDirectory
|
||||
|
||||
import boto3
|
||||
import filetype
|
||||
import requests
|
||||
import twitter
|
||||
from TikTokApi import TikTokApi
|
||||
from django.db import models
|
||||
# from qrtools import QR
|
||||
from telegram import Update, InlineKeyboardMarkup, InlineKeyboardButton, MessageEntity
|
||||
@@ -83,6 +85,7 @@ class RobotBotModuleConfig(TelegramBotModuleConfig):
|
||||
for link in links:
|
||||
try:
|
||||
twitter_matches = re.match(r'https?://twitter.com/[A-Za-z0-9_]{1,15}/status/(\d+).*', link)
|
||||
tiktok_matches = re.match(r'https?://vm.tiktok.com/.*', link)
|
||||
if link.endswith('.gif'):
|
||||
update.message.reply_document(link)
|
||||
elif twitter_matches:
|
||||
@@ -102,6 +105,10 @@ class RobotBotModuleConfig(TelegramBotModuleConfig):
|
||||
update.message.reply_video(max_bitrate_link)
|
||||
except KeyError:
|
||||
update.message.reply_text('Unable to retrieve video info from tweet')
|
||||
elif tiktok_matches:
|
||||
api = TikTokApi()
|
||||
vid = api.video(link)
|
||||
|
||||
else:
|
||||
update.message.reply_text('Can\'t detect link type')
|
||||
except BadRequest:
|
||||
|
Reference in New Issue
Block a user