{"id":16613119,"url":"https://github.com/c-cube/calculon","last_synced_at":"2025-03-21T14:31:15.534Z","repository":{"id":41203265,"uuid":"79588649","full_name":"c-cube/calculon","owner":"c-cube","description":"Library for writing IRC bots in OCaml, a collection of plugins, and a dramatic robotic actor.","archived":false,"fork":false,"pushed_at":"2024-01-20T03:08:41.000Z","size":1320,"stargazers_count":28,"open_issues_count":8,"forks_count":5,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-16T00:14:43.183Z","etag":null,"topics":["futurama","irc","irc-bot","lwt","ocaml","pluggable"],"latest_commit_sha":null,"homepage":"https://c-cube.github.io/calculon/","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/c-cube.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-20T19:03:15.000Z","updated_at":"2022-08-12T00:45:53.000Z","dependencies_parsed_at":"2024-10-28T10:30:06.184Z","dependency_job_id":null,"html_url":"https://github.com/c-cube/calculon","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-cube%2Fcalculon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-cube%2Fcalculon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-cube%2Fcalculon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-cube%2Fcalculon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c-cube","download_url":"https://codeload.github.com/c-cube/calculon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244815148,"owners_count":20514900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["futurama","irc","irc-bot","lwt","ocaml","pluggable"],"created_at":"2024-10-12T01:46:01.849Z","updated_at":"2025-03-21T14:31:15.060Z","avatar_url":"https://github.com/c-cube.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Calculon [![build](https://github.com/c-cube/calculon/actions/workflows/main.yml/badge.svg)](https://github.com/c-cube/calculon/actions/workflows/main.yml)\n\nLibrary for writing IRC bots in OCaml, a collection of plugins, and a dramatic robotic actor.\nThe core library is called `calculon`.\n\n![calculon logo](https://raw.github.com/c-cube/calculon/master/media/calculon.jpg)\n\n## Build\n\n```\nmake build\n```\n\n## Introduction to the Code\n\nLet's assume calculon is loaded, via:\n\n```ocaml\n# #require \"calculon\";;\n```\n\n### Main\n\nThe typical `main` entry point would look like  this.\nCalculon works by gathering a list of\n*plugins* (see the module `Plugin`), some configuration (see `Config`)\nand running the package in a loop using [irc-client](https://github.com/johnelse/ocaml-irc-client/).\n\n```ocaml non-deterministic=command\n\nmodule C = Calculon\n\nlet plugins : C.Plugin.t list = [\n  C.Plugin_social.plugin;\n  C.Plugin_factoids.plugin;\n  (* etc. *)\n]\n\nlet () =\n  let conf = C.Config.of_argv () in\n  C.Run_main.main conf plugins |\u003e Lwt_main.run\n\n```\n\n### Plugins\n\nA plugin contains a set of *commands*.\nA command is is a rule that matches a IRC message with some regex, and decides\nwhether or not to fire with a reply. They are defined in the module `Command`.\n\nFor instance, the following module will reply to messages\nstarting with `!hello` by replying `\"hello \u003csender\u003e\"`. This is a simple\ncommand, as the function `Command.make_simple` indicates: it returns a `string\noption` to indicate whether or not to respond to any line starting with\n`!prefix`. More elaborate commands are possible using `Command.make`.\n\n```ocaml\n\nopen Calculon\n\nlet cmd_hello : Command.t =\n  Command.make_simple ~descr:\"hello world\" ~cmd:\"hello\" ~prio:10\n    (fun (input_msg:Core.privmsg) _ -\u003e\n       let who = input_msg.Core.nick in\n       Lwt.return (Some (\"hello \" ^ who))\n    )\n\nlet plugin_hello : Plugin.t = Plugin.of_cmd cmd_hello\n```\n\nBasic plugins are stateless, built from one or more commands with `Plugin.of_cmd`\nand `Plugin.of_cmds`.\nOther plugins can be stateful (typically, they can have some persistent\nstate, or more \"custom\" schemes).\nThe constructor `Plugin.stateful` is used to make such plugins.\nAll the persistent state is stored in a single json file.\n\nSee for instance the existing plugins `Plugin_factoids` and `Plugin_movie`\nto see how to use `Plugin.stateful`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-cube%2Fcalculon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc-cube%2Fcalculon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-cube%2Fcalculon/lists"}