Skip to content

Commit 06d6ec0

Browse files
committed
Forgot this
1 parent 47b99c0 commit 06d6ec0

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

borogove/Status.hx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package borogove;
2+
3+
#if cpp
4+
import HaxeCBridge;
5+
#end
6+
7+
@:expose
8+
@:nullSafety(StrictThreaded)
9+
#if cpp
10+
@:build(HaxeCBridge.expose())
11+
@:build(HaxeSwiftBridge.expose())
12+
#end
13+
class Status {
14+
public final emoji: String;
15+
public final text: String;
16+
17+
public function new(emoji: String, text: String) {
18+
this.emoji = emoji;
19+
this.text = text;
20+
}
21+
22+
public function toString() {
23+
return emoji + (emoji == "" || text == "" ? "" : " ") + text;
24+
}
25+
26+
public function toStanza() {
27+
final s = new Stanza("activity", { xmlns: "http://jabber.org/protocol/activity" });
28+
if (text != "") s.textTag("text", text);
29+
if (emoji == "") {
30+
s.tag("undefined").tag("other").up().up();
31+
} else {
32+
s.tag("undefined").textTag("emoji", emoji, { xmlns: "https://ns.borogove.dev/" }).up();
33+
}
34+
return s;
35+
}
36+
}

0 commit comments

Comments
 (0)