Telegram version of schneiderbot. I'll totally do something w/ this, this is never going to be effectively a mirror.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
773 B

  1. import requests
  2. import re
  3. url = "https://thecodinglove.com/"
  4. def send_coding_love_gif(bot, update):
  5. random_url = re.search('href="(.*)".*\n.*random\(\)', requests.get(url).text).group(1)
  6. random_page_content = requests.get(random_url).text
  7. caption = re.search('blog-post-title">(.*)</h1>', random_page_content).group(1)
  8. gif_match = re.search('data="(.*)" type="image/gif"', random_page_content)
  9. if gif_match is None:
  10. gif_match = re.search('og:image" cont ent="(.*)"', random_page_content)
  11. if gif_match:
  12. gif_url = gif_match.group(1)
  13. bot.send_animation(chat_id=update.message.chat_id, animation=gif_url, caption=caption)
  14. else:
  15. update.message.reply_text("Error fetching image: %s ¯\_(ツ)_/¯" % random_url)