aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorturret <turret@duck.com>2024-03-30 20:35:30 -0500
committerturret <turret@duck.com>2024-03-30 20:35:30 -0500
commit2fb619ed6eac19afd7ed3b2c7baa4adc253f418e (patch)
tree521d3ec070fa39c398ec2d5835cac22bcd95190a /include
parent80a67b7d20393a29aa5d2cb92197f3381be7fd96 (diff)
downloaddiscord-bot-skeleton-2fb619ed6eac19afd7ed3b2c7baa4adc253f418e.tar.gz
discord-bot-skeleton-2fb619ed6eac19afd7ed3b2c7baa4adc253f418e.tar.bz2
discord-bot-skeleton-2fb619ed6eac19afd7ed3b2c7baa4adc253f418e.zip
net: event handler
in subsys.h: include init.h to ensure l5_initcall availability also: add example/ directory to provide some user-code in the skeleton (will likely be made defunct as i make the remainder of the skeleton, such as a /ping command and user action and maybe some buttons, which will require more organisation)
Diffstat (limited to 'include')
-rw-r--r--include/dbs/bits/events.h68
-rw-r--r--include/dbs/event.h20
-rw-r--r--include/dbs/subsys.h2
3 files changed, 90 insertions, 0 deletions
diff --git a/include/dbs/bits/events.h b/include/dbs/bits/events.h
new file mode 100644
index 0000000..de8b35d
--- /dev/null
+++ b/include/dbs/bits/events.h
@@ -0,0 +1,68 @@
+E(HELLO, hello)
+E(READY, ready)
+E(RESUMED, resumed)
+E(RECONNECT, reconnect)
+E(INVALID_SESSION, invalid_session)
+E(APPLICATION_COMMAND_PERMISSIONS_UPDATE, application_command_permissions_update)
+E(AUTO_MODERATION_RULE_CREATE, auto_moderation_rule_create)
+E(AUTO_MODERATION_RULE_UPDATE, auto_moderation_rule_update)
+E(AUTO_MODERATION_RULE_DELETE, auto_moderation_rule_delete)
+E(AUTO_MODERATION_ACTION_EXECUTION, auto_moderation_action_execution)
+E(CHANNEL_CREATE, channel_create)
+E(CHANNEL_UPDATE, channel_update)
+E(CHANNEL_DELETE, channel_delete)
+E(CHANNEL_PINS_UPDATE, channel_pins_update)
+E(THREAD_CREATE, thread_create)
+E(THREAD_UPDATE, thread_update)
+E(THREAD_DELETE, thread_delete)
+E(THREAD_LIST_SYNC, thread_list_sync)
+E(THREAD_MEMBER_UPDATE, thread_member_update)
+E(THREAD_MEMBERS_UPDATE, thread_members_update)
+E(ENTITLEMENT_CREATE, entitlement_create)
+E(ENTITLEMENT_UPDATE, entitlement_update)
+E(ENTITLEMENT_DELETE, entitlement_delete)
+E(GUILD_CREATE, guild_create)
+E(GUILD_UPDATE, guild_update)
+E(GUILD_DELETE, guild_delete)
+E(GUILD_AUDIT_LOG_ENTRY_CREATE, guild_audit_log_entry_create)
+E(GUILD_BAN_ADD, guild_ban_add)
+E(GUILD_BAN_REMOVE, guild_ban_remove)
+E(GUILD_EMOJIS_UPDATE, guild_emojis_update)
+E(GUILD_STICKERS_UPDATE, guild_stickers_update)
+E(GUILD_INTEGRATIONS_UPDATE, guild_integrations_update)
+E(GUILD_MEMBER_ADD, guild_member_add)
+E(GUILD_MEMBER_REMOVE, guild_member_remove)
+E(GUILD_MEMBER_UPDATE, guild_member_update)
+E(GUILD_MEMBERS_CHUNK, guild_members_chunk)
+E(GUILD_ROLE_CREATE, guild_role_create)
+E(GUILD_ROLE_UPDATE, guild_role_update)
+E(GUILD_ROLE_DELETE, guild_role_delete)
+E(GUILD_SCHEDULED_EVENT_CREATE, guild_scheduled_event_create)
+E(GUILD_SCHEDULED_EVENT_UPDATE, guild_scheduled_event_update)
+E(GUILD_SCHEDULED_EVENT_DELETE, guild_scheduled_event_delete)
+E(GUILD_SCHEDULED_EVENT_USER_ADD, guild_scheduled_event_user_add)
+E(GUILD_SCHEDULED_EVENT_USER_REMOVE, guild_scheduled_event_user_remove)
+E(INTEGRATION_CREATE, integration_create)
+E(INTEGRATION_UPDATE, integration_update)
+E(INTEGRATION_DELETE, integration_delete)
+E(INTERACTION_CREATE, interaction_create)
+E(INVITE_CREATE, invite_create)
+E(INVITE_DELETE, invite_delete)
+E(MESSAGE_CREATE, message_create)
+E(MESSAGE_UPDATE, message_update)
+E(MESSAGE_DELETE, message_delete)
+E(MESSAGE_DELETE_BULK, message_delete_bulk)
+E(MESSAGE_REACTION_ADD, message_reaction_add)
+E(MESSAGE_REACTION_REMOVE, message_reaction_remove)
+E(MESSAGE_REACTION_REMOVE_ALL, message_reaction_remove_all)
+E(MESSAGE_REACTION_REMOVE_EMOJI, message_reaction_remove_emoji)
+E(PRESENCE_UPDATE, presence_update)
+E(STAGE_INSTANCE_CREATE, stage_instance_create)
+E(STAGE_INSTANCE_UPDATE, stage_instance_update)
+E(STAGE_INSTANCE_DELETE, stage_instance_delete)
+E(TYPING_START, typing_start)
+E(USER_UPDATE, user_update)
+E(VOICE_STATE_UPDATE, voice_state_update)
+E(VOICE_SERVER_UPDATE, voice_server_update)
+E(WEBHOOKS_UPDATE, webhooks_update)
+E(EVENT_INVALID, event_invalid)
diff --git a/include/dbs/event.h b/include/dbs/event.h
new file mode 100644
index 0000000..6be3378
--- /dev/null
+++ b/include/dbs/event.h
@@ -0,0 +1,20 @@
+#ifndef __EVENT_H
+#define __EVENT_H
+
+#include <dbs/init.h>
+
+enum Event {
+#define E(ev_name, _) ev_name,
+#include <dbs/bits/events.h>
+#undef E
+};
+
+int ev_set_handler(enum Event event, int (*ev_handler)(cJSON*));
+
+#define declare_event(event, handler) \
+ void __decl_##event_##handler() { \
+ ev_set_handler(event, handler); \
+ } \
+ l3_initcall(__decl_##event_##handler)
+
+#endif
diff --git a/include/dbs/subsys.h b/include/dbs/subsys.h
index 1885a80..fa3b423 100644
--- a/include/dbs/subsys.h
+++ b/include/dbs/subsys.h
@@ -1,6 +1,8 @@
#ifndef __SUBSYS_H
#define __SUBSYS_H
+#include <dbs/init.h>
+
int __impl_start_subsystem(char *name, int (*fn)(void));
#define start_subsystem(fn) __impl_start_subsystem(#fn, fn)
#define declare_subsystem(fn) \