oper module
This commit is contained in:
parent
a2e649bb34
commit
e9130b3cd2
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
tup
|
||||
lua5.3 -l set_paths ./src/ketracel.lua
|
||||
cd src
|
||||
lua5.3 -l set_paths ketracel.lua
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
-- 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
|
|
@ -0,0 +1,3 @@
|
|||
include_rules
|
||||
.gitignore
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
irce = require "irce"
|
||||
util = require "irce.util"
|
||||
|
||||
{
|
||||
init: (state) =>
|
||||
state.nick = ""
|
||||
|
||||
senders:
|
||||
["OPER"]: (state, nick, pass) =>
|
||||
state.nick = nick
|
||||
return string.format "OPER %s %s", nick, pass
|
||||
|
||||
handlers:
|
||||
["381"]: (state, sender, params) =>
|
||||
print string.format "granted ircop status by %s as oper %s", sender[1], state.nick
|
||||
state.nick = nil
|
||||
return sender, params
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
irce = require "irce"
|
||||
socket = require "socket"
|
||||
print irce._VERSION .. " running on " .. _VERSION
|
||||
|
||||
config =
|
||||
server: "127.0.0.1"
|
||||
|
@ -9,21 +8,27 @@ config =
|
|||
real: os.getenv("IRC_REAL") or "The favorite of the Jem'Hadar"
|
||||
oper: os.getenv("IRC_OPER")
|
||||
channels: { "#ketracel", "#opers" }
|
||||
debug: os.getenv("KETRACEL_DEBUG")
|
||||
|
||||
irc = irce.new!
|
||||
running = true
|
||||
|
||||
-- load IRC modules
|
||||
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"
|
||||
assert irc\load_module require "irce.modules.oper"
|
||||
|
||||
client = socket.tcp!
|
||||
irc\set_send_func (message) =>
|
||||
client\send message
|
||||
client\settimeout 1
|
||||
|
||||
irc\set_callback irce.RAW, (send, message) =>
|
||||
-- irc engine callbacks
|
||||
irc\set_send_func (message) =>
|
||||
client\send message
|
||||
|
||||
if config.debug
|
||||
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) =>
|
||||
|
@ -39,13 +44,17 @@ irc\set_callback "PRIVMSG", (sender, origin, message, pm) =>
|
|||
assert self\QUIT "Ran out of white"
|
||||
running = false
|
||||
|
||||
-- connect to irc server
|
||||
assert client\connect config.server, 6667
|
||||
|
||||
assert irc\NICK config.nick
|
||||
assert irc\USER config.user, config.real
|
||||
|
||||
print "Ketracel loaded using " .. irce._VERSION .. " running on " .. _VERSION
|
||||
|
||||
if config.oper
|
||||
client\send "OPER " .. config.nick .. " " .. config.oper .. "\r\n"
|
||||
irc\OPER config.nick, config.oper
|
||||
print "IRC operator status requested for " .. config.nick
|
||||
|
||||
while running
|
||||
irc\process client\receive!
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue