diff --git a/README.md b/README.md index fecb6cd..18d6f43 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This is a simple bot which fetches RSS feeds and posts them to an IRC channel. - python3 - pip3 -- virtualenv (`pip3 install virtualenv`) +- venv (`Available by default in Python 3.3+`) # Features @@ -40,7 +40,7 @@ Help: Clone this repository and change into the directory. Create a new virtualenv and activate it: ``` -virtualenv -p python3 venv +python3 -m venv venv source venv/bin/activate ``` diff --git a/bot.py b/bot.py index 86956a3..5b59f1c 100644 --- a/bot.py +++ b/bot.py @@ -8,7 +8,6 @@ import sys import feedparser import datetime -import dateutil.parser import requests from colour import Colours from db import FeedDB @@ -203,10 +202,11 @@ def post_news(self, feed_name, title, url, date): def shorten(self, url): try: # Trying to shorten URL - sresponse = requests.get('https://v.gd/create.php?format=json&url=' + url) - surl = sresponse.json()['shorturl'] + api = 'https://tinyurl.com/api-create.php?url=' + sresponse = requests.get(api + url) + surl = sresponse.text except Exception as err: - print('A shortening error occurred.') + print('A shortening error occurred:', sresponse.status_code) surl = url return surl diff --git a/config.py.sample b/config.py.sample index 4b8cd4f..51b44c9 100644 --- a/config.py.sample +++ b/config.py.sample @@ -1,8 +1,7 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- - class Config(object): lastpubmsg = 0 + + ### SETTINGS ### def __init__(self): self.HOST = 'irc.rizon.net' @@ -32,6 +31,6 @@ class Config(object): self.postdelay = 180 # Post delay during conversation in seconds. 0 for off. self.feedorderdesc = False self.update_before_connecting = True # Update all feeds before connecting to the IRC server - self.filterkeywords = () # Lower-case keywords list to filter in title news. Use - # ('one','two','three') to activate or () for deactivate. + self.filterkeywords = [] # Lower-case keywords list to filter in news title. Use + # ['one','two','three'] to activate or [] for deactivate. diff --git a/feedupdater.py b/feedupdater.py index 79f32ad..0075fcf 100644 --- a/feedupdater.py +++ b/feedupdater.py @@ -50,7 +50,6 @@ def __fetch_feed(self, feed_info, callback, forever): for newsitem in news.entries[::-1]: newstitle = newsitem.title newsurl = newsitem.link -# print datetime.datetime.now(), newsurl # Try to get the published or updated date. Otherwise set it to 'no date' try: