clckwrks-plugin-ircbot 0.3.2 → 0.5.4
raw patch · 3 files changed
+35/−21 lines, 3 filesdep ~blaze-htmldep ~clckwrks
Dependency ranges changed: blaze-html, clckwrks
Files
- Clckwrks/IrcBot/Page/IrcLogs.hs +6/−2
- Clckwrks/IrcBot/Plugin.hs +26/−16
- clckwrks-plugin-ircbot.cabal +3/−3
Clckwrks/IrcBot/Page/IrcLogs.hs view
@@ -21,6 +21,10 @@ urls <- mapM (showURL . IrcLog) logFiles let logs = zip urls logFiles template "irc logs" ()- <ul>+ <%>+ <h1>IRC Logs</h1>+ <ul> <% mapM (\(url, logFile) -> <li><a href=url><% logFile %></a></li>) logs %>- </ul>+ </ul>+ </%>+
Clckwrks/IrcBot/Plugin.hs view
@@ -2,6 +2,7 @@ module Clckwrks.IrcBot.Plugin where import Clckwrks+import Clckwrks.Monad (ClckPluginsSt) import Clckwrks.Plugin (clckPlugin) import Clckwrks.IrcBot.URL (IrcBotURL(..), IrcBotAdminURL(..)) import Clckwrks.IrcBot.Acid (GetIrcConfig(..), initialIrcBotState)@@ -16,6 +17,7 @@ import qualified Data.Text.Lazy as TL import Data.Maybe (fromMaybe) import Data.Set (Set)+import qualified Data.Set as Set import Network (PortID(PortNumber)) import Network.IRC.Bot.BotMonad (BotMonad(..)) import Network.IRC.Bot.Core as IRC (BotConf(..), User(..), nullBotConf, simpleBot)@@ -63,27 +65,35 @@ -- addPreProc plugins (ircBotCmd ircBotShowFn) addHandler plugins (pluginName ircBotPlugin) (ircBotHandler ircBotShowFn ircBotConfig)+ addNavBarCallback plugins (ircBotNavBarCallback ircBotShowFn) return Nothing +ircBotNavBarCallback :: (IrcBotURL -> [(Text, Maybe Text)] -> Text)+ -> ClckT ClckURL IO (String, [NamedLink])+ircBotNavBarCallback ircBotShowURL =+ return ("Irc Bot", [(NamedLink "IRC logs" (ircBotShowURL IrcLogs []))])+ botConnect :: Plugins theme n hook config st -> Acid.AcidState (Acid.EventState GetIrcConfig) -> FilePath -> IO (IO ()) botConnect plugins ircBot ircBotLogDir = do ic@IrcConfig{..} <- Acid.query ircBot GetIrcConfig- let botConf = nullBotConf { channelLogger = Just $ posixLogger (Just ircBotLogDir) "#happs"- , IRC.host = ircHost- , IRC.port = PortNumber $ fromIntegral ircPort- , nick = ircNick- , commandPrefix = ircCommandPrefix- , user = ircUser- , channels = ircChannels- , limits = Just (5, 2000000)- }- ircParts <- initParts (channels botConf)- (tids, reconnect) <- simpleBot botConf ircParts- addCleanup plugins Always (mapM_ killThread tids)- return reconnect+ if ircEnabled+ then do let botConf = nullBotConf { channelLogger = Just $ posixLogger (Just ircBotLogDir) "#happs"+ , IRC.host = ircHost+ , IRC.port = PortNumber $ fromIntegral ircPort+ , nick = ircNick+ , commandPrefix = ircCommandPrefix+ , user = ircUser+ , channels = ircChannels+ , limits = Just (5, 2000000)+ }+ ircParts <- initParts (channels botConf)+ (tids, reconnect) <- simpleBot botConf ircParts+ addCleanup plugins Always (mapM_ killThread tids)+ return reconnect+ else return (return ()) initParts :: (BotMonad m) => Set String -- ^ set of channels to join@@ -103,11 +113,11 @@ (Just showIrcBotURL) <- getPluginRouteFn p (pluginName ircBotPlugin) let reconnectURL = showIrcBotURL (IrcBotAdmin IrcBotReconnect) [] settingsURL = showIrcBotURL (IrcBotAdmin IrcBotSettings) []- addAdminMenu ("IrcBot", [ ("Reconnect", reconnectURL)- , ("Settings", settingsURL)+ addAdminMenu ("IrcBot", [ (Set.fromList [Administrator, Editor], "Reconnect", reconnectURL)+ , (Set.fromList [Administrator, Editor], "Settings" , settingsURL) ]) -ircBotPlugin :: Plugin IrcBotURL Theme (ClckT ClckURL (ServerPartT IO) Response) (ClckT ClckURL IO ()) ClckwrksConfig [TL.Text -> ClckT ClckURL IO TL.Text]+ircBotPlugin :: Plugin IrcBotURL Theme (ClckT ClckURL (ServerPartT IO) Response) (ClckT ClckURL IO ()) ClckwrksConfig ClckPluginsSt ircBotPlugin = Plugin { pluginName = "ircBot" , pluginInit = ircBotInit
clckwrks-plugin-ircbot.cabal view
@@ -1,5 +1,5 @@ Name: clckwrks-plugin-ircbot-Version: 0.3.2+Version: 0.5.4 Synopsis: ircbot plugin for clckwrks Homepage: http://clckwrks.com/ License: BSD3@@ -42,8 +42,8 @@ base < 5, acid-state >= 0.7, attoparsec == 0.10.*,- blaze-html == 0.5.*,- clckwrks >= 0.13 && < 0.15,+ blaze-html >= 0.5 && < 0.7,+ clckwrks >= 0.16 && < 0.17, containers >= 0.4 && < 0.6, directory >= 1.1 && < 1.3, filepath >= 1.2 && < 1.4,