]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/matrix.qc
Merge branch 'master' into Mario/hagar_notfixed
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / matrix.qc
1 var void MX_Handle(int buf, string ancestor)
2 {
3     string type = json_get(buf, strcat(ancestor, ".type"));
4     switch (type) {
5         case "m.typing": {
6             string arr = strcat(ancestor, ".content.user_ids");
7             for (int i = 0, n = stof(json_get(buf, sprintf("%s.length", arr))); i < n; ++i) {
8                 string s = json_get(buf, sprintf("%s.%d", arr, i));
9                 print("\{1}", s, " is typing...\n");
10             }
11             break;
12         }
13         case "m.room.message": {
14             string msgtype = json_get(buf, strcat(ancestor, ".content.msgtype"));
15             switch (msgtype) {
16                 case "m.text": {
17                     string sender = json_get(buf, strcat(ancestor, ".sender"));
18                     string body = json_get(buf, strcat(ancestor, ".content.body"));
19                     if (body) print("\{1}", sender, ": ", body, "\n");
20                     break;
21                 }
22             }
23             break;
24         }
25     }
26 }