Skip to content

Commit

Permalink
Merge pull request #43 from fterh/release-v1.0.1
Browse files Browse the repository at this point in the history
Release v1.0.1
  • Loading branch information
fterh authored May 18, 2019
2 parents 52d075e + a6af1fe commit 53ad65d
Show file tree
Hide file tree
Showing 21 changed files with 569 additions and 455 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## Changelog
##v1.0.1
* Fix style issues (in code and Markdown)
* Add Codacy badge
* Warn if `SUBREDDIT` environment variable is not set

## v1.0.0
* Add support for Docker
* Set up continuous deployment (Heroku)
Expand Down Expand Up @@ -30,8 +35,7 @@
* Add Straits Times support

### v0.3.0-beta
* Temporarily remove Straits Times support
(until premium article detection feature)
* Temporarily remove Straits Times support (until premium article detection feature)
* Fix Todayonline article handling
* Fix Ricemedia article handling
* Update AbstractBaseHandler `handle` method definition
Expand All @@ -52,5 +56,4 @@

### v0.1.0-beta
* Minimum viable product
* Supports channelnewsasia.com, mothership.sg, ricemedia.co, straitstimes.com,
todayonline.com, zula.sg
* Supports channelnewsasia.com, mothership.sg, ricemedia.co, straitstimes.com, todayonline.com, zula.sg
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ invoke = "*"
newspaper3k = "*"
schedule = "*"
beautifulsoup4 = "*"
pylint = "*"

[requires]
python_version = "3.7"
298 changes: 189 additions & 109 deletions Pipfile.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# sneakpeek

[![Build Status](https://travis-ci.com/fterh/sneakpeek.svg?branch=master)](https://travis-ci.com/fterh/sneakpeek)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a196dd3251ec4600b126c9a7712ddbf2)](https://app.codacy.com/app/fterh/sneakpeek?utm_source=github.com&utm_medium=referral&utm_content=fterh/sneakpeek&utm_campaign=Badge_Grade_Dashboard)

A Reddit bot that previews hyperlinks and posts their contents as a comment.
It should **never spam or double-post**, and will skip a comment if it is
Expand Down
9 changes: 7 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}

BOT = {
"VERSION": "1.0.0",
"VERSION": "1.0.1",
"REPO_LINK": "https://github.com/fterh/sneakpeek",
"CONTRIBUTE_LINK": "https://github.com/fterh/sneakpeek"
}
Expand All @@ -28,5 +28,10 @@

USER_AGENT = os.getenv("USER_AGENT")

SUBREDDIT = os.getenv("SUBREDDIT", "all") # Set subreddit using environmental variables, default to /r/all
# Read subreddit from environment variable; warn and default to /r/all if not set
SUBREDDIT = os.getenv("SUBREDDIT")
if SUBREDDIT is None:
logging.warning("Environment variable `SUBREDDIT` is not set; defaulting to `all`")
SUBREDDIT = "all"

COMMENT_LENGTH_LIMIT = 9900
24 changes: 13 additions & 11 deletions handler.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import tldextract
"""Manage Handlers and map subdomains and domain names to Handlers."""

from collections import defaultdict
import tldextract

from handlers.ArticleHandler import ArticleHandler
from handlers.BusinesstimesHandler import BusinesstimesHandler
from handlers.CNAlifestyleHandler import CNAlifestyleHandler
from handlers.RicemediaHandler import RicemediaHandler
from handlers.STHandler import STHandler
from handlers.TNPHandler import TNPHandler
from handlers.TodayonlineHandler import TodayonlineHandler
from handlers.YahooHandler import YahooHandler
from handlers.article_handler import ArticleHandler
from handlers.business_times_handler import BusinesstimesHandler
from handlers.cna_lifestyle_handler import CNAlifestyleHandler
from handlers.ricemedia_handler import RicemediaHandler
from handlers.straits_times_handler import STHandler
from handlers.tnp_handler import TNPHandler
from handlers.today_online_handler import TodayonlineHandler
from handlers.yahoo_handler import YahooHandler


class HandlerManager:
Expand All @@ -21,8 +22,9 @@ class HandlerManager:
lambda: BusinesstimesHandler
),
"channelnewsasia.com": defaultdict(
lambda: ArticleHandler, # Default Handler for all subdomains (unless specify) for channelnewsasia.com
cnalifestyle = CNAlifestyleHandler
lambda: ArticleHandler, # Default Handler for all subdomains (unless specify)
# for channelnewsasia.com
cnalifestyle=CNAlifestyleHandler
),
"mothership.sg": defaultdict(
lambda: ArticleHandler
Expand Down
233 changes: 0 additions & 233 deletions handlers/STHandler/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""The abstract base Handler class which all Handlers must subclass."""

from abc import ABC, abstractmethod


Expand All @@ -11,8 +13,7 @@ def handle(cls, url):
All Handlers must override the `handle` method,
which must return a Comment object.
"""
pass


class HandlerError(Exception):
pass
"""An Error exception raised during the operation of a Handler."""
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from newspaper import Article

from comment import Comment
from handlers.AbstractBaseHandler import AbstractBaseHandler, HandlerError
from handlers.abstract_base_handler import AbstractBaseHandler, HandlerError


class ArticleHandler(AbstractBaseHandler):
Expand Down
Loading

0 comments on commit 53ad65d

Please sign in to comment.