aboutsummaryrefslogtreecommitdiff
path: root/cgi/post.py
diff options
context:
space:
mode:
Diffstat (limited to 'cgi/post.py')
-rw-r--r--cgi/post.py40
1 files changed, 19 insertions, 21 deletions
diff --git a/cgi/post.py b/cgi/post.py
index 6fc4bac..f40537d 100644
--- a/cgi/post.py
+++ b/cgi/post.py
@@ -985,9 +985,9 @@ def cut_home_msg(message, boardlength=0):
short_message = re.compile(r"&(.(?!;))*$", re.DOTALL | re.IGNORECASE).sub("", short_message) # Removes incomplete HTML
return short_message
-def getLastAge(limit):
+def getLastAge(board_type, limit):
threads = []
- sql = "SELECT posts.id, boards.name AS board_fulln, boards.subname AS board_name, board_type, boards.dir, timestamp, bumped, last, length, thumb, CASE WHEN posts.subject = boards.subject THEN posts.message ELSE posts.subject END AS content FROM posts INNER JOIN boards ON boardid = boards.id WHERE parentid = 0 AND IS_DELETED = 0 AND boards.secret = 0 AND posts.locked < 3 ORDER BY bumped DESC LIMIT %d" % limit
+ sql = "SELECT posts.id, boards.name AS board_fulln, boards.subname AS board_name, board_type, boards.dir, timestamp, bumped, last, length, thumb, CASE WHEN posts.subject = boards.subject THEN posts.message ELSE posts.subject END AS content FROM posts INNER JOIN boards ON boardid = boards.id WHERE parentid = 0 AND IS_DELETED = 0 AND boards.secret = 0 AND posts.locked < 3 AND boards.board_type = %d ORDER BY bumped DESC LIMIT %d" % (board_type, limit)
threads = FetchAll(sql)
for post in threads:
@@ -1037,7 +1037,8 @@ def regenerateHome():
'header': Settings.SITE_TITLE,
'slogan': Settings.SITE_SLOGAN,
'latest_news': FetchAll("SELECT `timestamp`, `message`, `timestamp_formatted` FROM `news` WHERE `type` = '2' ORDER BY `timestamp` DESC LIMIT " + str(Settings.HOME_NEWS)),
- 'latest_age': getLastAge(limit),
+ 'latest_age_ib': getLastAge(0, limit),
+ 'latest_age_bbs': getLastAge(1, limit),
'latest_age_num': limit,
'new_threads': getNewThreads(Settings.HOME_NEWTHREADS),
}
@@ -1259,26 +1260,23 @@ def discord_hook(post, url):
board = Settings._.BOARD
- WEBHOOK_URL = "https://discordapp.com/api/webhooks/428025764974166018/msYu1-R3JRnG-cxrhAu3J7LbIPvzpBlJwbW5PFe5VEQaxVzjros9CXOpjZDahUE42Jgn"
-
- data = {"content": "",
- "ts": post['timestamp'],
- "embeds": [{
- "title": post['subject'],
- "description": cut_home_msg(post['message'], 30),
- "url": "https://bienvenidoainternet.org" + url, # TODO: Parametrizar.
- "color": 11910504,
- "timestamp": datetime.datetime.utcfromtimestamp(post['timestamp']).isoformat(),
- "footer": { "text": board['name'] },
- "thumbnail": { "url": "%s%s/thumb/%s" % (Settings.HOME_URL, board['dir'], post['thumb']) },
- "author": {
- "name": "Nuevo hilo",
- "icon_url": "%s0/junk/w/shobon.gif" % Settings.HOME_URL
- }}]
- }
+ #data = {"embeds": [{
+ # "title": post['subject'],
+ # "description": cut_home_msg(post['message'], 30),
+ # "url": "https://bienvenidoainternet.org" + url, # TODO: Parametrizar.
+ # "color": 11910504,
+ # "timestamp": datetime.datetime.utcfromtimestamp(post['timestamp']).isoformat(),
+ # "footer": { "text": board['name'] },
+ # "thumbnail": { "url": "%s%s/thumb/%s" % (Settings.HOME_URL, board['dir'], post['thumb']) },
+ # "author": {
+ # "name": "Nuevo hilo",
+ # "icon_url": "%s0/junk/w/shobon.gif" % Settings.HOME_URL
+ # }}]
+ #}
+ data = {"content": "test"}
jsondata = json.dumps(data, separators=(',',':'))
opener = urllib2.build_opener()
- opener.addheaders = [('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0')]
+ #opener.addheaders = [('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0')]
response = opener.open(Settings.DISCORD_HOOK_URL, jsondata, 6)
the_page = response.read()