From 7a201808e3c56775e02b0f37911066e012916317 Mon Sep 17 00:00:00 2001 From: sunglocto Date: Tue, 10 Mar 2026 16:48:10 +0000 Subject: [PATCH] format code & add additional assets --- assets.go | 7 ++----- assets/information.png | Bin 0 -> 778 bytes assets/jabber.png | Bin 0 -> 730 bytes gtk-helpers.go | 12 ++++++------ gtk-message.go | 28 ++++++++++++++-------------- main.go | 8 ++++---- types.go | 2 +- xmpp-attention.go | 2 +- xmpp-carbons.go | 1 - xmpp-helpers.go | 6 +++--- xmpp-mentions.go | 12 ++++++------ 11 files changed, 37 insertions(+), 41 deletions(-) create mode 100644 assets/information.png create mode 100644 assets/jabber.png diff --git a/assets.go b/assets.go index cb14740..87c25c2 100644 --- a/assets.go +++ b/assets.go @@ -1,10 +1,10 @@ package main import ( - "encoding/base64" _ "embed" - "github.com/diamondburned/gotk4/pkg/gdkpixbuf/v2" + "encoding/base64" "github.com/diamondburned/gotk4/pkg/gdk/v4" + "github.com/diamondburned/gotk4/pkg/gdkpixbuf/v2" ) //go:embed debug.png @@ -87,7 +87,6 @@ var connectB64 string = base64.StdEncoding.EncodeToString(connectBytes) var commentBytes []byte var commentB64 string = base64.StdEncoding.EncodeToString(commentBytes) - //go:embed assets/information.png var informationBytes []byte var informationB64 string = base64.StdEncoding.EncodeToString(informationBytes) @@ -245,7 +244,6 @@ func init() { clientAssets["connect"] = gdk.NewTextureForPixbuf(loader.Pixbuf()) - loader = gdkpixbuf.NewPixbufLoader() commentData, _ := base64.StdEncoding.DecodeString(commentB64) @@ -254,7 +252,6 @@ func init() { clientAssets["comment"] = gdk.NewTextureForPixbuf(loader.Pixbuf()) - loader = gdkpixbuf.NewPixbufLoader() informationData, _ := base64.StdEncoding.DecodeString(informationB64) diff --git a/assets/information.png b/assets/information.png new file mode 100644 index 0000000000000000000000000000000000000000..12cd1aef900803abba99b26920337ec01ad5c267 GIT binary patch literal 778 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7SkfJR9T^zbpD<_bdda}R zAX(xXQ4*Y=R#Ki=l*-_klAn~S;F+74o*I;zm{M7IGS!BGfoYDXi(`nz>7|oTXI}}I zIci_-vnIty&5&zmr&<5S6&e`}JA-sMj`}JFS%)|-(u*mXnkyRfQ=Ws%E^Ob1r6sf0 zwMNaF(spi<^vq)hSC5$VUz9LDsq**io%egczjpGd*&=OwT0h=S#^Sj|=+oMe&(9Q# zOHFhS%7%;kg{|FU!K<;5YwH*j z6pMI7=M~gfRkAJqyYut>)cZ^_`{ta#;gKhED@^?U-Kg_d<}BSI@UVH(ifCu8jeUnU z8!_A4$1H0L-pSp*S-at$_jha8I~NwN{dncuw5p z`n9$xZkN~vm^a*;f8+YSGZBTHf{snc*^l=h7EWnb-;lKN+$Is%p7VM|3Hj2;ZV78^ z-Z-(%?CSM^8JZ9GxbIn@c%giQFl(FpvWo%?&V_js*Ih}w;=Xn@-zqWQuHX&pygtkm znDXaw<-fHSdrB)lS`=DnuVCDh&dN}imABKWc#qg(LlcdI)p2S|DhgQyn<9ih@>gt% zI5xvzE7yj1*AnU`ZSyVUV4PEwQg3Z-pR*`0R`;*_Hw7gNL8~Ys9^SvaFVe7vEZo?a8$C->U$^jmd;B!Rt;>s;@2A{fRrG!1Yso8d zKJUHM_}_S6-czT$z$SKu!H?e>!aoo77;gM`=fKQ2^?8g7p0C!<46T>pRp*>4W|GjO o$z;x3^t`{Z_`m(K@{8On?3=11w<+#qU|?YIboFyt=akR{07JHBGXMYp literal 0 HcmV?d00001 diff --git a/assets/jabber.png b/assets/jabber.png new file mode 100644 index 0000000000000000000000000000000000000000..c0d11fbcddc7c359770a2d4bbee768748d81426e GIT binary patch literal 730 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4rT@h1`S>QU}(S0UbZ>P$`SGgZEV7!S~ine1%1Rd>hzqJGYG}Ail;FM#dFDIGYG|hdZ_*OlH7+| zs&CFne|`7q?bSu^F8RN`VDMtU?3;62KdhPl>+|>eqO_{A?6lm{sNjsx&py09ci`i# zdyn^vJlG@r<%zy~@F5?c)=&3B-``4mGS~d=PL>-pq`$ol{_&ym`^S#2ui8G`ZGC=7 zxw%*I7O22>o_Vn&>aVb<$apdGT zd$NQ3!EXN7rzKvV5P5$^>D^`dx0hs|EEoNno!#FAP6FaZpgO zW#Q8P_V)9)=kHCOCdjB~{`>dW%v9+!0|SFnNswPK14DvC!ut0H3g`E~e?PzAeL}*0 z1A+Yw4*MPUE8OpIP&hw7^{8t+0|Ub`PZ!4!iOb0e2?;4F>1)?*Onv+`Ati-@(QVqD zmMZzRTSDT+Iv6(ht(#bwQ@CJdB(rfu!{)VnPp`dj-u}SRsoXjO>vI<^TeooKnpyJ% zS;RQ_IC;7IgHN706?T@9yFmN-Q*jMV(Ul=#9~)R_WWAnpMtb(FwQF)`C|vt=bLMSp z3oFad+zxjSYP@*&@a0oo6`o>=#T_f=?Q2{pp&a92qhzFI<;J9_5E&E|7N^)MFkzaf wkC)#>R}O - - - Retracted - - - `, jid.MustParse(m.From).Bare().String(), uuid.New().String(), sid.ID)) - }) - rc_box.Append(moderate) - } + if m.Type == stanza.MessageTypeGroupchat { + moderate := gtk.NewButtonWithLabel("Moderate") // TODO: Implement proper support for moderations via extension + moderate.ConnectClicked(func() { + client.SendRaw(fmt.Sprintf(` + + + + Retracted + + + `, jid.MustParse(m.From).Bare().String(), uuid.New().String(), sid.ID)) + }) + rc_box.Append(moderate) + } */ quote := gtk.NewButtonWithLabel("Quote") diff --git a/main.go b/main.go index 1df73c2..2e5e83b 100644 --- a/main.go +++ b/main.go @@ -25,8 +25,8 @@ import ( _ "embed" "encoding/xml" "github.com/kr/pretty" - "runtime" "io" + "runtime" ) var loadedConfig lambdaConfig @@ -118,9 +118,9 @@ func main() { return charset.NewReaderLabel(c, input) }, }, - Jid: loadedConfig.Username + "/" + loadedConfig.Resource, - Credential: xmpp.Password(loadedConfig.Password), - Insecure: loadedConfig.Insecure, + Jid: loadedConfig.Username + "/" + loadedConfig.Resource, + Credential: xmpp.Password(loadedConfig.Password), + Insecure: loadedConfig.Insecure, // StreamLogger: os.Stdout, StreamManagementEnable: true, } diff --git a/types.go b/types.go index 3cc1ed5..f4204d6 100644 --- a/types.go +++ b/types.go @@ -13,7 +13,7 @@ type chatTab struct { type lambdaConfig struct { Server string Username string - Resource string + Resource string Password string Insecure bool Nick string diff --git a/xmpp-attention.go b/xmpp-attention.go index 0ddbac3..298f1c7 100644 --- a/xmpp-attention.go +++ b/xmpp-attention.go @@ -5,7 +5,7 @@ import ( "gosrc.io/xmpp/stanza" ) -// Implementation of XEP-0224: Attention +// Implementation of XEP-0224: Attention type Attention struct { stanza.MsgExtension diff --git a/xmpp-carbons.go b/xmpp-carbons.go index f2695e5..f457c49 100644 --- a/xmpp-carbons.go +++ b/xmpp-carbons.go @@ -14,7 +14,6 @@ type ReceivedCarbon struct { Forwarded stanza.Forwarded } - type SentCarbon struct { stanza.MsgExtension XMLName xml.Name `xml:"urn:xmpp:carbons:2 sent"` diff --git a/xmpp-helpers.go b/xmpp-helpers.go index 1256939..24b946d 100644 --- a/xmpp-helpers.go +++ b/xmpp-helpers.go @@ -15,9 +15,9 @@ func sendMessage(c xmpp.Sender, sendTo string, msgType stanza.StanzaType, body s To: sendTo, Type: msgType, }, - Body: body, - Subject: subject, - Thread: thread, + Body: body, + Subject: subject, + Thread: thread, Extensions: exts, } err := c.Send(m) diff --git a/xmpp-mentions.go b/xmpp-mentions.go index 064cadd..11b4b6e 100644 --- a/xmpp-mentions.go +++ b/xmpp-mentions.go @@ -10,12 +10,12 @@ import ( type Mention struct { stanza.MsgExtension - XMLName xml.Name `xml:"urn:xmpp:mentions:0 mention"` - Mentions string `xml:"mentions,attr,omitempty"` - URI string `xml:"uri,attr,omitempty"` - Begin int `xml:"begin,attr,omitempty"` - End int `xml:"end,attr,omitempty"` - OccupantID string `xml:"occupantid,attr,omitempty"` + XMLName xml.Name `xml:"urn:xmpp:mentions:0 mention"` + Mentions string `xml:"mentions,attr,omitempty"` + URI string `xml:"uri,attr,omitempty"` + Begin int `xml:"begin,attr,omitempty"` + End int `xml:"end,attr,omitempty"` + OccupantID string `xml:"occupantid,attr,omitempty"` } func init() {