aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAdelyn Breelove <[email protected]>2019-01-29 10:01:35 -0700
committerAdelyn Breelove <[email protected]>2019-01-29 10:01:35 -0700
commit16cba5acd05093c66ab1432b40d40605c1098407 (patch)
tree28adffb77476315809fe133993c243c036447dc4 /lib
parentRemove outdated docs (diff)
downloaddisml-16cba5acd05093c66ab1432b40d40605c1098407.tar.xz
disml-16cba5acd05093c66ab1432b40d40605c1098407.zip
Add client options
Diffstat (limited to 'lib')
-rw-r--r--lib/client.ml4
-rw-r--r--lib/client.mli10
-rw-r--r--lib/client_options.ml4
-rw-r--r--lib/client_options.mli4
-rw-r--r--lib/http.ml1
-rw-r--r--lib/impl.ml4
-rw-r--r--lib/s.ml1
-rw-r--r--lib/sharder.ml4
8 files changed, 23 insertions, 9 deletions
diff --git a/lib/client.ml b/lib/client.ml
index 9fac420..dd69910 100644
--- a/lib/client.ml
+++ b/lib/client.ml
@@ -6,8 +6,10 @@ type t = {
sharder: Sharder.t;
}
-let start ?count token =
+let start ?count ?(compress=false) ?(large=250) token =
Client_options.token := token;
+ Client_options.compress := compress;
+ Client_options.large_threshold := large;
Sharder.start ?count ()
>>| fun sharder ->
{ sharder; }
diff --git a/lib/client.mli b/lib/client.mli
index a05810b..7ece537 100644
--- a/lib/client.mli
+++ b/lib/client.mli
@@ -21,11 +21,13 @@ type t = {
let _ =
Scheduler.go_main ~main ()
]}
- @param ?count Optional amount of shards to launch. Defaults to autosharding
- @param string The token used for authentication
- @return A deferred client object
+ @param ?count Optional amount of shards to launch. Defaults to autosharding.
+ @param ?compress Whether to use compression over the gateway. {b NOT CURRENTLY SUPPORTED. DO NOT SET TO TRUE. }
+ @param ?large Large threshold for guilds. Default is 250.
+ @param string The token used for authentication.
+ @return A deferred client object.
*)
-val start : ?count:int -> string -> t Deferred.t
+val start : ?count:int -> ?compress:bool -> ?large:int -> string -> t Deferred.t
(** Same as {!Sharder.set_status} where [client.sharder] is passed. *)
val set_status : status:Yojson.Safe.json -> t -> Sharder.Shard.shard list Deferred.t
diff --git a/lib/client_options.ml b/lib/client_options.ml
index 0571fea..6a0d261 100644
--- a/lib/client_options.ml
+++ b/lib/client_options.ml
@@ -1 +1,3 @@
-let token = ref "" \ No newline at end of file
+let token = ref ""
+let large_threshold = ref 250
+let compress = ref false \ No newline at end of file
diff --git a/lib/client_options.mli b/lib/client_options.mli
index edf80e1..455ed58 100644
--- a/lib/client_options.mli
+++ b/lib/client_options.mli
@@ -1,2 +1,4 @@
(** Token that is set when using {!Client.start} *)
-val token : string ref \ No newline at end of file
+val token : string ref
+val large_threshold : int ref
+val compress : bool ref \ No newline at end of file
diff --git a/lib/http.ml b/lib/http.ml
index 9a47c65..5e49843 100644
--- a/lib/http.ml
+++ b/lib/http.ml
@@ -23,6 +23,7 @@ module Base = struct
"User-Agent", "Dis.ml v0.1.0";
"Authorization", ("Bot " ^ !Client_options.token);
"Content-Type", "application/json";
+ "Connection", "keep-alive";
]
let process_response path ((resp:Response.t), body) =
diff --git a/lib/impl.ml b/lib/impl.ml
index 5fd7680..ae092d3 100644
--- a/lib/impl.ml
+++ b/lib/impl.ml
@@ -50,6 +50,10 @@ module Channel(T : S.HasSnowflake) : S.ChannelImpl with type t := T.t = struct
let get_pins ch =
Http.get_pinned_messages (get_id ch)
+
+ let bulk_delete msgs ch =
+ let msgs = `List (List.map ~f:(fun id -> `Int id) msgs) in
+ Http.bulk_delete (get_id ch) msgs
end
module Guild(T : S.HasSnowflake) : S.GuildImpl with type t := T.t = struct
diff --git a/lib/s.ml b/lib/s.ml
index 05eee18..2bd2703 100644
--- a/lib/s.ml
+++ b/lib/s.ml
@@ -48,6 +48,7 @@ module type ChannelImpl = sig
Message_t.t list Deferred.Or_error.t
val broadcast_typing : t -> unit Deferred.Or_error.t
val get_pins : t -> Message_t.t list Deferred.Or_error.t
+ val bulk_delete : Snowflake.t list -> t -> unit Deferred.Or_error.t
(* TODO more things related to guild channels *)
end
diff --git a/lib/sharder.ml b/lib/sharder.ml
index f98ee8f..65d137e 100644
--- a/lib/sharder.ml
+++ b/lib/sharder.ml
@@ -127,8 +127,8 @@ module Shard = struct
("$device", `String "dis.ml");
("$browser", `String "dis.ml")
]);
- ("compress", `Bool false); (* TODO add compression handling*)
- ("large_threshold", `Int 250);
+ ("compress", `Bool !Client_options.compress); (* TODO add compression handling*)
+ ("large_threshold", `Int !Client_options.large_threshold);
("shard", `List shards);
] in
push_frame ~payload ~ev:IDENTIFY shard