Browse Source

fix wikihow, add missing requirements (fix #15)

master
Angerstoner 5 years ago
parent
commit
9a78778731
  1. 3
      misc/requirements.txt
  2. 2
      schneiderbot_twitter.py
  3. 4
      web_requests.py

3
misc/requirements.txt

@ -1,4 +1,5 @@
python-telegram-bot python-telegram-bot
telegram telegram
requests requests
praw
praw
python-twitter

2
schneiderbot_twitter.py

@ -34,7 +34,7 @@ def check_pepito_and_post_auto(bot, update):
api = get_twitter_instance() api = get_twitter_instance()
current_status = api.GetUserTimeline(pepito_id)[0] current_status = api.GetUserTimeline(pepito_id)[0]
global last_status global last_status
if last_status == None or last_status.AsDict()['id'] != current_status.AsDict()['id']:
if last_status is None or last_status.AsDict()['id'] != current_status.AsDict()['id']:
for group_id in pepito_groups: for group_id in pepito_groups:
bot.send_message(chat_id=group_id, text=current_status.AsDict()['text']) bot.send_message(chat_id=group_id, text=current_status.AsDict()['text'])
last_status = current_status last_status = current_status

4
web_requests.py

@ -26,11 +26,11 @@ def send_coding_love_gif(bot, update):
bot.send_animation(chat_id=update.message.chat_id, animation=gif_url, caption=caption) bot.send_animation(chat_id=update.message.chat_id, animation=gif_url, caption=caption)
else: else:
update.message.reply_text("Error fetching image: %s ¯\_(ツ)_/¯" % random_url)
update.message.reply_text("Error fetching image: {} ¯\_(ツ)_/¯".format(random_url))
def send_wiki_how_article(bot, update): def send_wiki_how_article(bot, update):
random_howto = requests.get(urls["wikihow"]) random_howto = requests.get(urls["wikihow"])
howto_title = re.search('<title>(.*)</title>', random_howto.text).group(1) howto_title = re.search('<title>(.*)</title>', random_howto.text).group(1)
howto_url = re.search('<link rel="canonical" href="(.*)" />', 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) update.message.reply_text(howto_title + "\n" + howto_url)
Loading…
Cancel
Save