Xonotic
matrix.qc
Go to the documentation of this file.
1 #include "matrix.qh"
2 
3 #include <server/chat.qh>
4 
5 var void MX_Handle(int buf, string ancestor)
6 {
7  string type = json_get(buf, strcat(ancestor, ".type"));
8  switch (type) {
9  case "m.room.message": {
10  string msgtype = json_get(buf, strcat(ancestor, ".content.msgtype"));
11  switch (msgtype) {
12  case "m.text": {
13  string sender = json_get(buf, strcat(ancestor, ".sender"));
14  string body = json_get(buf, strcat(ancestor, ".content.body"));
15  if (sender != matrix_user && body) Say(NULL, false, NULL, body, false);
16  break;
17  }
18  }
19  break;
20  }
21  }
22 }
int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodcontrol)
message "": do not say, just test flood control return value: 1 = accept 0 = reject -1 = fake accept ...
Definition: chat.qc:25
ERASEABLE string json_get(int buf, string key)
Definition: json.qc:276
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define NULL
Definition: post.qh:17
string matrix_user
Definition: matrix.qh:4