forked from sch/Slixfeed
Segregate XMPP (Jabber) client and component; each to its respective module.
This commit is contained in:
parent
78a83ff121
commit
f8bdfca972
4 changed files with 78 additions and 73 deletions
|
@ -107,82 +107,11 @@ match account_mode:
|
||||||
class JabberComponent:
|
class JabberComponent:
|
||||||
def __init__(self, jid, secret, hostname, port, alias=None):
|
def __init__(self, jid, secret, hostname, port, alias=None):
|
||||||
xmpp = SlixfeedComponent(jid, secret, hostname, port, alias)
|
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
|
|
||||||
# xmpp.register_plugin('xep_0048') # Bookmarks
|
|
||||||
xmpp.register_plugin('xep_0050') # Ad-Hoc Commands
|
|
||||||
xmpp.register_plugin('xep_0054') # vcard-temp
|
|
||||||
xmpp.register_plugin('xep_0060') # Publish-Subscribe
|
|
||||||
# xmpp.register_plugin('xep_0065') # SOCKS5 Bytestreams
|
|
||||||
xmpp.register_plugin('xep_0066') # Out of Band Data
|
|
||||||
xmpp.register_plugin('xep_0071') # XHTML-IM
|
|
||||||
xmpp.register_plugin('xep_0084') # User Avatar
|
|
||||||
xmpp.register_plugin('xep_0085') # Chat State Notifications
|
|
||||||
xmpp.register_plugin('xep_0115') # Entity Capabilities
|
|
||||||
xmpp.register_plugin('xep_0122') # Data Forms Validation
|
|
||||||
xmpp.register_plugin('xep_0153') # vCard-Based Avatars
|
|
||||||
xmpp.register_plugin('xep_0199') # XMPP Ping
|
|
||||||
xmpp.register_plugin('xep_0203') # Delayed Delivery
|
|
||||||
xmpp.register_plugin('xep_0249') # Direct MUC Invitations
|
|
||||||
xmpp.register_plugin('xep_0297') # Stanza Forwarding
|
|
||||||
xmpp.register_plugin('xep_0356') # Privileged Entity
|
|
||||||
xmpp.register_plugin('xep_0363') # HTTP File Upload
|
|
||||||
xmpp.register_plugin('xep_0402') # PEP Native Bookmarks
|
|
||||||
xmpp.register_plugin('xep_0444') # Message Reactions
|
|
||||||
xmpp.connect()
|
|
||||||
xmpp.process()
|
|
||||||
|
|
||||||
|
|
||||||
class JabberClient:
|
class JabberClient:
|
||||||
def __init__(self, jid, password, hostname=None, port=None, alias=None):
|
def __init__(self, jid, password, hostname=None, port=None, alias=None):
|
||||||
xmpp = Slixfeed(jid, password, hostname, port, alias)
|
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
|
|
||||||
xmpp.register_plugin('xep_0048') # Bookmarks
|
|
||||||
xmpp.register_plugin('xep_0050') # Ad-Hoc Commands
|
|
||||||
xmpp.register_plugin('xep_0054') # vcard-temp
|
|
||||||
xmpp.register_plugin('xep_0060') # Publish-Subscribe
|
|
||||||
# xmpp.register_plugin('xep_0065') # SOCKS5 Bytestreams
|
|
||||||
xmpp.register_plugin('xep_0066') # Out of Band Data
|
|
||||||
xmpp.register_plugin('xep_0071') # XHTML-IM
|
|
||||||
xmpp.register_plugin('xep_0084') # User Avatar
|
|
||||||
xmpp.register_plugin('xep_0085') # Chat State Notifications
|
|
||||||
xmpp.register_plugin('xep_0115') # Entity Capabilities
|
|
||||||
xmpp.register_plugin('xep_0122') # Data Forms Validation
|
|
||||||
xmpp.register_plugin('xep_0153') # vCard-Based Avatars
|
|
||||||
xmpp.register_plugin('xep_0199', {'keepalive': True}) # XMPP Ping
|
|
||||||
xmpp.register_plugin('xep_0249') # Direct MUC Invitations
|
|
||||||
xmpp.register_plugin('xep_0363') # HTTP File Upload
|
|
||||||
xmpp.register_plugin('xep_0402') # PEP Native Bookmarks
|
|
||||||
xmpp.register_plugin('xep_0444') # Message Reactions
|
|
||||||
|
|
||||||
# proxy_enabled = config.get_value('accounts', 'XMPP', 'proxy_enabled')
|
|
||||||
# if proxy_enabled == '1':
|
|
||||||
# values = config.get_value('accounts', 'XMPP', [
|
|
||||||
# 'proxy_host',
|
|
||||||
# 'proxy_port',
|
|
||||||
# 'proxy_username',
|
|
||||||
# 'proxy_password'
|
|
||||||
# ])
|
|
||||||
# print('Proxy is enabled: {}:{}'.format(values[0], values[1]))
|
|
||||||
# xmpp.use_proxy = True
|
|
||||||
# xmpp.proxy_config = {
|
|
||||||
# 'host': values[0],
|
|
||||||
# 'port': values[1],
|
|
||||||
# 'username': values[2],
|
|
||||||
# 'password': values[3]
|
|
||||||
# }
|
|
||||||
# proxy = {'socks5': (values[0], values[1])}
|
|
||||||
# xmpp.proxy = {'socks5': ('localhost', 9050)}
|
|
||||||
|
|
||||||
# Connect to the XMPP server and start processing XMPP stanzas.
|
|
||||||
if hostname and port:
|
|
||||||
xmpp.connect((hostname, port))
|
|
||||||
else:
|
|
||||||
xmpp.connect()
|
|
||||||
xmpp.process()
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
__version__ = '0.1.69'
|
__version__ = '0.1.70'
|
||||||
__version_info__ = (0, 1, 69)
|
__version_info__ = (0, 1, 70)
|
||||||
|
|
|
@ -149,6 +149,47 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
self.max_connection_attempts = 10
|
self.max_connection_attempts = 10
|
||||||
self.reconnect_timeout = config.get_values('accounts.toml', 'xmpp')['settings']['reconnect_timeout']
|
self.reconnect_timeout = config.get_values('accounts.toml', 'xmpp')['settings']['reconnect_timeout']
|
||||||
|
|
||||||
|
self.register_plugin('xep_0004') # Data Forms
|
||||||
|
self.register_plugin('xep_0030') # Service Discovery
|
||||||
|
self.register_plugin('xep_0045') # Multi-User Chat
|
||||||
|
self.register_plugin('xep_0048') # Bookmarks
|
||||||
|
self.register_plugin('xep_0050') # Ad-Hoc Commands
|
||||||
|
self.register_plugin('xep_0054') # vcard-temp
|
||||||
|
self.register_plugin('xep_0060') # Publish-Subscribe
|
||||||
|
# self.register_plugin('xep_0065') # SOCKS5 Bytestreams
|
||||||
|
self.register_plugin('xep_0066') # Out of Band Data
|
||||||
|
self.register_plugin('xep_0071') # XHTML-IM
|
||||||
|
self.register_plugin('xep_0084') # User Avatar
|
||||||
|
self.register_plugin('xep_0085') # Chat State Notifications
|
||||||
|
self.register_plugin('xep_0115') # Entity Capabilities
|
||||||
|
self.register_plugin('xep_0122') # Data Forms Validation
|
||||||
|
self.register_plugin('xep_0153') # vCard-Based Avatars
|
||||||
|
self.register_plugin('xep_0199', {'keepalive': True}) # XMPP Ping
|
||||||
|
self.register_plugin('xep_0203') # Delayed Delivery
|
||||||
|
self.register_plugin('xep_0249') # Direct MUC Invitations
|
||||||
|
self.register_plugin('xep_0363') # HTTP File Upload
|
||||||
|
self.register_plugin('xep_0402') # PEP Native Bookmarks
|
||||||
|
self.register_plugin('xep_0444') # Message Reactions
|
||||||
|
|
||||||
|
# proxy_enabled = config.get_value('accounts', 'XMPP', 'proxy_enabled')
|
||||||
|
# if proxy_enabled == '1':
|
||||||
|
# values = config.get_value('accounts', 'XMPP', [
|
||||||
|
# 'proxy_host',
|
||||||
|
# 'proxy_port',
|
||||||
|
# 'proxy_username',
|
||||||
|
# 'proxy_password'
|
||||||
|
# ])
|
||||||
|
# print('Proxy is enabled: {}:{}'.format(values[0], values[1]))
|
||||||
|
# self.use_proxy = True
|
||||||
|
# self.proxy_config = {
|
||||||
|
# 'host': values[0],
|
||||||
|
# 'port': values[1],
|
||||||
|
# 'username': values[2],
|
||||||
|
# 'password': values[3]
|
||||||
|
# }
|
||||||
|
# proxy = {'socks5': (values[0], values[1])}
|
||||||
|
# self.proxy = {'socks5': ('localhost', 9050)}
|
||||||
|
|
||||||
self.add_event_handler("session_start",
|
self.add_event_handler("session_start",
|
||||||
self.on_session_start)
|
self.on_session_start)
|
||||||
self.add_event_handler("session_resumed",
|
self.add_event_handler("session_resumed",
|
||||||
|
@ -208,6 +249,13 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
self.add_event_handler('session_end',
|
self.add_event_handler('session_end',
|
||||||
self.on_session_end)
|
self.on_session_end)
|
||||||
|
|
||||||
|
# Connect to the XMPP server and start processing XMPP stanzas.
|
||||||
|
if hostname and port:
|
||||||
|
self.connect((hostname, port))
|
||||||
|
else:
|
||||||
|
self.connect()
|
||||||
|
self.process()
|
||||||
|
|
||||||
|
|
||||||
# TODO Test
|
# TODO Test
|
||||||
async def on_groupchat_invite(self, message):
|
async def on_groupchat_invite(self, message):
|
||||||
|
|
|
@ -139,6 +139,30 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
||||||
self.max_connection_attempts = 10
|
self.max_connection_attempts = 10
|
||||||
self.reconnect_timeout = config.get_values('accounts.toml', 'xmpp')['settings']['reconnect_timeout']
|
self.reconnect_timeout = config.get_values('accounts.toml', 'xmpp')['settings']['reconnect_timeout']
|
||||||
|
|
||||||
|
self.register_plugin('xep_0004') # Data Forms
|
||||||
|
self.register_plugin('xep_0030') # Service Discovery
|
||||||
|
self.register_plugin('xep_0045') # Multi-User Chat
|
||||||
|
# self.register_plugin('xep_0048') # Bookmarks
|
||||||
|
self.register_plugin('xep_0050') # Ad-Hoc Commands
|
||||||
|
self.register_plugin('xep_0054') # vcard-temp
|
||||||
|
self.register_plugin('xep_0060') # Publish-Subscribe
|
||||||
|
# self.register_plugin('xep_0065') # SOCKS5 Bytestreams
|
||||||
|
self.register_plugin('xep_0066') # Out of Band Data
|
||||||
|
self.register_plugin('xep_0071') # XHTML-IM
|
||||||
|
self.register_plugin('xep_0084') # User Avatar
|
||||||
|
self.register_plugin('xep_0085') # Chat State Notifications
|
||||||
|
self.register_plugin('xep_0115') # Entity Capabilities
|
||||||
|
self.register_plugin('xep_0122') # Data Forms Validation
|
||||||
|
self.register_plugin('xep_0153') # vCard-Based Avatars
|
||||||
|
self.register_plugin('xep_0199') # XMPP Ping
|
||||||
|
self.register_plugin('xep_0203') # Delayed Delivery
|
||||||
|
self.register_plugin('xep_0249') # Direct MUC Invitations
|
||||||
|
self.register_plugin('xep_0297') # Stanza Forwarding
|
||||||
|
self.register_plugin('xep_0356') # Privileged Entity
|
||||||
|
self.register_plugin('xep_0363') # HTTP File Upload
|
||||||
|
self.register_plugin('xep_0402') # PEP Native Bookmarks
|
||||||
|
self.register_plugin('xep_0444') # Message Reactions
|
||||||
|
|
||||||
self.add_event_handler("session_start",
|
self.add_event_handler("session_start",
|
||||||
self.on_session_start)
|
self.on_session_start)
|
||||||
self.add_event_handler("session_resumed",
|
self.add_event_handler("session_resumed",
|
||||||
|
@ -198,6 +222,10 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
||||||
self.add_event_handler('session_end',
|
self.add_event_handler('session_end',
|
||||||
self.on_session_end)
|
self.on_session_end)
|
||||||
|
|
||||||
|
# Connect to the XMPP server and start processing XMPP stanzas.
|
||||||
|
self.connect()
|
||||||
|
self.process()
|
||||||
|
|
||||||
|
|
||||||
async def on_groupchat_invite(self, message):
|
async def on_groupchat_invite(self, message):
|
||||||
# logging.warning("on_groupchat_invite")
|
# logging.warning("on_groupchat_invite")
|
||||||
|
|
Loading…
Reference in a new issue