...
 
Commits (4)
NAME = "hhelper"
VERSION = "1.0.11"
......@@ -22,7 +22,7 @@ VAULT_TOKEN = os.getenv("VAULT_TOKEN", None)
# Send a message (and optional file) via XMPP to a room
class XmppMessage(slixmpp.ClientXMPP):
def __init__(self, room, filename, message):
def __init__(self, room, filename, message, loop):
jid = XMPP_JID
password = XMPP_PASSWORD
......@@ -31,6 +31,7 @@ class XmppMessage(slixmpp.ClientXMPP):
slixmpp.ClientXMPP.__init__(self, jid, password)
LOG.info("Initialized XMPP client instance")
self.loop = loop
self.room = room
self.filename = filename
self.message = message
......@@ -67,7 +68,7 @@ class XmppMessage(slixmpp.ClientXMPP):
self.disconnect()
async def disconnect_on_login_fail(self, event):
def disconnect_on_login_fail(self, event):
LOG.warning("Failed to login: %s", str(event))
self.disconnect()
......@@ -152,9 +153,11 @@ def vault_test(address, entity, token):
# Get an instance of XmppMessage
# Returns: a ready-to-connect instance of XmppMessage
def get_xmpp(room=DEFAULT_XMPP_ROOM, message=DEFAULT_XMPP_MESSAGE, filename=None):
def get_xmpp(
room=DEFAULT_XMPP_ROOM, message=DEFAULT_XMPP_MESSAGE, filename=None, loop=None
):
xmpp = XmppMessage(room, filename, message)
xmpp = XmppMessage(room, filename, message, loop)
xmpp.register_plugin("xep_0045")
xmpp.register_plugin("xep_0030")
xmpp.register_plugin("xep_0199")
......@@ -231,9 +234,11 @@ def get_vault_secret(secret):
# Send an XMPP message or file to a given room
def send_xmpp(room=DEFAULT_XMPP_ROOM, message=DEFAULT_XMPP_MESSAGE, filename=None):
def send_xmpp(
room=DEFAULT_XMPP_ROOM, message=DEFAULT_XMPP_MESSAGE, filename=None, loop=None
):
xmpp = get_xmpp(
room=str(room) + XMPP_ROOM_SUFFIX, message=message, filename=filename
room=str(room) + XMPP_ROOM_SUFFIX, message=message, filename=filename, loop=loop
)
if xmpp is False:
......@@ -241,7 +246,6 @@ def send_xmpp(room=DEFAULT_XMPP_ROOM, message=DEFAULT_XMPP_MESSAGE, filename=Non
return False
xmpp.connect()
xmpp.process(forever=False)
return True
......
......@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="hhelper",
version="1.0.10",
version="1.0.11",
author="Tyler Page",
author_email="hhelper-pypi@tpage.io",
description="A homelab helper module",
......