forked from angerstoner/schneiderbot-tg
				
			
				 3 changed files with 34 additions and 10 deletions
			
			
		- 
					22coding_love.py
 - 
					2db.py
 - 
					20schneiderbot.py
 
@ -0,0 +1,22 @@ | 
				
			|||
import requests | 
				
			|||
import re | 
				
			|||
 | 
				
			|||
url = "https://thecodinglove.com/" | 
				
			|||
 | 
				
			|||
 | 
				
			|||
def send_coding_love_gif(bot, update): | 
				
			|||
    random_url = re.search('href="(.*)".*\n.*random\(\)', requests.get(url).text).group(1) | 
				
			|||
 | 
				
			|||
    random_page_content = requests.get(random_url).text | 
				
			|||
    caption = re.search('blog-post-title">(.*)</h1>', random_page_content).group(1) | 
				
			|||
 | 
				
			|||
    gif_match = re.search('data="(.*)" type="image/gif"', random_page_content) | 
				
			|||
    if gif_match is None: | 
				
			|||
        gif_match = re.search('og:image" cont ent="(.*)"', random_page_content) | 
				
			|||
 | 
				
			|||
    if gif_match: | 
				
			|||
        gif_url = gif_match.group(1) | 
				
			|||
        bot.send_animation(chat_id=update.message.chat_id, animation=gif_url, caption=caption) | 
				
			|||
 | 
				
			|||
    else: | 
				
			|||
        update.message.reply_text("Error fetching image: %s  ¯\_(ツ)_/¯" % random_url) | 
				
			|||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue