Skip to content

Instantly share code, notes, and snippets.

@pravsripad
Created July 24, 2017 11:32
Show Gist options
  • Save pravsripad/65273e59e2a94b3168d0ebe808d89eaf to your computer and use it in GitHub Desktop.
Save pravsripad/65273e59e2a94b3168d0ebe808d89eaf to your computer and use it in GitHub Desktop.
News feed
# -*- coding: utf-8 -*-
#!/usr/bin/env python
import telepot
import yaml
from rss_gumpu import parse_prep_feed
with open('/home/user/.my_config.yaml', 'r') as myfile:
uconfig = yaml.load(myfile)
TOKEN = uconfig['tg']['TOKEN']
chat_id = uconfig['chat_id']
# Deutsche Welle top stories (rss url)
feed_name = uconfig['news']['deutsche_welle']
if __name__ == "__main__":
# initialize the bot
bot = telepot.Bot(TOKEN)
headlines, err_msg = parse_prep_feed(feed_name)
if headlines:
# inform that the headlines are coming up
bot.sendMessage(chat_id, 'Here are also todays headlines.')
# finally send the news
bot.sendMessage(chat_id, headlines, parse_mode='Markdown', disable_web_page_preview=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment