forked from APE-Project/APE_Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
libape-setcord.c
executable file
·65 lines (47 loc) · 1.84 KB
/
libape-setcord.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdio.h>
#include "plugins.h"
#include "global_plugins.h"
#define MODULE_NAME "setcord"
/* You must name this "infos_module" because of macro READ_CONF */
static ace_plugin_infos infos_module = {
"Setcord", // Module Name
"0.02", // Module Version
"Anthony Catel", // Module Author
NULL // Config file
};
static unsigned int cmd_setpos(callbackp *callbacki)
{
/* ->param[1] is not used (sessid) */
int x = abs(atoi(callbacki->param[3])), y = abs(atoi(callbacki->param[4]));
char cx[8], cy[8];
if (x > 10000 || y > 10000) {
send_error(callbacki->call_user, "BAD_POS", "302", callbacki->g_ape);
} else {
json *jlist;
/* Get channel structure by name */
if (get_pipe_strict(callbacki->param[2], callbacki->call_user, callbacki->g_ape) == NULL) {
send_error(callbacki->call_user, "UNKNOWN_PIPE", "109", callbacki->g_ape);
/* Check if calling user is on this channel */
} else {
jlist = NULL;
/* Adding two persistant properties to calling user */
add_property(&callbacki->call_user->properties, "x", itos(x, cx), EXTEND_STR, EXTEND_ISPUBLIC);
add_property(&callbacki->call_user->properties, "y", itos(y, cy), EXTEND_STR, EXTEND_ISPUBLIC);
post_to_pipe(jlist, "POSITIONS", callbacki->param[2], getsubuser(callbacki->call_user, callbacki->host), NULL, callbacki->g_ape);
}
}
/* Nothing todo after */
return (FOR_NOTHING);
}
static void init_module(acetables *g_ape) // Called when module is loaded
{
register_cmd("SETPOS", 4, cmd_setpos, NEED_SESSID, g_ape);
}
static ace_callbacks callbacks = {
NULL, /* Called when new user is added */
NULL, /* Called when a user is disconnected */
NULL, /* Called when new chan is created */
NULL, /* Called when a user join a channel */
NULL /* Called when a user leave a channel */
};
APE_INIT_PLUGIN(MODULE_NAME, init_module, callbacks)