io.randomseed.utils.bot

added in 1.0.0

Random utils, bot abstraction.

bot-ns

(bot-ns v id)

bot?

(bot? v)

command

(command wrk command & args)

current-ns-str

generic-control

(generic-control bot-session f wrk req handler-args)

Common tasks which any bot should support.

generic-data-handler

(generic-data-handler data bot-session)

Handles additional data which are a result of a request. It’s like side effect for the request, regardless of its reply. When session object is returned then bot-specific data handlers should not interfere (processing is done) and just replace session with the returned one. When nil is returned then bot-specific data handlers should exit the loop and finish execution. All other data is passed as is.

get-config

(get-config wrk)

get-data

(get-data wrk k & args)

get-data!

(get-data! wrk k & args)

get-session

(get-session wrk)

handle-request

(handle-request bot-session f data-handler wrk req & handler-args)

Handles requests. Returns an Outcome object. Passes control to a chosen request handler f to prepare the response. Updates the returned map with data-handler if data is present in the outcome.

instance-config

(instance-config cfg instance-id)

Creates an instance of a configuration for the given instance (if a bot is instantiable).

load

(load config-parser id)(load config-parser id instance-id)

load-config

(load-config cfg-parser bot-id)(load-config cfg-parser config-file bot-id)

parse-config

(parse-config cfg)(parse-config cfg instance-id)

pause

(pause wrk)

ping

(ping wrk)

run!

(run! wrk)(run! bot-session cfg)(run! bot-session cfg instance)

Runs a bot by creating a worker thread with communication channels. After bot is successfully created it queries it for its updated configuration and replaces a local one with it.

stop!

(stop! wrk)

update-local-config!

(update-local-config! wid)