mirror of
https://github.com/nicolabs/nicobot.git
synced 2025-09-07 05:14:01 +02:00
+ .omemo directory is now placed inside the configuration directory and is created if missing
This commit is contained in:
parent
3cb25d287e
commit
314df61e4d
|
@ -109,7 +109,8 @@ class ArgsHelper:
|
||||||
|
|
||||||
def jabber_chatter( args ):
|
def jabber_chatter( args ):
|
||||||
"""
|
"""
|
||||||
Builds a JabberChatter from Namespace argument 'args'
|
Builds a JabberChatter from Namespace argument 'args'.
|
||||||
|
Sets its data directory to <config_dir>/.omemo
|
||||||
"""
|
"""
|
||||||
|
|
||||||
username = args.jabber_username if args.jabber_username else args.username
|
username = args.jabber_username if args.jabber_username else args.username
|
||||||
|
@ -124,7 +125,8 @@ class ArgsHelper:
|
||||||
return JabberChatter(
|
return JabberChatter(
|
||||||
jid=username,
|
jid=username,
|
||||||
password=args.jabber_password,
|
password=args.jabber_password,
|
||||||
recipient=recipients[0]
|
recipient=recipients[0],
|
||||||
|
data_dir=os.path.join(args.config_dir,".omemo")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ class SliXmppClient(ClientXMPP):
|
||||||
|
|
||||||
eme_ns = 'eu.siacs.conversations.axolotl'
|
eme_ns = 'eu.siacs.conversations.axolotl'
|
||||||
|
|
||||||
def __init__(self, jid, password, message_handler):
|
def __init__(self, jid, password, message_handler, data_dir):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
jid, password : valid account to send and receive messages
|
jid, password : valid account to send and receive messages
|
||||||
|
@ -46,16 +46,18 @@ class SliXmppClient(ClientXMPP):
|
||||||
self.register_plugin('xep_0199') # XMPP Ping
|
self.register_plugin('xep_0199') # XMPP Ping
|
||||||
self.register_plugin('xep_0380') # Explicit Message Encryption
|
self.register_plugin('xep_0380') # Explicit Message Encryption
|
||||||
|
|
||||||
|
if not os.path.exists(data_dir):
|
||||||
|
os.makedirs(data_dir)
|
||||||
try:
|
try:
|
||||||
self.register_plugin(
|
self.register_plugin(
|
||||||
'xep_0384',
|
'xep_0384',
|
||||||
{
|
{
|
||||||
'data_dir': '.omemo',
|
'data_dir': data_dir,
|
||||||
},
|
},
|
||||||
module=slixmpp_omemo,
|
module=slixmpp_omemo,
|
||||||
) # OMEMO
|
) # OMEMO
|
||||||
except (PluginCouldNotLoad,):
|
except (PluginCouldNotLoad,):
|
||||||
log.exception('And error occured when loading the omemo plugin.')
|
logging.exception('And error occured when loading the omemo plugin.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
self.message_handler = message_handler
|
self.message_handler = message_handler
|
||||||
|
@ -265,10 +267,10 @@ class JabberChatter(Chatter):
|
||||||
It implements nicobot.Chatter by wrapping an internal slixmpp.ClientXMPP instance.
|
It implements nicobot.Chatter by wrapping an internal slixmpp.ClientXMPP instance.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__( self, jid, password, recipient ):
|
def __init__( self, jid, password, recipient, data_dir ):
|
||||||
|
|
||||||
self.recipient = recipient
|
self.recipient = recipient
|
||||||
self.xmpp = SliXmppClient( jid, password, message_handler=self.on_xmpp_message )
|
self.xmpp = SliXmppClient( jid, password, message_handler=self.on_xmpp_message, data_dir=data_dir )
|
||||||
|
|
||||||
def on_xmpp_message( self, original_message, decrypted_body ):
|
def on_xmpp_message( self, original_message, decrypted_body ):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue