aboutsummaryrefslogtreecommitdiff
path: root/bin/bot.ml
diff options
context:
space:
mode:
authorAdelyn Breelove <[email protected]>2019-01-17 12:13:27 -0700
committerAdelyn Breelove <[email protected]>2019-01-17 12:13:27 -0700
commite0cd2c4b63e07300607dbfb6f4863b473359241c (patch)
tree6b9a2122b66f2893c2e2a4e5cf119b0e84c57595 /bin/bot.ml
parentMake the example bot cleaner (diff)
downloaddisml-0.2.0.tar.xz
disml-0.2.0.zip
more improvements to test bot, fix message module0.2.0
Diffstat (limited to 'bin/bot.ml')
-rw-r--r--bin/bot.ml6
1 files changed, 5 insertions, 1 deletions
diff --git a/bin/bot.ml b/bin/bot.ml
index 197efb4..a42fd16 100644
--- a/bin/bot.ml
+++ b/bin/bot.ml
@@ -8,7 +8,11 @@ let check_command (msg:Message.t) =
| [] -> "", []
in match cmd with
| "!ping" ->
- Message.reply msg "Pong!" >>> ignore
+ Message.reply msg "Pong!" >>= begin fun msg ->
+ let msg = match msg with Ok m -> m | Error e -> Error.raise e in
+ let diff = Time.diff (Time.now ()) (Time.of_string msg.timestamp) in
+ Message.set_content msg (Printf.sprintf "Pong! `%d ms`" (Time.Span.to_ms diff |> Float.to_int))
+ end >>> ignore
| "spam" ->
let count = Option.((List.hd rest >>| Int.of_string) |> value ~default:0) in
List.range 0 count