Commit b40fcf42 authored by Mindiell's avatar Mindiell

Now, Wantzel is able to push articles on new RP

parent c5b6ca9e
......@@ -18,6 +18,10 @@ dbpassword = ""
dbserver = "localhost"
dbname = "db"
# External API for rp
api = "The URL API"
token = "Token get_a_token"
# Internal db, sqlite is sufficient
sqlite_db = "db.sqlite3"
......@@ -30,3 +34,30 @@ TOKENSEC = ""
CONSKEY = ""
CONSSEC = ""
# Logfile
LOG_FILE = "wantzel.log"
DEBUG = 3
WARNING = 2
INFO = 1
ERROR = 0
LOG_LEVEL = DEBUG
# Press Review
MASTER_SCORE = 5
MASTER_CLEANING = 7 # in days
RP_CHANNEL = "#choose_a_channel"
# Feeds channels for tweeting
feeds = (
"feed_1",
"feed_2",
)
# Monitoring
MONITOR_CHANNEL = "#choose_a_channel"
monitors = [
{
"name": "A fantastic name",
"type": "a type",
"url" : "an URL",
},
]
......@@ -5,6 +5,7 @@ Press review methods.
import feedparser
import MySQLdb
import requests
import sqlite3
import time
from twitter import Twitter, OAuth
......@@ -138,6 +139,7 @@ class Rp():
if necessary.
"""
Log.debug("count_articles method")
# TODO: Adapt this to new RP
cursor = get_cursor()
cursor.execute("""SELECT COUNT(*) FROM presse
WHERE DATE_SUB(NOW(), INTERVAL 2 MONTH)<datec
......@@ -177,6 +179,7 @@ class Rp():
return ""
# Looking for such an article in database
# TODO: Is this possible with new RP ?
cursor = get_cursor()
# We need to be able to retrieve an url with "http" or "https"
if url.startswith("https"):
......@@ -332,6 +335,23 @@ class Rp():
if note>=3:
# Update number of articles to do
self.count_articles()
# Do the same for new RP
headers = {"Authorization": config.token}
data = {
"url": url,
"speak": True if "c" in command else False,
"archive": True if "a" in command else False,
"quote": True if command.count("p") > 1 else False,
}
result = requests.post(
"%s/articles/" % config.api,
data=data,
headers=headers
)
if result.code==200:
article = json.loads(result.text)
note = article["score"]
if answer:
# Answer is now based on where, who, note, and a little magic
return self.did_rp(channel, user, note)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment