initial commit

This commit is contained in:
2026-01-29 21:35:36 +00:00
commit b0f9a7048a
17 changed files with 923 additions and 0 deletions

49
xmpp-helpers.go Normal file
View File

@@ -0,0 +1,49 @@
package main
import (
"fmt"
"gosrc.io/xmpp"
"gosrc.io/xmpp/stanza"
)
// This file has small functions that can be used to do XMPP stuff without writing tons of boilerplate
// Basic message sender. Anything more complex should be written by hand
func sendMessage(c xmpp.Sender, sendTo string, msgType stanza.StanzaType, body string, subject string, thread string) error {
m := stanza.Message{
Attrs: stanza.Attrs{
To: sendTo,
Type: msgType,
},
Body: body,
Subject: subject,
Thread: thread,
}
err := c.Send(m)
if err != nil {
return err
}
return nil
}
// Joins a MUC
func joinMuc(c xmpp.Sender, jid string, muc string, nick string) error{
addr := muc + "/" + nick
fmt.Println(addr)
joinPresence := stanza.Presence{
Attrs: stanza.Attrs{
From: jid,
To: addr,
},
Extensions: []stanza.PresExtension{
&stanza.MucPresence{
},
},
}
err := client.Send(joinPresence)
if err != nil {
return err
}
return nil
}