package calculon
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=d536856761b0305cad7dc77cfca163095bc45455b192b2bf7cae5ce6d8eea733
sha512=44a30e453b5e0f1699d36f09b2eacf696cab03a5aa72f0c8d3c5444f0949fdb05618629636344f04b783732e20fad0120ac4c14549b26c6c47001a493f12026e
Description
README
Calculon 
Library for writing IRC bots in OCaml, a collection of plugins, and a dramatic robotic actor. The core library is called calculon.

Build
make buildIntroduction to the Code
Let's assume calculon is loaded, via:
# #require "calculon";;Main
The typical main entry point would look like this. Calculon works by gathering a list of plugins (see the module Plugin), some configuration (see Config) and running the package in a loop using irky with the Eio runtime.
module C = Calculon
let plugins : C.Plugin.t list = [
C.Plugin_social.plugin;
C.Plugin_factoids.plugin;
(* etc. *)
]
let () =
let conf = C.Config.of_argv () in
Eio_main.run @@ fun env ->
Eio.Switch.run @@ fun sw ->
let net = Eio.Stdenv.net env in
let clock = Eio.Stdenv.clock env in
C.Run_main.main ~sw ~net ~clock conf pluginsPlugins
A plugin contains a set of commands. A command is is a rule that matches a IRC message with some regex, and decides whether or not to fire with a reply. They are defined in the module Command.
For instance, the following module will reply to messages starting with !hello by replying "hello <sender>". This is a simple command, as the function Command.make_simple indicates: it returns a string option to indicate whether or not to respond to any line starting with !prefix. More elaborate commands are possible using Command.make.
open Calculon
let cmd_hello : Command.t =
Command.make_simple ~descr:"hello world" ~cmd:"hello" ~prio:10
(fun (input_msg:Core.privmsg) _ ->
let who = input_msg.Core.nick in
Some ("hello " ^ who)
)
let plugin_hello : Plugin.t = Plugin.of_cmd cmd_helloBasic plugins are stateless, built from one or more commands with Plugin.of_cmd and Plugin.of_cmds. Other plugins can be stateful (typically, they can have some persistent state, or more "custom" schemes). The constructor Plugin.stateful is used to make such plugins. All the persistent state is stored in a single json file.
See for instance the existing plugins Plugin_factoids and Plugin_movie to see how to use Plugin.stateful.
Dependencies (17)
Dev Dependencies (1)
-
odoc
with-doc
Optional Dependencies (1)
Used by (1)
-
calculon-web
>= "0.9"
Conflicts
None
Build status
Results of building calculon with each compiler on check.ci.ocaml.org, run of against opam-repository 8d8d144. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 0.9 (this version) | n/a | n/a | good | good | good |
| 0.8 | good | good | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure