aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorturret <turret@duck.com>2024-03-30 21:25:45 -0500
committerturret <turret@duck.com>2024-03-30 21:25:45 -0500
commit818ac0454c4b8e3abe28ed4fab411c50c3421e05 (patch)
tree9a1d7a538eec620e4124527975ec1fa89bab8d4b
parentf6b38bbdeeaa3645e1921ccc6114d43e25dd1083 (diff)
downloaddiscord-bot-skeleton-master.tar.gz
discord-bot-skeleton-master.tar.bz2
discord-bot-skeleton-master.zip
ex/hello: identifyHEADmaster
i PROMISE that there will be a stupid easy way to identify to the websocket, consisting probably of the user just declaring the intents somewhere (since we already have the token) welcome to the true beginnings of DBS (new acronym for this project instead of the lame TDBS since im not that cool)
-rw-r--r--example/hello.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/example/hello.c b/example/hello.c
index f192a52..fe208d5 100644
--- a/example/hello.c
+++ b/example/hello.c
@@ -1,16 +1,40 @@
#include <stdlib.h>
+#include <string.h>
+#include <sys/utsname.h>
#include <cJSON.h>
+#include <curl/curl.h>
#include <dbs/event.h>
#include <dbs/log.h>
+extern CURL *ws_handle;
+
int hello(cJSON *data)
{
- char *string = cJSON_Print(data);
- print("hello, world!");
- print("hello data: %s", string);
- free(string);
+ cJSON *ev_payload = cJSON_CreateObject();
+ cJSON *ev_data = cJSON_CreateObject();
+ cJSON_AddNumberToObject(ev_payload, "op", 2);
+ cJSON_AddItemToObject(ev_payload, "d", ev_data);
+
+ cJSON_AddStringToObject(ev_data, "token", getenv("TOKEN"));
+ cJSON_AddNumberToObject(ev_data, "intents", 0);
+
+ cJSON *properties = cJSON_CreateObject();
+ cJSON_AddItemToObject(ev_data, "properties", properties);
+ cJSON_AddStringToObject(properties, "browser", "DBS");
+ cJSON_AddStringToObject(properties, "device", "DBS");
+
+ struct utsname unamed;
+ uname(&unamed);
+ cJSON_AddStringToObject(properties, "os", unamed.sysname);
+
+ char *msg = cJSON_PrintUnformatted(ev_payload);
+ size_t sent;
+ curl_ws_send(ws_handle, msg, strlen(msg), &sent, 0, CURLWS_TEXT);
+ free(msg);
+ cJSON_Delete(ev_payload);
+ print("hello: sent IDENT");
return 0;
}