Add IRC connection functionality

Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
This commit is contained in:
Sebastian Crane 2022-02-19 22:32:43 +00:00
parent fe660a8929
commit aacf1cad28
1 changed files with 23 additions and 0 deletions

23
src/irc.clj Normal file
View File

@ -0,0 +1,23 @@
;; SPDX-License-Identifier: Apache-2.0
;; SPDX-FileCopyrightText: 2022 Sebastian Crane <seabass-labrax@gmx.com>
(ns irc
(:require [bot :refer :all]
[irclj.core]))
(defn irc-callback [state config connection type & m]
(let [{:keys [channel]} (:irc config)
{:keys [nick text target]} type]
(irclj.core/message connection channel
(when (= target channel)
(dispatch-command state nick text)))))
(defn new-irc-connection [state config]
(let [{:keys [server port name nick channel]} (:irc config)]
(try
(irclj.core/connect server
port
nick
:real-name name
:callbacks {:privmsg (partial irc-callback state config)})
(catch Exception e nil))))