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": case "client":
from slixfeed.xmpp.client import Slixfeed from slixfeed.xmpp.client import Slixfeed
case "component": case "component":
from slixfeed.xmpp.component import Slixfeed from slixfeed.xmpp.component import SlixfeedComponent
class JabberComponent: class JabberComponent:
def __init__(self, jid, secret, hostname, port, alias): def __init__(self, jid, secret, hostname, port, alias=None):
xmpp = Slixfeed(jid, secret, hostname, port, alias) xmpp = SlixfeedComponent(jid, secret, hostname, port, alias)
xmpp.register_plugin('xep_0004') # Data Forms xmpp.register_plugin('xep_0004') # Data Forms
xmpp.register_plugin('xep_0030') # Service Discovery xmpp.register_plugin('xep_0030') # Service Discovery
xmpp.register_plugin('xep_0045') # Multi-User Chat xmpp.register_plugin('xep_0045') # Multi-User Chat
@ -139,11 +139,8 @@ class JabberComponent:
class JabberClient: class JabberClient:
def __init__(self, jid, password, alias): def __init__(self, jid, password, hostname=None, port=None, alias=None):
# Setup the Slixfeed and register plugins. Note that while plugins may xmpp = Slixfeed(jid, password, hostname, port, alias)
# have interdependencies, the order in which you register them does
# not matter.
xmpp = Slixfeed(jid, password, alias)
xmpp.register_plugin('xep_0004') # Data Forms xmpp.register_plugin('xep_0004') # Data Forms
xmpp.register_plugin('xep_0030') # Service Discovery xmpp.register_plugin('xep_0030') # Service Discovery
xmpp.register_plugin('xep_0045') # Multi-User Chat xmpp.register_plugin('xep_0045') # Multi-User Chat
@ -266,9 +263,9 @@ def main():
match xmpp_type: match xmpp_type:
case "client": case "client":
JabberClient(jid, password, alias) JabberClient(jid, password, hostname=hostname, port=port, alias=alias)
case "component": case "component":
JabberComponent(jid, password, hostname, port, alias) JabberComponent(jid, password, hostname, port, alias=alias)
sys.exit(0) sys.exit(0)
if __name__ == "__main__": if __name__ == "__main__":

View file

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

View file

@ -16,7 +16,14 @@ TODO
2) Assure message delivery before calling a new task. 2) Assure message delivery before calling a new task.
See https://slixmpp.readthedocs.io/en/latest/event_index.html#term-marker_acknowledged 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"): case _ if message_lowercase.startswith("html"):
message['html']=" message['html']="
Parse me! Parse me!
@ -91,7 +98,7 @@ class Slixfeed(slixmpp.ClientXMPP):
------- -------
News bot that sends updates from RSS feeds. 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) slixmpp.ClientXMPP.__init__(self, jid, password)
# NOTE # NOTE

View file

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