add image url handling
This commit is contained in:
parent
da66cbac82
commit
8edcefb7ae
1 changed files with 6 additions and 1 deletions
|
@ -175,9 +175,14 @@ class DelojzaBot:
|
||||||
def handle_url(self, _, update):
|
def handle_url(self, _, update):
|
||||||
urls = map(lambda e: update.message.parse_entity(e),
|
urls = map(lambda e: update.message.parse_entity(e),
|
||||||
filter(lambda e: e.type == 'url', update.message.entities))
|
filter(lambda e: e.type == 'url', update.message.entities))
|
||||||
ytdl_urls = list(filter(self.ytdl_can, urls))
|
ytdl_urls = [url for url in urls if self.ytdl_can(url)]
|
||||||
|
normal_urls = [url for url in urls if not self.ytdl_can(url)]
|
||||||
if len(ytdl_urls) > 0:
|
if len(ytdl_urls) > 0:
|
||||||
self.handle(ytdl_urls, update.message, self.download_ytdl)
|
self.handle(ytdl_urls, update.message, self.download_ytdl)
|
||||||
|
if len(normal_urls) > 0:
|
||||||
|
image_urls = [url for url in normal_urls if "image" in requests.head(url).headers.get("Content-Type", "")]
|
||||||
|
if len(image_urls) > 0:
|
||||||
|
self.handle(image_urls, update.message, self.download_raw)
|
||||||
|
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
def handle_rest(self, bot, update):
|
def handle_rest(self, bot, update):
|
||||||
|
|
Loading…
Reference in a new issue