XMPP Client

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
leinad
Posts: 2
Joined: Sun Nov 14, 2010 12:38 pm

XMPP Client

Post by leinad » Sun Nov 14, 2010 11:39 pm

Hi,

here's a plug-in which connects to a Jabber server (eg Google Talk), and transforms received messages and online statuses into events.

It also let's you send messages through actions.

Received messages get transformed into 3 events:
XMPP.Message | Test
XMPP.Message | username@gmail.com | Test
XMPP.Message | username@gmail.com/resource | Test
so that you can choose the required granularity for each message

and online statuses look like
XMPP.Presence | Online | username@gmail.com/device1
XMPP.Presence | Online | username@gmail.com/device2
XMPP.Presence | Offline | username@gmail.com/device2
XMPP.Presence | Online | othername@gmail.com/somedevice

I'm using it to automatically lower the volume on my netbook when the main machine is turned off, because I usually plug in the headphones into it after turning it off. And when the main machine is turned on, the volume on the netbook is set to 100% because I then usually plug it into a mixer which requires the full audio level.

I'd appreciate to get some feedback.

Greetings,
Daniel
xmpp_test.png
Attachments
XMPP.zip
(148.48 KiB) Downloaded 369 times

HTPCanwender
Experienced User
Posts: 59
Joined: Wed Feb 08, 2012 9:41 pm
Location: Germany

Re: XMPP Client

Post by HTPCanwender » Mon Jan 04, 2016 12:18 am

I tried to use your plugin, but I did not get it work. I have a jabber account at jabber.de. When starting the plugin I get the following Error:

Fehler beim Start des Plugins: XMPP
Traceback (most recent call last) (1669):
File "C:\Program Files (x86)\EventGhost\eg\Classes\PluginInstanceInfo.py", line 177, in Start
self.instance.__start__(*self.args)
File "C:\Program Files (x86)\EventGhost\plugins\xmpp\__init__.py", line 123, in __start__
client.auth(username, password, resource=resource)
File "C:\Program Files (x86)\EventGhost\plugins\xmpp\xmpp\client.py", line 214, in auth
while not self.Dispatcher.Stream._document_attrs and self.Process(1): pass
AttributeError: Client instance has no attribute 'Dispatcher'

Can You please help me?

Snowbird
Experienced User
Posts: 349
Joined: Fri Jul 03, 2009 10:04 am

Re: XMPP Client

Post by Snowbird » Tue Dec 19, 2017 3:25 pm

HTPCanwender wrote:
Mon Jan 04, 2016 12:18 am
I tried to use your plugin, but I did not get it work. I have a jabber account at jabber.de. When starting the plugin I get the following Error:

Fehler beim Start des Plugins: XMPP
Traceback (most recent call last) (1669):
File "C:\Program Files (x86)\EventGhost\eg\Classes\PluginInstanceInfo.py", line 177, in Start
self.instance.__start__(*self.args)
File "C:\Program Files (x86)\EventGhost\plugins\xmpp\__init__.py", line 123, in __start__
client.auth(username, password, resource=resource)
File "C:\Program Files (x86)\EventGhost\plugins\xmpp\xmpp\client.py", line 214, in auth
while not self.Dispatcher.Stream._document_attrs and self.Process(1): pass
AttributeError: Client instance has no attribute 'Dispatcher'

Can You please help me?

I had the same problem as you, and after a lot of investigations I came up with a fix, that works for me, and I thought I could share it with you and others, here's what you have to do :

you need to edit just a single file, here is my path (yours could be different depending where you usually install your plugins) :
C:\ProgramData\EventGhost\plugins\XMPP\xmpp\transports.py

open the file and go around line 32, comment this line :

Code: Select all

#import socket,select,base64,dispatcher,sys
and add this line instead :

Code: Select all

import socket,ssl,select,base64,dispatcher,sys
and now, go around line 324, and comment these 3 lines :

Code: Select all

#          tcpsock._sslObj    = socket.ssl(tcpsock._sock, None, None)
#          tcpsock._sslIssuer = tcpsock._sslObj.issuer()
#          tcpsock._sslServer = tcpsock._sslObj.server()
and add these 3 lines instead :

Code: Select all

          tcpsock._sslObj    = ssl.wrap_socket(tcpsock._sock, None, None)
          tcpsock._sslIssuer = tcpsock._sslObj.getpeercert().get('issuer')
          tcpsock._sslServer = tcpsock._sslObj.getpeercert().get('server')
As you can see, this fix is all about SSL support, no more errors !! it took me days to find this fix and I hope it will work for you too ! :)

Now remains 2 other problems with this plugin, although it works good, it could be perfect, let me explain :

1/ there is no support of variables, for example you can't put {eg.result} in the field where you can send messages, all you can do is put some regular text and that's all. This is a huge limitation and could be fixed rather easily by some folks on this forum (first person that comes to my mind is kg ;) )

2/ there is no proper auto-reconnection functionality when you're disconnected from the server (either the XMPP server disconnects you for some reason, or when you lose your internet connection), sometimes it reconnects automatically and sometimes it won't... so not very reliable ! and sometimes because of this behavior, EG completely freezes !! only a restart of EG can fix this... The workaround I've found so far, is to disable the XMPP plugin, wait 2 seconds, then re-enable it, not very clean solution, but at least it works :) I think there must be some "ping" functionality that needs to be addressed to solve this issue, to tell the remote server that we are "alive", thus do not close the connection ! more information here :
https://xmpp.org/extensions/xep-0199.html
I was glad to find out that I wasn't the only one having this issue : viewtopic.php?f=9&t=6797

So for now, I'm using this plugin with those limitations, until some smart guy can improve things with this plugin.

Post Reply