Xonotic
matrix.qh File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void MX_Forget (string room)
 
void MX_Join (string room)
 
void MX_Leave (string room)
 
void MX_Messages (string from)
 
void MX_Nick (string name)
 
void MX_Say (string body)
 
void MX_Sync (string since)
 
void MX_Typing (bool state)
 
var void (int buf, string ancestor) MX_Handle
 

Variables

string autocvar_matrix_server = "http://matrix.org"
 
string matrix_access_token
 
string matrix_room
 
string matrix_user
 

Function Documentation

◆ MX_Forget()

void MX_Forget ( string  room)

Definition at line 135 of file matrix.qc.

References autocvar_matrix_server, FILE_WRITE, matrix_access_token, matrix_room, MX_JLF_(), NULL, and url_single_fopen().

Referenced by GENERIC_COMMAND().

136 {
137  if (!matrix_access_token) return;
139  sprintf("%s/_matrix/client/r0/rooms/%s/forget?access_token=%s", autocvar_matrix_server, matrix_room, matrix_access_token),
140  FILE_WRITE,
141  MX_JLF_,
142  NULL
143  );
144 }
string matrix_access_token
Definition: matrix.qh:5
string matrix_room
Definition: matrix.qh:6
#define NULL
Definition: post.qh:17
const float FILE_WRITE
Definition: csprogsdefs.qc:233
ERASEABLE void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass)
Definition: urllib.qc:87
void MX_JLF_(entity fh, entity pass, int status)
Definition: matrix.qc:145
string autocvar_matrix_server
Definition: matrix.qh:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MX_Join()

void MX_Join ( string  room)

Definition at line 115 of file matrix.qc.

References autocvar_matrix_server, FILE_WRITE, matrix_access_token, matrix_room, MX_JLF_(), NULL, and url_single_fopen().

Referenced by GENERIC_COMMAND().

116 {
117  if (!matrix_access_token) return;
119  sprintf("%s/_matrix/client/r0/rooms/%s/join?access_token=%s", autocvar_matrix_server, matrix_room, matrix_access_token),
120  FILE_WRITE,
121  MX_JLF_,
122  NULL
123  );
124 }
string matrix_access_token
Definition: matrix.qh:5
string matrix_room
Definition: matrix.qh:6
#define NULL
Definition: post.qh:17
const float FILE_WRITE
Definition: csprogsdefs.qc:233
ERASEABLE void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass)
Definition: urllib.qc:87
void MX_JLF_(entity fh, entity pass, int status)
Definition: matrix.qc:145
string autocvar_matrix_server
Definition: matrix.qh:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MX_Leave()

void MX_Leave ( string  room)

Definition at line 125 of file matrix.qc.

References autocvar_matrix_server, FILE_WRITE, matrix_access_token, matrix_room, MX_JLF_(), NULL, and url_single_fopen().

Referenced by GENERIC_COMMAND().

126 {
127  if (!matrix_access_token) return;
129  sprintf("%s/_matrix/client/r0/rooms/%s/leave?access_token=%s", autocvar_matrix_server, matrix_room, matrix_access_token),
130  FILE_WRITE,
131  MX_JLF_,
132  NULL
133  );
134 }
string matrix_access_token
Definition: matrix.qh:5
string matrix_room
Definition: matrix.qh:6
#define NULL
Definition: post.qh:17
const float FILE_WRITE
Definition: csprogsdefs.qc:233
ERASEABLE void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass)
Definition: urllib.qc:87
void MX_JLF_(entity fh, entity pass, int status)
Definition: matrix.qc:145
string autocvar_matrix_server
Definition: matrix.qh:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MX_Messages()

void MX_Messages ( string  from)

Definition at line 34 of file matrix.qc.

References autocvar_matrix_server, FILE_READ, matrix_access_token, matrix_room, MX_Messages_(), NULL, and url_single_fopen().

Referenced by GENERIC_COMMAND(), and MX_Messages_().

35 {
36  if (!matrix_access_token) return;
37  string s = sprintf("%s/_matrix/client/r0/events?room_id=%s&limit=50&timeout=30000&from=%s&access_token=%s", autocvar_matrix_server, matrix_room, from, matrix_access_token);
39  s,
40  FILE_READ,
42  NULL
43  );
44 }
string matrix_access_token
Definition: matrix.qh:5
const float FILE_READ
Definition: csprogsdefs.qc:231
string matrix_room
Definition: matrix.qh:6
#define NULL
Definition: post.qh:17
ERASEABLE void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass)
Definition: urllib.qc:87
void MX_Messages_(entity fh, entity pass, int status)
Definition: matrix.qc:45
string autocvar_matrix_server
Definition: matrix.qh:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MX_Nick()

void MX_Nick ( string  name)

Definition at line 6 of file matrix.qc.

References autocvar_matrix_server, entity(), FILE_WRITE, matrix_access_token, matrix_user, MX_Nick_(), name, new_pure, pass, and url_single_fopen().

Referenced by GENERIC_COMMAND().

7 {
8  if (!matrix_access_token) return;
9  entity pass = new_pure(mx);
10  pass.message = name;
12  sprintf("%s/_matrix/client/r0/profile/%s/displayname?access_token=%s", autocvar_matrix_server, matrix_user, matrix_access_token),
13  FILE_WRITE,
14  MX_Nick_,
15  pass
16  );
17 }
entity() spawn
string matrix_access_token
Definition: matrix.qh:5
string matrix_user
Definition: matrix.qh:4
const float FILE_WRITE
Definition: csprogsdefs.qc:233
ERASEABLE void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass)
Definition: urllib.qc:87
#define new_pure(class)
purely logical entities (.origin doesn't work)
Definition: oo.qh:62
void MX_Nick_(entity fh, entity pass, int status)
Definition: matrix.qc:18
#define pass(name, colormin, colormax)
string autocvar_matrix_server
Definition: matrix.qh:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MX_Say()

void MX_Say ( string  body)

Definition at line 187 of file matrix.qc.

References autocvar_matrix_server, entity(), FILE_WRITE, matrix_access_token, matrix_room, MX_Say_(), new_pure, pass, strzone(), and url_single_fopen().

Referenced by GENERIC_COMMAND(), and Say().

188 {
189  if (!matrix_access_token) return;
190  static int txnid;
191  entity pass = new_pure(mx);
192  pass.message = strzone(body);
194  sprintf("%s/_matrix/client/r0/rooms/%s/send/m.room.message/%d?access_token=%s", autocvar_matrix_server, matrix_room, ++txnid, matrix_access_token),
195  FILE_WRITE,
196  MX_Say_,
197  pass
198  );
199 }
entity() spawn
string matrix_access_token
Definition: matrix.qh:5
string matrix_room
Definition: matrix.qh:6
const float FILE_WRITE
Definition: csprogsdefs.qc:233
ERASEABLE void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass)
Definition: urllib.qc:87
#define new_pure(class)
purely logical entities (.origin doesn't work)
Definition: oo.qh:62
#define pass(name, colormin, colormax)
void MX_Say_(entity fh, entity pass, int status)
Definition: matrix.qc:200
string autocvar_matrix_server
Definition: matrix.qh:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MX_Sync()

void MX_Sync ( string  since)

Definition at line 70 of file matrix.qc.

References autocvar_matrix_server, FILE_READ, matrix_access_token, matrix_room, MX_Sync_(), NULL, strcat(), and url_single_fopen().

Referenced by GENERIC_COMMAND(), and MX_Sync_().

71 {
72  if (!matrix_access_token) return;
73  string s = strcat(autocvar_matrix_server, "/_matrix/client/r0/sync?");
74  if (since) {
75  s = strcat(s,
76  "since=", since, "&",
77  "timeout=30000&",
78  sprintf("filter={\"account_data\":{\"types\":[]},\"presence\":{\"types\":[]},\"room\":{\"rooms\":[\"%s\"]}}&", matrix_room)
79  );
80  } else {
81  s = strcat(s,
82  "timeout=0&",
83  "filter={\"account_data\":{\"types\":[]},\"presence\":{\"types\":[]},\"room\":{\"rooms\":[]}}&"
84  );
85  }
86  s = strcat(s, "access_token=", matrix_access_token);
88 }
void MX_Sync_(entity fh, entity pass, int status)
Definition: matrix.qc:89
string matrix_access_token
Definition: matrix.qh:5
const float FILE_READ
Definition: csprogsdefs.qc:231
string matrix_room
Definition: matrix.qh:6
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
ERASEABLE void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass)
Definition: urllib.qc:87
string autocvar_matrix_server
Definition: matrix.qh:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MX_Typing()

void MX_Typing ( bool  state)

Definition at line 159 of file matrix.qc.

References autocvar_matrix_server, entity(), FILE_WRITE, matrix_access_token, matrix_room, matrix_user, MX_Typing_(), new_pure, pass, and url_single_fopen().

Referenced by GENERIC_COMMAND().

160 {
161  if (!matrix_access_token) return;
162  entity pass = new_pure(mx);
163  pass.message = state ? "true" : "false";
165  sprintf("%s/_matrix/client/r0/rooms/%s/typing/%s?access_token=%s", autocvar_matrix_server, matrix_room, matrix_user, matrix_access_token),
166  FILE_WRITE,
167  MX_Typing_,
168  pass
169  );
170 }
float state
Definition: subs.qh:32
entity() spawn
string matrix_access_token
Definition: matrix.qh:5
string matrix_room
Definition: matrix.qh:6
string matrix_user
Definition: matrix.qh:4
void MX_Typing_(entity fh, entity pass, int status)
Definition: matrix.qc:171
const float FILE_WRITE
Definition: csprogsdefs.qc:233
ERASEABLE void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass)
Definition: urllib.qc:87
#define new_pure(class)
purely logical entities (.origin doesn't work)
Definition: oo.qh:62
#define pass(name, colormin, colormax)
string autocvar_matrix_server
Definition: matrix.qh:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ void()

var void ( int  buf,
string  ancestor 
)

Variable Documentation

◆ autocvar_matrix_server

string autocvar_matrix_server = "http://matrix.org"

Definition at line 3 of file matrix.qh.

Referenced by MX_Forget(), MX_Join(), MX_Leave(), MX_Messages(), MX_Nick(), MX_Say(), MX_Sync(), and MX_Typing().

◆ matrix_access_token

string matrix_access_token

◆ matrix_room

string matrix_room

◆ matrix_user

string matrix_user

Definition at line 4 of file matrix.qh.

Referenced by GENERIC_COMMAND(), MX_Handle(), MX_Nick(), and MX_Typing().