~technomancy/taverner

403c191fd964d94601945f033cfefc203a8befe8 — Phil Hagelberg 2 months ago 8a28bcd
Support join/part across with multiple channels at once.
2 files changed, 10 insertions(+), 11 deletions(-)

M Makefile
M commands.fnl
M Makefile => Makefile +2 -2
@@ 1,7 1,7 @@
CORE_SRC=$(wildcard *.fnl)
run: ; ./fennel bin/taverner

dev: ; PLUGINS=bot PORT=6668 luajit -lluarocks.loader ./fennel bin/taverner
dev: ; PLUGINS=bot PORT=6668 ./fennel bin/taverner

# just playing with this for now
lint: ; ./fennel --plugin ../fennel/src/linter.fnl \


@@ 9,4 9,4 @@ lint: ; ./fennel --plugin ../fennel/src/linter.fnl \

count: ;
	cloc $(CORE_SRC) bin/taverner
	cloc bots
	cloc bot

M commands.fnl => commands.fnl +8 -9
@@ 78,10 78,9 @@
            (state:send cstate :404 ":Cannot send (+m)"))))
  (call-with-channel state cstate channel-name f))

(fn msg-user [state cstate to command-name msg]
(fn msg-user [state cstate to cmd msg]
  (fn f [{: conn}]
    (conn:send (.. ":" cstate.nick " " command-name " " cstate.nick
                   " :" msg "\r\n")))
    (conn:send (.. ":" cstate.nick " " cmd " " cstate.nick " :" msg "\r\n")))
  (call-with-user state cstate to f))

(fn PRIVMSG [state cstate to msg]


@@ 130,6 129,8 @@
  (state:send cstate :PONG token))

(fn LIST [state cstate]
  ;; 321 is supposed to be optional but some clients don't work without it.
  (state:send cstate :321 "Channel :Users Name")
  (each [_ ch (pairs state.channels)]
    (when (or (not (ch.mode :s)) (ch.member? cstate.nick))
      (state:send cstate :322 ch.name


@@ 180,15 181,13 @@
(fn REHASH [state cstate ?what]
  (state:send cstate :382 :clients (tostring (lume.count state.clients nil))
              :uptime (- (os.time) state.start-time))
  (if (= ?what :channel) (do (lume.hotswap :channel) ; special case for channel
                             (each [_ ch (pairs state.channels)]
                               (ch:upgrade channel.make)))
  (if (= ?what :channels) (do (lume.hotswap :channel)
                              (each [_ ch (pairs state.channels)]
                                (ch:upgrade channel.make))
                              (state:send cstate :382 :Reloaded))
      (. package.loaded ?what) (match (pcall lume.hotswap ?what)
                                 true (state:send cstate :382 :Reloaded ?what)
                                 (_ msg) (state:send cstate :400 ":" msg))
      (= ?what :channels) (each [_ ch (pairs state.channels)]
                            (ch:upgrade channel.make)
                            (state:send cstate :382 :Reloaded ch.name))
      (= ?what :bots) (each [_ client (pairs state.clients)]
                        (when client.conn.upgrade
                          (client.conn:upgrade)