Quantcast
Viewing all articles
Browse latest Browse all 14

Servicio de XMPP para gnusocial

Image may be NSFW.
Clik here to view.

Para configurar esto tienes que ir a configuración y en la pestaña de IM introducir tu cuenta de XMPP y pulsar el botón «ADD». Verás un mensaje como este:

XMPP/Jabber gnusocial@xmpp.elbinario.net

Awaiting confirmation on this address. Check your XMPP/Jabber account for a message with further instructions. (Did you add gnusocial@xmpp.elbinario.net/gnusocial to your buddy list?)

Ahora viene la magia de python, un bot que simplemente accepte nuevos contactos La base del bot está aqui https://gitlab.com/barfoo/SimpleXMPPBot, simplemente he añadido una línea para que añada la función adecuada al capturar el evento de que alguien quiere suscribirse y mostrarle la presencia al mismo.

#!/usr/bin/env python

import xmpp
import ConfigParser
import sys

class XmppBot(object):

    def __init__(self):
        self.cfg = ConfigParser.ConfigParser()
        self.cfg.read("xmppbot.cfg")
        self.jid = xmpp.protocol.JID(self.cfg.get("bot", "jid"))
        self.password = self.cfg.get("bot", "password")
        self.room = self.cfg.get("bot", "room")
        self.owner = self.cfg.get("bot", "owner")
        self.client = xmpp.Client(self.jid.getDomain(), debug=[])
        self.con = self.client.connect()
        self.connect()
        self.client.RegisterHandler('presence', self.presence)
        while self.client.Process(1):
            pass

    def connect(self):
        if not self.con:
            print "Could not connect"
            sys.exit()
        auth = self.client.auth(self.jid.getNode(), self.password, resource=self.jid.getResource())
        if not auth:
            print "Authentication failed"
            sys.exit()
        if self.con:
            self.client.sendInitPresence()

    def presence(self, client, event):
        if event.getType() == 'subscribe':
            self.client.send(xmpp.Presence(to=event.getFrom(), typ='subscribed'))


if __name__ == "__main__":
    XmppBot = XmppBot()

El bot te pasará un link de confirmación para verificar que eres tú.

User «foo» on gnusocial.net has said that your XMPP/Jabber screenname belongs to them. If that is true, you can confirm by clicking on this URL: https://gnusocial.net/main/confirmaddress?code=QWOCULTO$AD$ . (If you cannot click it, copy-and-paste it into the address bar of your browser). If that user is not you, or if you did not request this confirmation, just ignore this message.

Al abrir el enlace en el navegador veras un mensaje conforme se confirma la activación para tu cuenta: The address «foo@xmpp.elbinario.net» has been confirmed for your account.

Más info de este plugin en https://git.gnu.io/gnu/gnu-social/tree/master/plugins/Xmpp

Hecho esto puedes configurar si quieres recibir notificaciones quips o replies o tu propio cambio de estado, también la pestaña IM.

¿Eres usuario de gnusocial.net y no has agregado al XMPP a gnusocial@xmpp.elbinario.net/gnusocial a tu roster? Pues ahora ya puedes quipear desde tu cuenta de XMPP sin más.


Viewing all articles
Browse latest Browse all 14

Trending Articles