Ejemplo n.º 1
0
    global $client, $config, $rooms;
    l("[JAXL] Connected with jid " . $client->full_jid->to_string());
    $client->get_vcard();
    $client->get_roster();
    $client->set_status("", "chat", 10);
    foreach ($config['rooms'] as $id => $jid) {
        $rooms[$id] = new \XMPPJid($jid . '/' . $config['botname']);
        l("[JAXL] Joining room " . $rooms[$id]->to_string());
        $client->xeps['0045']->join_room($rooms[$id]);
        l("[JAXL] Joined room " . $rooms[$id]->to_string());
    }
});
$roster = new roster();
$decks = array();
$client->add_cb('on_auth_failure', function ($reason) {
    global $client;
    $client->send_end_stream();
    l("[JAXL] Auth failure: " . $reason, L_WARN);
});
// Where the magic happens. "Magic" "Happens". I dunno why I type this either.
$client->add_cb('on_groupchat_message', function ($stanza) {
    new ligrevCommand($stanza, "groupchat");
});
$client->add_cb('on_chat_message', function ($stanza) {
    new ligrevCommand($stanza, "chat");
});
$client->add_cb('on_presence_stanza', function ($stanza) {
    global $roster;
    $roster->ingest($stanza);
});
$client->start();