first commit

This commit is contained in:
Cadey Ratio 2019-12-24 15:29:08 +00:00
commit a2e649bb34
8 changed files with 106 additions and 0 deletions

12
LICENSE Normal file
View File

@ -0,0 +1,12 @@
Copyright (c) 2019 Christine Dodrill <me@christine.website>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

2
Tupfile Normal file
View File

@ -0,0 +1,2 @@
include_rules
.gitignore

1
Tuprules.tup Normal file
View File

@ -0,0 +1 @@
: foreach *.moon |> ^ Moon: %f -> %o^ moonc %f 2> /dev/null |> %B.lua

27
ketracel-scm-1.rockspec Normal file
View File

@ -0,0 +1,27 @@
package = "ketracel"
version = "scm-1"
source = {
url = "https://tulpa.dev/cadey/ketracel"
}
description = {
homepage = "https://tulpa.dev/cadey/ketracel",
license = "0bsd",
summary = "a small security bot for ngircd",
labels = {
"irc",
"security"
}
}
dependencies = {
"lua ~> 5.3",
"irc-engine",
"luasocket",
}
build_dependencies = {
"moonscript",
"busted",
}
build = {
type = "builtin",
modules = {}
}

4
scripts/run.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
tup
lua5.3 -l set_paths ./src/ketracel.lua

4
set_paths.lua Normal file
View File

@ -0,0 +1,4 @@
-- set_paths.lua
local version = _VERSION:match("%d+%.%d+")
package.path = 'lua_modules/share/lua/' .. version .. '/?.lua;lua_modules/share/lua/' .. version .. '/?/init.lua;' .. package.path
package.cpath = 'lua_modules/lib/lua/' .. version .. '/?.so;' .. package.cpath

3
src/Tupfile Normal file
View File

@ -0,0 +1,3 @@
include_rules
.gitignore

53
src/ketracel.moon Normal file
View File

@ -0,0 +1,53 @@
irce = require "irce"
socket = require "socket"
print irce._VERSION .. " running on " .. _VERSION
config =
server: "127.0.0.1"
nick: os.getenv("IRC_NICK") or "Ketracel"
user: os.getenv("IRC_USER") or "white"
real: os.getenv("IRC_REAL") or "The favorite of the Jem'Hadar"
oper: os.getenv("IRC_OPER")
channels: { "#ketracel", "#opers" }
irc = irce.new!
running = true
assert irc\load_module require "irce.modules.base"
assert irc\load_module require "irce.modules.message"
assert irc\load_module require "irce.modules.channel"
assert irc\load_module require "irce.modules.motd"
client = socket.tcp!
irc\set_send_func (message) =>
client\send message
client\settimeout 1
irc\set_callback irce.RAW, (send, message) =>
print string.format "%s %s", (send and ">" or "<"), message
irc\set_callback "CTCP", (sender, origin, command, params, pm) =>
if command == "VERSION"
self\CTCP_REPLY origin, "VERSION", string.format("Ketracel white - dev (%s, %s)", irce._VERSION, _VERSION)
irc\set_callback "001", (...) =>
for k, chan in ipairs config.channels
assert irc\JOIN chan
irc\set_callback "PRIVMSG", (sender, origin, message, pm) =>
if message == "?quit"
assert self\QUIT "Ran out of white"
running = false
assert client\connect config.server, 6667
assert irc\NICK config.nick
assert irc\USER config.user, config.real
if config.oper
client\send "OPER " .. config.nick .. " " .. config.oper .. "\r\n"
while running
irc\process client\receive!
client\close!