-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell scripting interface for HexChat -- -- This package builds a shared object ready for loading into HexChat, -- that will compile and interpret scripts written in Haskell; and also a -- Haskell library that said scripts should import and use to interface -- with HexChat. -- -- At the moment the scripting interface is not finalized and may (and -- will) change in a future. -- -- At the moment only Linux is supported. -- -- For instructions on how to write a script, see the HexChat -- module. -- -- The plugin understands the classic /load, /unload, -- /reload commands, as well as: -- --
--   /hs load <filename>
--   /hs unload <filename>
--   /hs reload <filename>
--   /hs list
--   
-- -- To automatically load the plugin symlink or copy -- ~/.cabal/lib/libhexchat-haskell.so (or -- /usr/local/lib/libhexchat-haskell.so) to -- ~/.config/hexchat/addons/ (or -- /usr/lib/hexchat/plugins/). @package hexchat @version 0.0.2.0 -- | This module contains the "raw" functions that leak the fact that all -- Haskell scripts are actually executed under the same -- hexchat_plugin structure. You should unhook everything you -- have hooked. module HexChat.Internal pri_HIGHEST :: CInt pri_HIGH :: CInt pri_NORM :: CInt pri_LOW :: CInt pri_LOWEST :: CInt -- | An opaque type referencing a particular hook. Can be passed to -- unhook. data Hook -- | This type defines whether the current hook "consumes" the event or -- lets other hooks know about it. data Eat -- | Pass the event to everything else. EatNone :: Eat -- | Pass the event to all other scripts but not HexChat. EatHexChat :: Eat -- | Pass the event to HexChat but not any other scripts. EatPlugin :: Eat -- | Completely consume the event. EatAll :: Eat -- | Event attributes. data EventAttrs EventAttrs :: CTime -> EventAttrs [server_time_utc] :: EventAttrs -> CTime -- | An opaque type referencing a context (tab or window). data Context data List command :: Plugin -> String -> IO () print :: Plugin -> String -> IO () emitPrint :: Plugin -> String -> [String] -> IO Bool emitPrintAttrs :: Plugin -> EventAttrs -> String -> [String] -> IO Bool sendModes :: Plugin -> [String] -> Int -> Char -> Char -> IO () nickCmp :: Plugin -> String -> String -> IO Ordering strip :: Plugin -> Bool -> Bool -> String -> IO String getPrefs :: Plugin -> String -> (String -> IO a) -> (Int -> IO a) -> (Bool -> IO a) -> IO (Maybe a) listGet :: Plugin -> String -> IO (Maybe List) listFields :: Plugin -> String -> IO [String] listNext :: Plugin -> List -> IO Bool listStr :: Plugin -> List -> String -> IO String listInt :: Plugin -> List -> String -> IO Int listTime :: Plugin -> List -> String -> IO CTime hookCommand :: Plugin -> String -> CInt -> String -> ([String] -> [String] -> IO Eat) -> IO Hook hookPrint :: Plugin -> String -> CInt -> ([String] -> IO Eat) -> IO Hook hookPrintAttrs :: Plugin -> String -> CInt -> ([String] -> EventAttrs -> IO Eat) -> IO Hook hookServer :: Plugin -> String -> CInt -> ([String] -> [String] -> IO Eat) -> IO Hook hookServerAttrs :: Plugin -> String -> CInt -> ([String] -> [String] -> EventAttrs -> IO Eat) -> IO Hook unhook :: Plugin -> Hook -> IO () findContext :: Plugin -> Maybe String -> Maybe String -> IO (Maybe Context) getContext :: Plugin -> IO Context setContext :: Plugin -> Context -> IO Bool pluginguiAdd :: Plugin -> String -> String -> String -> String -> IO Plugin pluginguiRemove :: Plugin -> Plugin -> IO () data StaticData staticData :: StaticData lPlugin :: IORef Plugin lHandle :: IORef IORef Plugin lHooks :: IORef IORef [(Plugin, Hook)] initStaticData :: Plugin -> IO () joinStaticData :: StaticData -> IO () getPlugin :: IO Plugin getHandle :: IO Plugin withHandle :: Plugin -> IO a -> IO a unhookHandle :: Plugin -> IO () newtype Plugin Plugin :: (Ptr HexChat_Plugin) -> Plugin type Plugin_Init = Plugin -> Ptr CString -> Ptr CString -> Ptr CString -> CString -> IO CInt type Plugin_Deinit = Plugin -> IO CInt instance GHC.Classes.Eq HexChat.Internal.EventAttrs instance GHC.Read.Read HexChat.Internal.EventAttrs instance GHC.Show.Show HexChat.Internal.EventAttrs instance GHC.Classes.Eq HexChat.Internal.Eat instance GHC.Read.Read HexChat.Internal.Eat instance GHC.Show.Show HexChat.Internal.Eat instance GHC.Classes.Eq HexChat.Internal.List instance GHC.Classes.Ord HexChat.Internal.Context instance GHC.Classes.Eq HexChat.Internal.Context instance GHC.Show.Show HexChat.Internal.Context instance GHC.Classes.Ord HexChat.Internal.Hook instance GHC.Classes.Eq HexChat.Internal.Hook instance GHC.Show.Show HexChat.Internal.Hook instance GHC.Classes.Ord HexChat.Internal.Plugin instance GHC.Classes.Eq HexChat.Internal.Plugin instance GHC.Show.Show HexChat.Internal.Plugin -- | A HexChat script is a .hs file that defines a global -- identifier info with type ModInfo. This structure -- contains the necessary metadata about a script as well its -- initialization and deinitialization functions. From your -- initialization function you may want to hook some events. Any -- remaining hooks are automatically unhooked after the deinitializer so -- you don't have to worry about that. module HexChat -- | This datatype contains metadata about the script. Every script should -- define an global binding named info of this type. This -- structure contains internal fields necessary for scripting to work, so -- when constructing an object please use the default value -- modInfo with record modification notation, like this: -- --
--   info = modInfo { modName = "a module", modAuthor = "somepony", ... }
--   
-- -- The type parameter signifies the return type of the initializer and -- has no special meaning otherwise, you can specialize it to anything -- you want. -- -- If you need to pass a lot of data to the deinitializer you could -- simply let a ~ IO () and modDeinit = -- id, such as in the following: -- --
--   info = modInfo
--       { modInit = do
--             x <- createX
--             return $ do
--                 destroyX x
--       , modDeinit = id
--       }
--   
data ModInfo a ModInfo :: String -> String -> String -> String -> IO a -> (a -> IO ()) -> StaticData -> ModInfo a -- | Name of the script. [modName] :: ModInfo a -> String -- | Version of the script. [modVersion] :: ModInfo a -> String -- | Author of the script. [modAuthor] :: ModInfo a -> String -- | A short description of the script that can fit in the "Plugins and -- Scripts" list window. [modDescription] :: ModInfo a -> String -- | This is the entry point of the script. It will be executed immediately -- after the script is compiled and loaded. The returned value will be -- opaquely passed to modDeinit. [modInit] :: ModInfo a -> IO a -- | This function will be executed shortly before the script is unloaded. -- You can place any cleanup routines here. As argument it receives -- whatever modInit returned. [modDeinit] :: ModInfo a -> a -> IO () -- | An internal field that lets the different (to the linker) instances of -- the HexChat library identify eachother. Please inherit the value of -- this field from modInfo. [modStaticData] :: ModInfo a -> StaticData -- | A default value for ModInfo. This has some sensible defaults -- and also provides the values of internal fields necessary for the -- operation of the interface. modInfo :: ModInfo a -- | Invoke a HexChat command as if the user has typed it in the inputbox. -- Do not include the leading /. command :: String -> IO () -- | Print some text to the buffer. print :: String -> IO () -- | Output a Text Event to the buffer. First argument is the Text Event -- identifier (see Settings -> Text Events), second is the -- list of event's parameters. emitPrint :: String -> [String] -> IO Bool -- | Event attributes. data EventAttrs EventAttrs :: CTime -> EventAttrs [server_time_utc] :: EventAttrs -> CTime -- | Same as emitPrint but also lets you specify Event Attributes -- for the event. emitPrintAttrs :: EventAttrs -> String -> [String] -> IO Bool -- | sendModes targets n sign mode where sign is -- + or - and mode is a channel mode character -- will set the specified channel mode on each of the specified targets, -- sending n modes per line, or the server's advertised maximum -- if n is zero. sendModes :: [String] -> Int -> Char -> Char -> IO () -- | Compare two nicknames according to the rules of the server. nickCmp :: String -> String -> IO Ordering -- | strip colors format will strip colors if -- colors is True, and miscellaneous formatting if -- formatting is True, from the provided string. strip :: Bool -> Bool -> String -> IO String -- | Get a HexChat preference value (see /set). You should pass 3 -- continuations one of which will be invoked depending on the type of -- the actual preference. Returns Nothing if no preference with -- that name exists. getPrefs :: String -> (String -> IO a) -> (Int -> IO a) -> (Bool -> IO a) -> IO (Maybe a) -- | Return the value of a preference that is supposedly a String. Returns -- Nothing if no such preference exists or it is of the wrong -- type. getPrefString :: String -> IO (Maybe String) -- | Return the value of a preference that is supposedly an Int. Returns -- Nothing if no such preference exists or it is of the wrong -- type. getPrefInt :: String -> IO (Maybe Int) -- | Return the value of a preference that is supposedly a Bool. Returns -- Nothing if no such preference exists or it is of the wrong -- type. getPrefBool :: String -> IO (Maybe Bool) data List listGet :: String -> IO (Maybe List) listFields :: String -> IO [String] listNext :: List -> IO Bool listStr :: List -> String -> IO String listInt :: List -> String -> IO Int listTime :: List -> String -> IO CTime pri_HIGHEST :: CInt pri_HIGH :: CInt pri_NORM :: CInt pri_LOW :: CInt pri_LOWEST :: CInt -- | This type defines whether the current hook "consumes" the event or -- lets other hooks know about it. data Eat -- | Pass the event to everything else. EatNone :: Eat -- | Pass the event to all other scripts but not HexChat. EatHexChat :: Eat -- | Pass the event to HexChat but not any other scripts. EatPlugin :: Eat -- | Completely consume the event. EatAll :: Eat -- | An opaque type referencing a particular hook. Can be passed to -- unhook. data Hook -- | hookCommand cmd priority description f registers a -- command named cmd (with description description). -- The given f will be passed a list of command's arguments -- (proper words) and a list of "leftovers" for every position in the -- word list (with the exact original whitespace). -- -- If cmd is "" then instead the hook will be invoked -- whenever the user types anything not beginning with /. hookCommand :: String -> CInt -> String -> ([String] -> [String] -> IO Eat) -> IO Hook -- | hookPrint event priority f hooks f to be -- invoked whenever a Text Event event is to be displayed on -- screen. The given f will be passed a list of event's -- parameters. hookPrint :: String -> CInt -> ([String] -> IO Eat) -> IO Hook -- | hookPrintAttrs event priority f hooks f to be -- invoked whenever a Text Event event is to be displayed on -- screen. The given f will be passed a list of event's -- parameters, and the attributes. hookPrintAttrs :: String -> CInt -> ([String] -> EventAttrs -> IO Eat) -> IO Hook -- | hookServer word priority f hooks f to be -- invoked whenever a word command arrives from the IRC server. -- The given f will be passed a list of command's arguments -- (proper words) and a list of "leftovers" for every position in the -- word list (with the exact original whitespace). Processing of -- : long arguments is *NOT* done. -- -- If cmd is "RAW LINE" then the hook will be invoked -- for all commands received from the server. hookServer :: String -> CInt -> ([String] -> [String] -> IO Eat) -> IO Hook -- | hookServer word priority f hooks f to be -- invoked whenever a word command arrives from the IRC server. -- The given f will be passed a list of command's arguments -- (proper words), a list of "leftovers" for every position in the word -- list (with the exact original whitespace), and the event attributes. -- Processing of : long arguments is *NOT* done. -- -- If cmd is "RAW LINE" then the hook will be invoked -- for all commands received from the server. hookServerAttrs :: String -> CInt -> ([String] -> [String] -> EventAttrs -> IO Eat) -> IO Hook -- | Remove the given hook. All hooks are automatically removed when the -- script is unloaded. unhook :: Hook -> IO () -- | An opaque type referencing a context (tab or window). data Context -- | findContext mserver mtabname finds the context -- corresponding to the given tab name (or to the front tab if -- Nothing) in the given server (or in any of the servers if -- Nothing). findContext :: Maybe String -> Maybe String -> IO (Maybe Context) -- | Obtains the current context. getContext :: IO Context -- | Sets the current context. The scope of this function is limited to the -- currently executing hook (or the initializer/deinitializer). setContext :: Context -> IO Bool -- | Execute a given IO action in a given context a-la bracket. withContext :: Context -> IO a -> IO a