Browse Source

added wikihow

master
Angerstoner 6 years ago
parent
commit
eb740b5e1d
  1. 2
      misc/commandlist
  2. 5
      schneiderbot.py
  3. 14
      web_requests.py

2
misc/commandlist

@ -7,6 +7,8 @@ catdog - catdog pic
reddit - [subreddit] random submission from reddit.com/r/[subreddit]
reddit_img - [subreddit] random image submission from reddit.com/r/[subreddit]
codinglove - random gif from the coding love
wikihow - random wikihow article
wiegeht - random wikihow article
manta - boah ey, geile Karre!
magie - Magie ist Physik durch wollen
goodlife - gimme some goodlife

5
schneiderbot.py

@ -7,7 +7,7 @@ import random
from telegram import ParseMode
from telegram.ext import Updater, CommandHandler
from coding_love import send_coding_love_gif
from web_requests import send_coding_love_gif, send_wiki_how_article
from reddit import wrong_dog, hamster, reddit, reddit_img, toggle_four_twenty, four_twenty, cat, dog
from schneiderbot_twitter import toggle_pepito_for_group, check_pepito_and_post_auto, check_pepito_and_post_manually
from db import Db
@ -65,6 +65,7 @@ def help(bot, update):
*Other fun stuff*:
/codinglove - random gif from the coding love (https://thecodinglove.com)
/wikihow - random wikihow article (https://http://de.wikihow.com)
/shrug - prints shrug
/kill - kills you
/revive - revives you
@ -199,6 +200,8 @@ def init_commands(dp):
dp.add_handler(CommandHandler("simon", simon, pass_args=True))
dp.add_handler(CommandHandler("graveyard", graveyard))
dp.add_handler(CommandHandler("codinglove", send_coding_love_gif))
dp.add_handler(CommandHandler("wiegeht", send_wiki_how_article))
dp.add_handler(CommandHandler("wikihow", send_wiki_how_article))
dp.add_handler(CommandHandler("wrongdog", wrong_dog))
dp.add_handler(CommandHandler("hamster", hamster))
dp.add_handler(CommandHandler("reddit", reddit, pass_args=True))

14
coding_love.py → web_requests.py

@ -2,11 +2,14 @@ import requests
import re
import html
url = "https://thecodinglove.com/"
urls = {
"codinglove": "https://thecodinglove.com/",
"wikihow": "https://de.wikihow.com/Spezial:Randomizer"
}
def send_coding_love_gif(bot, update):
random_url = re.search('href="(.*)".*\n.*random\(\)', requests.get(url).text).group(1)
random_url = re.search('href="(.*)".*\n.*random\(\)', requests.get(urls["codinglove"]).text).group(1)
random_page_content = requests.get(random_url)
random_page_content.encoding = 'utf-8'
@ -24,3 +27,10 @@ def send_coding_love_gif(bot, update):
else:
update.message.reply_text("Error fetching image: %s ¯\_(ツ)_/¯" % random_url)
def send_wiki_how_article(bot, update):
random_howto = requests.get(urls["wikihow"])
howto_title = re.search('<title>(.*)</title>', random_howto.text).group(1)
howto_url = re.search('<link rel="canonical" href="(.*)" />', random_howto.text).group(1)
update.message.reply_text(howto_title + "\n" + howto_url)
Loading…
Cancel
Save