From 7fb433845435b58c59dcfd83cf0afcc200e35325 Mon Sep 17 00:00:00 2001 From: Wibol <19147332+Wibol@users.noreply.github.com> Date: Sun, 25 Apr 2021 10:44:29 +0200 Subject: [PATCH 1/6] Removal of unnecessary library. dateutil.parser is not used in this module. --- bot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bot.py b/bot.py index 86956a3..77e199c 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 From 7ee01b69f5f79a903b7c2edaaf51ba943f88c80e Mon Sep 17 00:00:00 2001 From: Wibol <19147332+Wibol@users.noreply.github.com> Date: Sun, 25 Apr 2021 10:53:34 +0200 Subject: [PATCH 2/6] Added argument to "dateutil.parser.parse". In the next version of the "dateutil library" it will be necessary to pass the argument "tzinfos" to "parser.parse". --- feedupdater.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feedupdater.py b/feedupdater.py index 79f32ad..36cf381 100644 --- a/feedupdater.py +++ b/feedupdater.py @@ -55,14 +55,14 @@ def __fetch_feed(self, feed_info, callback, forever): # Try to get the published or updated date. Otherwise set it to 'no date' try: # Get date and parse it - newsdate = dateutil.parser.parse(newsitem.published) + newsdate = dateutil.parser.parse(newsitem.published, tzinfos=TZOFFSETS) # Format date based on 'dateformat' in config.py newsdate = newsdate.strftime(self.__config.dateformat) except Exception as e: try: # Get date and parse it - newsdate = dateutil.parser.parse(newsitem.updated) + newsdate = dateutil.parser.parse(newsitem.updated, tzinfos=TZOFFSETS) # Format date based on 'dateformat' in config.py newsdate = newsdate.strftime(self.__config.dateformat) From 7b27b8e20e430d067149a9fcee574aa20dc771f0 Mon Sep 17 00:00:00 2001 From: Wibol <19147332+Wibol@users.noreply.github.com> Date: Sun, 25 Apr 2021 11:04:00 +0200 Subject: [PATCH 3/6] Fixing a bug in the keyword filter. The filter was activated only with a letter in the title matched those contained in the list. --- config.py.sample | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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. From 148f2d68b5c0a02571bc85f5a2a1175f7469ae5f Mon Sep 17 00:00:00 2001 From: Wibol <19147332+Wibol@users.noreply.github.com> Date: Sun, 25 Apr 2021 11:30:45 +0200 Subject: [PATCH 4/6] Replaced "virtualenv" with the new "venv". Since Python 3.3 the new "venv" tool is available by default, so it is not necessary to install "virtualenv". --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 ``` From 9700a1fcc7c6ca6fa025cef449caaa924b7c5c75 Mon Sep 17 00:00:00 2001 From: Wibol <19147332+Wibol@users.noreply.github.com> Date: Tue, 27 Apr 2021 11:39:32 +0200 Subject: [PATCH 5/6] Update feedupdater.py --- feedupdater.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/feedupdater.py b/feedupdater.py index 36cf381..0075fcf 100644 --- a/feedupdater.py +++ b/feedupdater.py @@ -50,19 +50,18 @@ 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: # Get date and parse it - newsdate = dateutil.parser.parse(newsitem.published, tzinfos=TZOFFSETS) + newsdate = dateutil.parser.parse(newsitem.published) # Format date based on 'dateformat' in config.py newsdate = newsdate.strftime(self.__config.dateformat) except Exception as e: try: # Get date and parse it - newsdate = dateutil.parser.parse(newsitem.updated, tzinfos=TZOFFSETS) + newsdate = dateutil.parser.parse(newsitem.updated) # Format date based on 'dateformat' in config.py newsdate = newsdate.strftime(self.__config.dateformat) From 27b7eb55f9ff7116a08cd90a48529f20c39ec29a Mon Sep 17 00:00:00 2001 From: Wibol <19147332+Wibol@users.noreply.github.com> Date: Sat, 30 Apr 2022 11:09:44 +0200 Subject: [PATCH 6/6] Changed URL shortener Changed URL shortener due to the previous one being out of service for days. --- bot.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 77e199c..5b59f1c 100644 --- a/bot.py +++ b/bot.py @@ -202,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