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-11-22 12:47:34 +01:00
|
|
|
1) SQL prepared statements.
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-11-22 12:47:34 +01:00
|
|
|
2) Machine Learning for scrapping Title, Link, Summary and Timstamp.
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-11-22 12:47:34 +01:00
|
|
|
3) Support MUC.
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-11-22 12:47:34 +01:00
|
|
|
4) Support categories.
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-11-22 12:47:34 +01:00
|
|
|
5) Default prepackaged list of feeds.
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-11-22 12:47:34 +01:00
|
|
|
6) XMPP commands.
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-11-22 12:47:34 +01:00
|
|
|
7) Bot as transport.
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-11-22 12:47:34 +01:00
|
|
|
8) OMEMO.
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-11-22 12:47:34 +01:00
|
|
|
9) Logging.
|
2023-11-13 14:45:10 +01:00
|
|
|
|
|
|
|
10) Default feeds (e.g. Blacklisted News, TBOT etc.)
|
|
|
|
|
2023-11-22 12:47:34 +01:00
|
|
|
11) Download and upload/send article (xHTML, xHTMLZ, Markdown, MHTML, TXT).
|
|
|
|
Use Readability.
|
2023-11-13 14:45:10 +01:00
|
|
|
|
2023-11-15 15:02:39 +01:00
|
|
|
12) Fetch summary from URL, instead of storing summary.
|
|
|
|
|
|
|
|
13) Support protocol Gopher
|
|
|
|
https://github.com/michael-lazar/pygopherd
|
|
|
|
https://github.com/gopherball/gb
|
|
|
|
|
2023-11-22 12:47:34 +01:00
|
|
|
13) Support ActivityPub @person@domain (see Tip Of The Day).
|
|
|
|
|
|
|
|
12) Tip Of The Day.
|
|
|
|
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-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
|
|
|
|
from getpass import getpass
|
|
|
|
import logging
|
|
|
|
|
2023-11-02 06:14:01 +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-11-02 06:14:01 +01:00
|
|
|
#import irchandler
|
|
|
|
import xmpphandler
|
|
|
|
#import matrixhandler
|
2023-07-16 17:23:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
# Setup the command line arguments.
|
2023-11-02 06:14:01 +01:00
|
|
|
parser = ArgumentParser(description=xmpphandler.Slixfeed.__doc__)
|
2023-07-16 17:23:10 +02:00
|
|
|
|
|
|
|
# Output verbosity options.
|
|
|
|
parser.add_argument(
|
|
|
|
"-q", "--quiet", help="set logging to ERROR",
|
|
|
|
action="store_const", dest="loglevel",
|
|
|
|
const=logging.ERROR, default=logging.INFO
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-d", "--debug", help="set logging to DEBUG",
|
|
|
|
action="store_const", dest="loglevel",
|
|
|
|
const=logging.DEBUG, default=logging.INFO
|
|
|
|
)
|
|
|
|
|
|
|
|
# JID and password options.
|
|
|
|
parser.add_argument("-j", "--jid", dest="jid",
|
|
|
|
help="JID to use")
|
|
|
|
parser.add_argument("-p", "--password", dest="password",
|
|
|
|
help="password to use")
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# Setup logging.
|
|
|
|
logging.basicConfig(level=args.loglevel,
|
|
|
|
format='%(levelname)-8s %(message)s')
|
|
|
|
|
|
|
|
if args.jid is None:
|
|
|
|
args.jid = input("Username: ")
|
|
|
|
if args.password is None:
|
|
|
|
args.password = getpass("Password: ")
|
|
|
|
|
|
|
|
# Setup the Slixfeed and register plugins. Note that while plugins may
|
|
|
|
# have interdependencies, the order in which you register them does
|
|
|
|
# not matter.
|
2023-11-02 06:14:01 +01:00
|
|
|
xmpp = xmpphandler.Slixfeed(args.jid, args.password)
|
2023-07-16 17:23:10 +02:00
|
|
|
xmpp.register_plugin('xep_0004') # Data Forms
|
|
|
|
xmpp.register_plugin('xep_0030') # Service Discovery
|
|
|
|
xmpp.register_plugin('xep_0045') # Multi-User Chat
|
2023-11-26 16:23:52 +01:00
|
|
|
xmpp.register_plugin('xep_0048') # Bookmarks
|
2023-07-16 17:23:10 +02:00
|
|
|
xmpp.register_plugin('xep_0060') # PubSub
|
2023-11-27 18:22:56 +01:00
|
|
|
xmpp.register_plugin('xep_0199', {'keepalive': True, 'frequency': 15}) # XMPP Ping
|
2023-11-26 06:48:09 +01:00
|
|
|
xmpp.register_plugin('xep_0249') # Multi-User Chat
|
2023-11-27 18:22:56 +01:00
|
|
|
xmpp.register_plugin('xep_0402') # PEP Native Bookmarks
|
2023-07-16 17:23:10 +02:00
|
|
|
|
|
|
|
# Connect to the XMPP server and start processing XMPP stanzas.
|
|
|
|
xmpp.connect()
|
|
|
|
xmpp.process()
|