| File | Date | Author | Commit |
|---|---|---|---|
| example | 2020-01-31 |
|
[2cb3c8] State tracker module |
| src | 2020-02-02 |
|
[6a175f] Separate client module from `dithcord-tui` |
| .hgignore | 2020-01-22 |
|
[b871a0] Make a module for modules |
| .travis.yml | 2020-01-11 |
|
[a19f0b] Commands module |
| README.md | 2020-01-23 |
|
[de79b0] Update readme |
| TODO | 2020-02-02 |
|
[6a175f] Separate client module from `dithcord-tui` |
| dithcord.asd | 2020-02-02 |
|
[6a175f] Separate client module from `dithcord-tui` |
Dithcord is a library for making modular Discord bots. It's mainly developed
for dithcord-tui and dithcord-gui but
it's absolutely usable for any kind of bot.
The main difference is that Lispcord
supports running several monolithic bots in the same lisp-system while Dithcord
supports running a single modular bot. If either suits you then you should
probably pick Lispcord to avoid an extra layer you don't need. Dithcord is not
a complete abstraction and you'll have to use Lispcord functions anyway.
Also, Lispcord is more imperative while Dithcord is more declarative with all
the define-stuff macros.
Well, both Dithcord and Lispcord have lots of it.
Since the current code is in such a state that it probably shouldn't have been
published yet this section contains very little.
More are in the examples directory.
(in-package dithcord-user)
;; Define a bot named ECHO-BOT with one module ECHO
;; Modules are not loaded until the bot is started
(define-bot echo-bot (echo)
;; Parameters are evaluated. You can load it from a config file e.g.
:token "")
;; Define a module ECHO with no dependencies.
;; Lispcord is always available without any modules.
(define-module echo ())
;; Define a handler for event :ON-MODULE-LOAD handled by the module ECHO.
;; Dithcord has some special events and the rest (like :on-message-create) are the same as Lispcord's
(define-handler echo :on-module-load ()
(v:info :echo-bot "ECHO loaded!"))
;; Define another handler for :ON-MESSAGE-CREATE
(define-handler echo :on-message-create (msg)
;; This code is from Lispcord's example
(unless (lc:botp (lc:author msg))
(let ((cmd (string-trim " " (lispcord:remove-mention (lispcord:me) (lc:content msg)))))
(when (eql 0 (search "echo!" cmd))
(lispcord:reply msg (subseq cmd 6))))))
;; Start the bot
(start-bot 'echo-bot)
:on-module-load - Called when the module is loaded into the bot after the
module's dependencies are loaded. The connection may not exist. Use :on-ready
to do stuff when re/connected.
:on-module-unload - Called when the module is unloaded from a bot, either
because the bot is redefined without this module or because the bot is being
stopped.