aboutsummaryrefslogtreecommitdiff
path: root/lib/models
diff options
context:
space:
mode:
authorAdelyn Breelove <[email protected]>2019-01-24 11:59:13 -0700
committerAdelyn Breelove <[email protected]>2019-01-24 11:59:13 -0700
commit2d61d1ffd77940eebd4e865ba1429c5798ed0b7c (patch)
tree08327e19f4047eace5d88dce7dde2997cf119406 /lib/models
parentImprove HTTP stuff (diff)
downloaddisml-2d61d1ffd77940eebd4e865ba1429c5798ed0b7c.tar.xz
disml-2d61d1ffd77940eebd4e865ba1429c5798ed0b7c.zip
Start of an event dispatch rework
Diffstat (limited to 'lib/models')
-rw-r--r--lib/models/channel/message/message_t.ml22
-rw-r--r--lib/models/channel/message/message_t.mli23
-rw-r--r--lib/models/event_models.ml347
-rw-r--r--lib/models/id/message_id.ml3
-rw-r--r--lib/models/id/message_id.mli3
-rw-r--r--lib/models/id/role_id.ml3
-rw-r--r--lib/models/id/role_id.mli3
-rw-r--r--lib/models/id/user_id.ml1
-rw-r--r--lib/models/id/user_id.mli2
-rw-r--r--lib/models/id/user_id_t.ml3
-rw-r--r--lib/models/id/user_id_t.mli3
-rw-r--r--lib/models/user/user.mli4
12 files changed, 369 insertions, 48 deletions
diff --git a/lib/models/channel/message/message_t.ml b/lib/models/channel/message/message_t.ml
index c4253d5..47b5803 100644
--- a/lib/models/channel/message/message_t.ml
+++ b/lib/models/channel/message/message_t.ml
@@ -1,27 +1,5 @@
open Core
-type message_update = {
- id: Snowflake.t;
- author: User_t.t option [@default None];
- channel_id: Snowflake.t;
- member: Member_t.partial_member option [@default None];
- guild_id: Snowflake.t option [@default None];
- content: string option [@default None];
- timestamp: string option [@default None];
- editedimestamp: string option [@default None];
- tts: bool option [@default None];
- mention_everyone: bool option [@default None];
- mentions: Snowflake.t list [@default []];
- role_mentions: Snowflake.t list [@default []];
- attachments: Attachment.t list [@default []];
- embeds: Embed.t list [@default []];
- reactions: Snowflake.t list [@default []];
- nonce: Snowflake.t option [@default None];
- pinned: bool option [@default None];
- webhook_id: Snowflake.t option [@default None];
- kind: int option [@default None][@key "type"];
-} [@@deriving sexp, yojson { strict = false}]
-
type t = {
id: Snowflake.t;
author: User_t.t;
diff --git a/lib/models/channel/message/message_t.mli b/lib/models/channel/message/message_t.mli
index 097a705..14086fe 100644
--- a/lib/models/channel/message/message_t.mli
+++ b/lib/models/channel/message/message_t.mli
@@ -1,26 +1,3 @@
-(** Represents data sent on {{!Dispatch.member_update}member update} events. *)
-type message_update = {
- id: Snowflake.t;
- author: User_t.t option;
- channel_id: Snowflake.t;
- member: Member_t.partial_member option;
- guild_id: Snowflake.t option;
- content: string option;
- timestamp: string option;
- editedimestamp: string option;
- tts: bool option;
- mention_everyone: bool option;
- mentions: Snowflake.t list;
- role_mentions: Snowflake.t list;
- attachments: Attachment.t list;
- embeds: Embed.t list;
- reactions: Snowflake.t list;
- nonce: Snowflake.t option;
- pinned: bool option;
- webhook_id: Snowflake.t option;
- kind: int option;
-} [@@deriving sexp, yojson]
-
(** Represents a message object. *)
type t = {
id: Snowflake.t;
diff --git a/lib/models/event_models.ml b/lib/models/event_models.ml
new file mode 100644
index 0000000..6df9762
--- /dev/null
+++ b/lib/models/event_models.ml
@@ -0,0 +1,347 @@
+open Core
+
+module ChannelCreate = struct
+ type t = {
+ channel: Channel_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module ChannelDelete = struct
+ type t = {
+ channel: Channel_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module ChannelUpdate = struct
+ type t = {
+ channel: Channel_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module ChannelPinsUpdate = struct
+ type t = {
+ channel_id: Channel_id_t.t;
+ last_pin_timestamp: string option;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module ChannelRecipientAdd = struct
+ type t = {
+ channel_id: Channel_id_t.t;
+ user: User_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module ChannelRecipientRemove = struct
+ type t = {
+ channel_id: Channel_id_t.t;
+ user: User_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module GuildBanAdd = struct
+ type t = {
+ guild_id: Guild_id_t.t;
+ user: User_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module GuildBanRemove = struct
+ type t = {
+ guild_id: Guild_id_t.t;
+ user: User_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module GuildCreate = struct
+ type t = {
+ guild: Guild_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+(* TODO *)
+module GuildDelete = struct
+ type t = {
+ foo: bool option [@default None];
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+(* TODO *)
+module GuildUpdate = struct
+ type t = {
+ foo: bool option [@default None];
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module GuildEmojisUpdate = struct
+ type t = {
+ emojis: Emoji.t list;
+ guild_id: Guild_id_t.t
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module GuildMemberAdd = struct
+ type t = {
+ guild_id: Guild_id_t.t;
+ member: Member_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module GuildMemberRemove = struct
+ type t = {
+ guild_id: Guild_id_t.t;
+ user: User_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module GuildMemberUpdate = struct
+ type t = {
+ guild_id: Guild_id_t.t;
+ nick: string option;
+ roles: Role_id.t list;
+ user: User_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module GuildMembersChunk = struct
+ type t = {
+ guild_id: Guild_id_t.t;
+ members: (Snowflake.t * Member_t.t) list;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module GuildRoleCreate = struct
+ type t = {
+ guild_id: Guild_id_t.t;
+ role: Role_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module GuildRoleDelete = struct
+ type t = {
+ guild_id: Guild_id_t.t;
+ role_id: Role_id.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module GuildRoleUpdate = struct
+ type t = {
+ guild_id: Guild_id_t.t;
+ role: Role_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module GuildUnavailable = struct
+ type t = {
+ guild_id: Guild_id_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module MessageCreate = struct
+ type t = {
+ message: Message_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module MessageDelete = struct
+ type t = {
+ channel_id: Channel_id_t.t;
+ message_id: Message_id.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module MessageUpdate = struct
+ type t = {
+ id: Snowflake.t;
+ author: User_t.t option [@default None];
+ channel_id: Snowflake.t;
+ member: Member_t.partial_member option [@default None];
+ guild_id: Snowflake.t option [@default None];
+ content: string option [@default None];
+ timestamp: string option [@default None];
+ editedimestamp: string option [@default None];
+ tts: bool option [@default None];
+ mention_everyone: bool option [@default None];
+ mentions: Snowflake.t list [@default []];
+ role_mentions: Snowflake.t list [@default []];
+ attachments: Attachment.t list [@default []];
+ embeds: Embed.t list [@default []];
+ reactions: Snowflake.t list [@default []];
+ nonce: Snowflake.t option [@default None];
+ pinned: bool option [@default None];
+ webhook_id: Snowflake.t option [@default None];
+ kind: int option [@default None][@key "type"];
+ } [@@deriving sexp, yojson { strict = false}]
+
+ let deserialize = of_yojson_exn
+end
+
+module MessageDeleteBulk = struct
+ type t = {
+ channel_id: Channel_id_t.t;
+ ids: Message_id.t list;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module PresenceUpdate = struct
+ type t = {
+ guild_id: Guild_id_t.t option;
+ presence: Presence.t;
+ roles: Role_id.t list option;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+(* module PresencesReplace = struct
+ type t =
+
+ let deserialize = of_yojson_exn
+end *)
+
+module ReactionAdd = struct
+ type t = {
+ reaction: Reaction_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module ReactionRemove = struct
+ type t = {
+ reaction: Reaction_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module ReactionRemoveAll = struct
+ type t = {
+ channel_id: Channel_id_t.t;
+ message_id: Message_id.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module Ready = struct
+ type t = {
+ foo: bool option [@default None];
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module Resumed = struct
+ type t = {
+ trace: string option list;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module TypingStart = struct
+ type t = {
+ channel_id: Channel_id_t.t;
+ timestamp: int;
+ user_id: User_id_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module UserUpdate = struct
+ type t = {
+ user: User_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module WebhookUpdate = struct
+ type t = {
+ channel_id: Channel_id_t.t;
+ guild_id: Guild_id_t.t;
+ } [@@deriving sexp, yojson]
+
+ let deserialize = of_yojson_exn
+end
+
+module Unknown = struct
+ type t = {
+ kind: string;
+ value: Yojson.Safe.json;
+ } [@@deriving yojson]
+
+ let deserialize kind value = { kind; value; }
+end
+
+(* module VoiceHeartbeat = struct
+
+end
+
+module VoiceHello = struct
+
+end
+
+module VoiceServerUpdate = struct
+
+end
+
+module VoiceSessionDescription = struct
+
+end
+
+module VoiceSpeaking = struct
+
+end
+
+module VoiceStateUpdate = struct
+
+end *) \ No newline at end of file
diff --git a/lib/models/id/message_id.ml b/lib/models/id/message_id.ml
new file mode 100644
index 0000000..377cadd
--- /dev/null
+++ b/lib/models/id/message_id.ml
@@ -0,0 +1,3 @@
+type t = [ `Message_id of Snowflake.t ] [@@deriving sexp, yojson]
+
+let get_id (`Message_id id) = id \ No newline at end of file
diff --git a/lib/models/id/message_id.mli b/lib/models/id/message_id.mli
new file mode 100644
index 0000000..da50f72
--- /dev/null
+++ b/lib/models/id/message_id.mli
@@ -0,0 +1,3 @@
+type t = [ `Message_id of Snowflake.t ] [@@deriving sexp, yojson]
+
+val get_id : t -> Snowflake.t \ No newline at end of file
diff --git a/lib/models/id/role_id.ml b/lib/models/id/role_id.ml
new file mode 100644
index 0000000..a505f33
--- /dev/null
+++ b/lib/models/id/role_id.ml
@@ -0,0 +1,3 @@
+type t = [ `Role_id of Snowflake.t ] [@@deriving sexp, yojson]
+
+let get_id (`Role_id id) = id \ No newline at end of file
diff --git a/lib/models/id/role_id.mli b/lib/models/id/role_id.mli
new file mode 100644
index 0000000..ededf3a
--- /dev/null
+++ b/lib/models/id/role_id.mli
@@ -0,0 +1,3 @@
+type t = [ `Role_id of Snowflake.t ] [@@deriving sexp, yojson]
+
+val get_id : t -> Snowflake.t \ No newline at end of file
diff --git a/lib/models/id/user_id.ml b/lib/models/id/user_id.ml
new file mode 100644
index 0000000..aba1b17
--- /dev/null
+++ b/lib/models/id/user_id.ml
@@ -0,0 +1 @@
+include Impl.User(User_id_t) \ No newline at end of file
diff --git a/lib/models/id/user_id.mli b/lib/models/id/user_id.mli
new file mode 100644
index 0000000..7fe822a
--- /dev/null
+++ b/lib/models/id/user_id.mli
@@ -0,0 +1,2 @@
+include S.UserImpl with
+ type t := User_id_t.t \ No newline at end of file
diff --git a/lib/models/id/user_id_t.ml b/lib/models/id/user_id_t.ml
new file mode 100644
index 0000000..8a6a265
--- /dev/null
+++ b/lib/models/id/user_id_t.ml
@@ -0,0 +1,3 @@
+type t = [ `User_id of Snowflake.t ] [@@deriving sexp, yojson]
+
+let get_id (`User_id id) = id \ No newline at end of file
diff --git a/lib/models/id/user_id_t.mli b/lib/models/id/user_id_t.mli
new file mode 100644
index 0000000..90211ab
--- /dev/null
+++ b/lib/models/id/user_id_t.mli
@@ -0,0 +1,3 @@
+type t = [ `User_id of Snowflake.t ] [@@deriving sexp, yojson]
+
+val get_id : t -> Snowflake.t \ No newline at end of file
diff --git a/lib/models/user/user.mli b/lib/models/user/user.mli
index 2cc6184..6e2c0f1 100644
--- a/lib/models/user/user.mli
+++ b/lib/models/user/user.mli
@@ -3,6 +3,4 @@ include module type of User_t
val tag : t -> string
val mention : t -> string
val default_avatar : t -> string
-val face : t -> string
-(* val private_channel : t -> Channel_t.t *)
-(* val send : t -> Yojson.Safe.json Deferred.Or_error.t *) \ No newline at end of file
+val face : t -> string \ No newline at end of file