Skip to content

Instantly share code, notes, and snippets.

@legastero
legastero / mod_extdisco.lua
Created December 3, 2013 04:29
Combine the Prosody extdisco modules.
local st = require "util.stanza";
local hmac_sha1 = require "util.hashes".hmac_sha1;
local base64 = require "util.encodings".base64;
local os_time = os.time;
local services = module:get_option("external_services");
local xmlns_extdisco = "urn:xmpp:extdisco:1";
@legastero
legastero / gist:7127532
Last active December 26, 2015 09:09
Where to find XMPP/Jingle in JS resources
@legastero
legastero / prosody-setup.lua
Last active February 24, 2019 12:11
Set up a Prosody server to work with stanza.io/otalk (with websockets, mam, etc)
-- 1. apt-get install prosody-trunk
-- 2. Checkout prosody-modules on Google Code
-- 3. Move all modules to /usr/lib/prosody/modules
-- 4. Move the mod_smacks module to mod_smacks2 and copy it to mod_smacks3
-- 5. Move the files in mod_smacks* to match the new names
-- 6. In mod_smacks3/mod_smacks3.lua s/urn:xmpp:sm:2/urn:xmpp:sm:3/g
-- 7. Set the Prosody configuration to:
admins = { "ADMIN@HOST" }
daemonize = true
@legastero
legastero / pubsub_fis.xml
Created April 23, 2013 22:47
Thoughts on using Pubsub with FIS
<iq type="get" to="[email protected]/fis">
<query xmlns="http://jabber.org/protocol/disco#items" node="urn:xmpp:fis:shares:0">
<item jid="pubsub.example.com" node="file_share_1" name="Pictures" />
<item jid="pubsub.example.com" node="file_share_2" name="Music" />
</query>
</iq>
<iq type="get" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<items node="file_share_1" />
@legastero
legastero / search.xml
Created February 28, 2013 23:16
Thought experiments on generalized XMPP searching.
<iq type="get">
<query xmlns="X">
<search xmlns="urn:xmpp:search:0">
<x xmlns="jabber:x:data" type="submit">
...
</x>
</search>
<rsm xmlns="http://jabber.org/protocol/rsm">
<limit>10</limit>
</rsm>
@legastero
legastero / gist:4964296
Last active December 13, 2015 19:38
Experimenting with simplest ways to deal with XMPP streams over websockets, in JS.
var MAGIC_START_TOKEN = "<stream:stream ";
var ALT_MAGIC_START_TOKEN = "<stream ";
var MAGIC_END_TOKEN = "</stream:stream>";
var ALT_MAGIC_END_TOKEN = "</stream>";
var STREAM_START_TAG, STREAM_END_TAG;
if (frame == MAGIC_END_TOKEN || frame == ALT_MAGIC_END_TOKEN) {
onStreamEnd();
} else {
var doc;
@legastero
legastero / fis_disco.xml
Created January 25, 2013 00:14
Ponder options in exposing FIS data over disco.
<iq type="get" id="disco1">
<query xmlns="http://jabber.org/protocol/disco#items" node="urn:xmpp:fis:0" />
</iq>
<iq type="result" id="disco1">
<query xmlns="http://jabber.org/protocol/disco#items" node="urn:xmpp:fis:0">
<item jid="a@b" node="test1.txt" name="test1.txt" />
<item jid="a@b" node="test2.txt" name="test2.txt" />
<item jid="a@b" node="pics" name="pics" />
</query>
@legastero
legastero / fis_examples.xml
Created January 24, 2013 23:50
Experiment with cleaning up the XML in the new FIS XEP.
<!-- Notes:
The <offer />, and <request /> wrappers aren't needed, since that
information is provided by the IQ type.
The node attribute is the path of a file or directory in these
examples, but its not really required that the two match. There
could be a mapping of UUIDs to paths, with the node being the UUID.
Using the term node would make it easier conceptually for
future XEPs that tie in pubsub updates for new/changed/removed
@legastero
legastero / send_image.py
Last active October 10, 2021 16:12
Send an image in a chat message with SleekXMPP
import logging
import threading
import sleekxmpp
logging.basicConfig(level=logging.DEBUG)
class Bot(sleekxmpp.ClientXMPP):
def __init__(self, jid, password):
@legastero
legastero / bot.py
Last active December 18, 2018 19:58
Example SleekXMPP Bot
import logging
import threading
import sleekxmpp
from sleekxmpp.jid import JID
from sleekxmpp.xmlstream import ET
from sleekxmpp.exceptions import XMPPError
from sleekxmpp.plugins import BasePlugin, register_plugin
from sleekxmpp.stanza.roster import Roster, RosterItem