void MX_Nick_(entity fh, entity pass, int status);
void MX_Nick(string name)
{
+ if (!matrix_access_token) return;
entity pass = new_pure(mx);
pass.message = name;
url_single_fopen(
fh.url_verb = "PUT";
fh.url_content_type = "application/json";
url_fputs(fh, sprintf("{\"displayname\": \"%s\"}", pass.message));
- remove(pass);
+ delete(pass);
url_fclose(fh);
break;
}
void MX_Messages_(entity fh, entity pass, int status);
void MX_Messages(string from)
{
+ if (!matrix_access_token) return;
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);
url_single_fopen(
s,
{
switch (status) {
default: {
- LOG_WARNINGF("status: %d", status);
+ LOG_WARNF("status: %d", status);
break;
}
case URL_READY_CLOSED: break;
void MX_Sync_(entity fh, entity pass, int status);
void MX_Sync(string since)
{
+ if (!matrix_access_token) return;
string s = strcat(autocvar_matrix_server, "/_matrix/client/r0/sync?");
if (since) {
s = strcat(s,
{
switch (status) {
default: {
- LOG_WARNINGF("status: %d", status);
+ LOG_WARNF("status: %d", status);
break;
}
case URL_READY_CLOSED: break;
void MX_JLF_(entity fh, entity pass, int status);
void MX_Join(string room)
{
+ if (!matrix_access_token) return;
url_single_fopen(
sprintf("%s/_matrix/client/r0/rooms/%s/join?access_token=%s", autocvar_matrix_server, matrix_room, matrix_access_token),
FILE_WRITE,
}
void MX_Leave(string room)
{
+ if (!matrix_access_token) return;
url_single_fopen(
sprintf("%s/_matrix/client/r0/rooms/%s/leave?access_token=%s", autocvar_matrix_server, matrix_room, matrix_access_token),
FILE_WRITE,
}
void MX_Forget(string room)
{
+ if (!matrix_access_token) return;
url_single_fopen(
sprintf("%s/_matrix/client/r0/rooms/%s/forget?access_token=%s", autocvar_matrix_server, matrix_room, matrix_access_token),
FILE_WRITE,
void MX_Typing_(entity fh, entity pass, int status);
void MX_Typing(bool state)
{
+ if (!matrix_access_token) return;
entity pass = new_pure(mx);
pass.message = state ? "true" : "false";
url_single_fopen(
fh.url_verb = "PUT";
fh.url_content_type = "application/json";
url_fputs(fh, sprintf("{\"typing\": %s, \"timeout\": 30000}", pass.message));
- remove(pass);
+ delete(pass);
url_fclose(fh);
break;
}
void MX_Say_(entity fh, entity pass, int status);
void MX_Say(string body)
{
+ if (!matrix_access_token) return;
static int txnid;
entity pass = new_pure(mx);
pass.message = strzone(body);
fh.url_verb = "PUT";
fh.url_content_type = "application/json";
url_fputs(fh, sprintf("{\"msgtype\": \"m.text\", \"body\": \"%s\"}", pass.message));
- strunzone(pass.message); remove(pass);
+ strunzone(pass.message); delete(pass);
url_fclose(fh);
break;
}