diff options
| author | Adelyn Breedlove <[email protected]> | 2019-01-20 23:55:56 -0700 |
|---|---|---|
| committer | Adelyn Breedlove <[email protected]> | 2019-01-20 23:55:56 -0700 |
| commit | 916a7fe93cb43a127ae08d545f5fddf2a4ea74be (patch) | |
| tree | 4784cce76f45b4083364fb7a4f9968e879887780 /lib | |
| parent | Improve embed builders (diff) | |
| download | disml-916a7fe93cb43a127ae08d545f5fddf2a4ea74be.tar.xz disml-916a7fe93cb43a127ae08d545f5fddf2a4ea74be.zip | |
Add more interfaces
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/models/activity.mli | 5 | ||||
| -rw-r--r-- | lib/models/attachment.mli | 9 | ||||
| -rw-r--r-- | lib/models/embed.mli | 79 | ||||
| -rw-r--r-- | lib/models/emoji.mli | 14 | ||||
| -rw-r--r-- | lib/models/snowflake.ml | 13 | ||||
| -rw-r--r-- | lib/models/snowflake.mli | 13 |
6 files changed, 125 insertions, 8 deletions
diff --git a/lib/models/activity.mli b/lib/models/activity.mli new file mode 100644 index 0000000..53173b7 --- /dev/null +++ b/lib/models/activity.mli @@ -0,0 +1,5 @@ +type t = { + name: string; + kind: int; + url: string; +} [@@deriving sexp, yojson]
\ No newline at end of file diff --git a/lib/models/attachment.mli b/lib/models/attachment.mli new file mode 100644 index 0000000..2780011 --- /dev/null +++ b/lib/models/attachment.mli @@ -0,0 +1,9 @@ +type t = { + id: Snowflake.t; + filename: string; + size: int; + url: string; + proxy_url: string; + height: int; + width: int; +} [@@deriving sexp, yojson]
\ No newline at end of file diff --git a/lib/models/embed.mli b/lib/models/embed.mli new file mode 100644 index 0000000..d15c9fd --- /dev/null +++ b/lib/models/embed.mli @@ -0,0 +1,79 @@ +type footer = { + text: string; + icon_url: string option; + proxy_icon_url: string option; +} [@@deriving sexp, yojson] + +type image = { + url: string option; + proxy_url: string option; + height: int option; + width: int option; +} [@@deriving sexp, yojson] + +type video = { + url: string option; + height: int option; + width: int option; +} [@@deriving sexp, yojson] + +type provider = { + name: string option; + url: string option; +} [@@deriving sexp, yojson] + +type author = { + name: string option; + url: string option; + icon_url: string option; + proxy_icon_url: string option; +} [@@deriving sexp, yojson] + +type field = { + name: string; + value: string; + inline: bool; +} [@@deriving sexp, yojson] + +type t = { + title: string option; + kind: string option[@key "type"]; + description: string option; + url: string option; + timestamp: string option; + colour: int option[@key "color"]; + footer: footer option; + image: image option; + thumbnail: image option; + video: video option; + provider: provider option; + author: author option; + fields: field list [@default []]; +} [@@deriving sexp, yojson { strict = false }] + +val default : t +val default_footer : footer +val default_image : image +val default_video : video +val default_provider : provider +val default_author : author + +val title : string -> t -> t +val description : string -> t -> t +val url : string -> t -> t +val timestamp : string -> t -> t +val colour : int -> t -> t +val color : int -> t -> t +val footer : (footer -> footer) -> t -> t +val image : string -> t -> t +val thumbnail : string -> t -> t +val author : (author -> author) -> t -> t +val field : string * string * bool -> t -> t +val fields : (string * string * bool) list -> t -> t + +val footer_text : string -> footer -> footer +val footer_icon : string -> footer -> footer + +val author_name : string -> author -> author +val author_url : string -> author -> author +val author_icon : string -> author -> author
\ No newline at end of file diff --git a/lib/models/emoji.mli b/lib/models/emoji.mli new file mode 100644 index 0000000..4bbfc2a --- /dev/null +++ b/lib/models/emoji.mli @@ -0,0 +1,14 @@ +type partial_emoji = { + id: Snowflake.t option; + name: string; +} [@@deriving sexp, yojson] + +type t = { + id: Snowflake.t option; + name: string; + roles: Snowflake.t list; + user: User_t.t option; + require_colons: bool option; + managed: bool option; + animated: bool option; +} [@@deriving sexp, yojson]
\ No newline at end of file diff --git a/lib/models/snowflake.ml b/lib/models/snowflake.ml index 0122da8..4c87d63 100644 --- a/lib/models/snowflake.ml +++ b/lib/models/snowflake.ml @@ -10,13 +10,10 @@ let of_yojson d = let to_yojson s : Yojson.Safe.json = `String (Int.to_string s) -let timestamp snowflake = - let offset = (snowflake lsr 22) / 1000 in - 1_420_070_400 + offset +let timestamp snowflake = (snowflake lsr 22) + 1_420_070_400_000 let timestamp_iso snowflake = - let t = timestamp snowflake in - Date.( - of_time ~zone:Time.Zone.utc - Time.(of_span_since_epoch @@ Span.of_int_sec t) - |> format) "%FT%T+00:00"
\ No newline at end of file + let t = timestamp snowflake |> float_of_int in + Time.(Span.of_ms t + |> of_span_since_epoch + |> to_string_iso8601_basic ~zone:Zone.utc)
\ No newline at end of file diff --git a/lib/models/snowflake.mli b/lib/models/snowflake.mli new file mode 100644 index 0000000..5bbd1ff --- /dev/null +++ b/lib/models/snowflake.mli @@ -0,0 +1,13 @@ +open Core + +type t = Int.t [@@deriving sexp] + +val of_yojson_exn : Yojson.Safe.json -> t + +val of_yojson : Yojson.Safe.json -> t Ppx_deriving_yojson_runtime.error_or + +val to_yojson : t -> Yojson.Safe.json + +val timestamp : t -> int + +val timestamp_iso : t -> string
\ No newline at end of file |