Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Luminarys/Kaguya
A small, powerful, and modular IRC bot
https://github.com/Luminarys/Kaguya
irc irc-bot
Last synced: 2 months ago
JSON representation
A small, powerful, and modular IRC bot
- Host: GitHub
- URL: https://github.com/Luminarys/Kaguya
- Owner: Luminarys
- License: isc
- Created: 2015-12-10T03:28:58.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2020-02-06T06:27:02.000Z (almost 5 years ago)
- Last Synced: 2024-10-30T16:56:15.443Z (2 months ago)
- Topics: irc, irc-bot
- Language: Elixir
- Size: 114 KB
- Stars: 74
- Watchers: 6
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - A small, powerful, and modular IRC bot. (Chatting)
- fucking-awesome-elixir - kaguya - A small, powerful, and modular IRC bot. (Chatting)
- awesome-elixir - kaguya - A small, powerful, and modular IRC bot. (Chatting)
README
# Kaguya
**A small but powerful IRC bot**
## Installation
1. Add kaguya to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:kaguya, "~> x.y.z"}]
end
```2. Run `mix deps.get`
3. Ensure kaguya is started before your application:
```elixir
def application do
[applications: [:kaguya]]
end
```4. Configure kaguya in config.exs:
```elixir
config :kaguya,
server: "my.irc.server",
port: 6666,
bot_name: "kaguya",
channels: ["#kaguya"]
```## Usage
By default Kaguya won't do much. This is an example of a module which will
perform a few simple commands:
```elixir
defmodule Kaguya.Module.Simple do
use Kaguya.Module, "simple"handle "PRIVMSG" do
match ["!ping", "!p"], :pingHandler
match "hi", :hiHandler
match "!say ~message", :sayHandler
enddefh pingHandler, do: reply "pong!"
defh hiHandler(%{user: %{nick: nick}}), do: reply "hi #{nick}!"
defh sayHandler(%{"message" => response}), do: reply response
end
```This module defines four commands to be handled:
* `!ping` and `!p` are aliased to the same handler, which has the bot respond `pong!`.
* `hi` will cause the bot to reply saying "hi" with the persons' nick
* `!say [some message]` will have the bot echo the message the user gave.The handler macro can accept up to two different parameters, a map which destructures a message struct, and a map which destructures a match from a command.
You can find a more full featured example in `example/basic.ex`.
## Configuration
* `server` - Hostname or IP address to connect with. String.
* `server_ip_type` - IP version to use. Can be either `inet` or `inet6`
* `port` - Port to connect on. Integer.
* `bot_name` - Name to use by bot. String.
* `channels` - List of channels to join. Format: `#`. List
* `help_cmd` - Specifies command to act as help. Defaults to `.help`. String
* `use_ssl` - Specifies whether to use SSL or not. Boolean
* `reconnect_interval` - Interval for reconnection in ms. Integer. Not used.
* `server_timeout` - Timeout(ms) that determines when server gets disconnected. Integer.
When omitted Kaguya does not verifies connectivity with server.
It is recommended to set at least few minutes.