More fixes

This commit is contained in:
Schimon Jehudah 2024-01-24 20:28:14 +00:00
parent 386b10ae15
commit c1ef5acc7e
4 changed files with 25 additions and 20 deletions

View file

@ -112,12 +112,12 @@ match xmpp_type:
case "client":
from slixfeed.xmpp.client import Slixfeed
case "component":
from slixfeed.xmpp.component import Slixfeed
from slixfeed.xmpp.component import SlixfeedComponent
class JabberComponent:
def __init__(self, jid, secret, hostname, port, alias):
xmpp = Slixfeed(jid, secret, hostname, port, alias)
def __init__(self, jid, secret, hostname, port, alias=None):
xmpp = SlixfeedComponent(jid, secret, hostname, port, alias)
xmpp.register_plugin('xep_0004') # Data Forms
xmpp.register_plugin('xep_0030') # Service Discovery
xmpp.register_plugin('xep_0045') # Multi-User Chat
@ -139,11 +139,8 @@ class JabberComponent:
class JabberClient:
def __init__(self, jid, password, alias):
# 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, alias)
def __init__(self, jid, password, hostname=None, port=None, alias=None):
xmpp = Slixfeed(jid, password, hostname, port, alias)
xmpp.register_plugin('xep_0004') # Data Forms
xmpp.register_plugin('xep_0030') # Service Discovery
xmpp.register_plugin('xep_0045') # Multi-User Chat
@ -266,9 +263,9 @@ def main():
match xmpp_type:
case "client":
JabberClient(jid, password, alias)
JabberClient(jid, password, hostname=hostname, port=port, alias=alias)
case "component":
JabberComponent(jid, password, hostname, port, alias)
JabberComponent(jid, password, hostname, port, alias=alias)
sys.exit(0)
if __name__ == "__main__":

View file

@ -51,9 +51,15 @@ from slixfeed.url import (
import slixfeed.xmpp.bookmark as bookmark
from urllib import error
from urllib.parse import parse_qs, urlsplit
import xml2epub
import xml.etree.ElementTree as ET
try:
import xml2epub
except:
logging.info(
"Package xml2epub was not found.\n"
"ePUB support is disabled.")
try:
import html2text
except:

View file

@ -16,7 +16,14 @@ TODO
2) Assure message delivery before calling a new task.
See https://slixmpp.readthedocs.io/en/latest/event_index.html#term-marker_acknowledged
3) XHTTML-IM
3) Check the lesyt message sent by the bot.
This is essential in case bot restarts within an update interval.
Example:
Bot is set to send an update every 5 hours.
Bot was disconnected and reconnected after an hour.
Bot will send an update when it is connected, which is lesser than 5 hours as it should.
4) XHTTML-IM
case _ if message_lowercase.startswith("html"):
message['html']="
Parse me!
@ -91,7 +98,7 @@ class Slixfeed(slixmpp.ClientXMPP):
-------
News bot that sends updates from RSS feeds.
"""
def __init__(self, jid, password, alias):
def __init__(self, jid, password, hostname=None, port=None, alias=None):
slixmpp.ClientXMPP.__init__(self, jid, password)
# NOTE

View file

@ -85,13 +85,8 @@ loop = asyncio.get_event_loop()
# return current_time
class Slixfeed(slixmpp.ComponentXMPP):
"""
Slixmpp
-------
News bot that sends updates from RSS feeds.
"""
def __init__(self, jid, secret, hostname, port, alias):
class SlixfeedComponent(slixmpp.ComponentXMPP):
def __init__(self, jid, secret, hostname, port, alias=None):
slixmpp.ComponentXMPP.__init__(self, jid, secret, hostname, port)
# The session_start event will be triggered when