2023-07-16 17:23:10 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2023-11-13 14:45:10 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
FIXME
|
|
|
|
|
|
|
|
1) Check feed duplication on runtime.
|
|
|
|
When feed is valid and is not yet in the database it is
|
|
|
|
posible to send a batch which would result in duplication.
|
|
|
|
Consequently, it might result in database lock error upon
|
|
|
|
feed removal attempt
|
|
|
|
|
|
|
|
TODO
|
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
1) SQL prepared statements;
|
2023-12-04 15:41:02 +01:00
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
2) Machine Learning for scrapping Title, Link, Summary and Timstamp;
|
2023-12-24 19:37:05 +01:00
|
|
|
Scrape element </article> (example: Liferea)
|
|
|
|
http://intertwingly.net/blog/
|
|
|
|
https://www.brandenburg.de/
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
3) Set MUC subject
|
2023-12-04 15:41:02 +01:00
|
|
|
Feeds which entries are to be set as groupchat subject.
|
|
|
|
Perhaps not, as it would require to check every feed for this setting.
|
2023-12-24 19:37:05 +01:00
|
|
|
Maybe a separate bot;
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
4) Support categories;
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
5) XMPP commands;
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
6) Bot as service;
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
7) OMEMO;
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
8) Logging;
|
2023-12-24 19:37:05 +01:00
|
|
|
https://docs.python.org/3/howto/logging.html
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
9) Readability
|
2023-12-24 19:37:05 +01:00
|
|
|
See project /buriy/python-readability
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
10) Download and upload/send article (xHTML, HTMLZ, Markdown, MHTML, TXT).
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
11) Fetch summary from URL, instead of storing summary, or
|
2023-12-04 15:41:02 +01:00
|
|
|
Store 5 upcoming summaries.
|
|
|
|
This would help making the database files smaller.
|
2023-11-15 15:02:39 +01:00
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
12) Support protocol Gopher
|
2023-12-24 19:37:05 +01:00
|
|
|
See project /michael-lazar/pygopherd
|
|
|
|
See project /gopherball/gb
|
2023-11-15 15:02:39 +01:00
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
13) Support ActivityPub @person@domain (see Tip Of The Day).
|
2023-11-22 12:47:34 +01:00
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
14) Tip Of The Day.
|
2023-11-22 12:47:34 +01:00
|
|
|
Did you know that you can follow you favorite Mastodon feeds by just
|
|
|
|
sending the URL address?
|
|
|
|
Supported fediverse websites are:
|
|
|
|
Akkoma, HubZilla, Mastodon, Misskey, Pixelfed, Pleroma, Soapbox.
|
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
15) Brand: News Broker, Newsman, Newsdealer, Laura Harbinger
|
2023-12-18 16:29:32 +01:00
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
16) See project /offpunk/offblocklist.py
|
2023-12-24 19:37:05 +01:00
|
|
|
|
|
|
|
18) Search messages of government regulated publishers, and promote other sources.
|
|
|
|
Dear reader, we couldn't get news from XYZ as they don't provide RSS feeds.
|
|
|
|
However, you might want to get news from (1) (2) and (3) instead!
|
2023-12-11 10:04:45 +01:00
|
|
|
|
2023-11-13 14:45:10 +01:00
|
|
|
"""
|
2023-07-16 17:23:10 +02:00
|
|
|
|
|
|
|
# vars and their meanings:
|
|
|
|
# jid = Jabber ID (XMPP)
|
|
|
|
# res = response (HTTP)
|
|
|
|
|
|
|
|
from argparse import ArgumentParser
|
2023-12-11 10:04:45 +01:00
|
|
|
import configparser
|
2023-12-28 15:50:23 +01:00
|
|
|
# import filehandler
|
|
|
|
# from slixfeed.file import get_default_confdir
|
2023-07-16 17:23:10 +02:00
|
|
|
from getpass import getpass
|
|
|
|
import logging
|
2023-12-11 10:04:45 +01:00
|
|
|
import os
|
2023-07-16 17:23:10 +02:00
|
|
|
|
2023-12-04 15:41:02 +01:00
|
|
|
# from datetime import date
|
|
|
|
# import time
|
2023-07-16 17:23:10 +02:00
|
|
|
|
2023-09-29 13:49:24 +02:00
|
|
|
# from eliot import start_action, to_file
|
|
|
|
# # to_file(open("slixfeed.log", "w"))
|
|
|
|
# # with start_action(action_type="set_date()", jid=jid):
|
|
|
|
# # with start_action(action_type="message()", msg=msg):
|
2023-07-16 17:23:10 +02:00
|
|
|
|
2023-12-04 15:41:02 +01:00
|
|
|
#import slixfeed.irchandler
|
2023-12-28 15:50:23 +01:00
|
|
|
from slixfeed.xmpp.client import Slixfeed
|
2023-12-04 15:41:02 +01:00
|
|
|
#import slixfeed.matrixhandler
|
2023-07-16 17:23:10 +02:00
|
|
|
|
|
|
|
|
2023-12-28 15:50:23 +01:00
|
|
|
class Jabber:
|
|
|
|
|
|
|
|
def __init__(self, jid, password, nick):
|
|
|
|
|
|
|
|
# Setup the Slixfeed and register plugins. Note that while plugins may
|
|
|
|
# have interdependencies, the order in which you register them does
|
|
|
|
# not matter.
|
|
|
|
xmpp = Slixfeed(jid, password, nick)
|
|
|
|
xmpp.register_plugin('xep_0004') # Data Forms
|
|
|
|
xmpp.register_plugin('xep_0030') # Service Discovery
|
|
|
|
xmpp.register_plugin('xep_0045') # Multi-User Chat
|
|
|
|
xmpp.register_plugin('xep_0048') # Bookmarks
|
|
|
|
xmpp.register_plugin('xep_0060') # PubSub
|
|
|
|
xmpp.register_plugin('xep_0199', {'keepalive': True, 'frequency': 15}) # XMPP Ping
|
|
|
|
xmpp.register_plugin('xep_0249') # Multi-User Chat
|
|
|
|
xmpp.register_plugin('xep_0402') # PEP Native Bookmarks
|
|
|
|
|
|
|
|
# Connect to the XMPP server and start processing XMPP stanzas.
|
|
|
|
xmpp.connect()
|
|
|
|
xmpp.process()
|