<commit_before>{-# OPTIONS_GHC -fno-cse #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE RecordWildCards #-}
import Bot
import Bot.Component.Command
import Bot.Component.Conditional
import Bot.Component.Fuzzy
import Bot.Component.Impl.Goodbye
import Bot.Component.Impl.Op
import Bot.Component.Impl.Roll
import Bot.Component.Impl.Uptime
import Bot.Component.Impl.Seen
import Bot.IO

import Data.List
import System.Console.CmdArgs.Implicit
import System.Directory

-- | A data type defining the various command line arguments that may be
-- supplied.
data Flags = Flags {
        serverFlag  ::  String
    ,   portFlag    ::  Int
    ,   nickFlag    ::  String
    ,   channelFlag ::  [String]
    ,   dataFlag    ::  FilePath
} deriving (Data, Typeable, Show)

-- | Declare the default values, help strings and options values for each of the
-- different flags.
flagDefinition = Flags {
        serverFlag  =   "crafting.dangerbear.in"
                    &=  explicit 
                    &=  help "The IRC server to connect to"
                    &=  name "server"
                    &=  typ "HostName"
    ,   portFlag    =   6667
                    &=  explicit 
                    &=  help "The port on which the IRC server is running"
                    &=  name "port"
                    &=  typ "PortNumber"
    ,   nickFlag    =   "zhenya_bot"
                    &=  explicit 
                    &=  help "The nick that the bot should take"
                    &=  name "nick"
                    &=  typ "Nick"
    ,   channelFlag =   []
                    &=  explicit 
                    &=  help "The channel that the bot should join"
                    &=  name "channel"
                    &=  typ "Channel"
    ,   dataFlag    =   "data"
                    &=  explicit 
                    &=  help "The directory persistent files should be stored"
                    &=  name "data"
                    &=  typ "Directory"
}   &=  summary "Greatest guys IRC bot"
    &=  program "zhenya_bot"

-- | Grab configuration from the command line, attach appropriate BotComponents
-- and start the IRC bot.
main :: IO ()
main = do
    Flags{..} <-  cmdArgs flagDefinition
    -- Create a directory for runtime data if one does not already exist
    runBot $ defaultBotConfig {
            cfgServer   = serverFlag
        ,   cfgPort     = portFlag
        ,   cfgData     = dataFlag
        ,   cfgChannel  = nub channelFlag
        ,   cfgNick     = nickFlag
        } `withComponents` [
            grantOps
        ,   rollDice
        ,   sayGoodbye
        ,   seen
        ,   uptime

        ,   command "!id" (ircReply . unwords)

        ,   conditional (nickFlag `isPrefixOf`) (ircReply "hm?") 

        ,   fuzzyMatch "pigups" 0.3 
                (ircReply "Jolly good pigups, jolly good.") 

        ,   fuzzyMatch "you can't dry a bug!" 0.5
                (ircReply "Noted.") 

        ,   fuzzyMatch "cheap meat" 0.2 
                (ircReply "Can we go to DQ?") 

        ,   fuzzyMatch "I'd expect it." 0.8
                (ircReply "me too")
        ]
<commit_msg>0.7 just the right amount of fuzzy<commit_after>{-# OPTIONS_GHC -fno-cse #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE RecordWildCards #-}
import Bot
import Bot.Component.Command
import Bot.Component.Conditional
import Bot.Component.Fuzzy
import Bot.Component.Impl.Goodbye
import Bot.Component.Impl.Op
import Bot.Component.Impl.Roll
import Bot.Component.Impl.Uptime
import Bot.Component.Impl.Seen
import Bot.IO

import Data.List
import System.Console.CmdArgs.Implicit
import System.Directory

-- | A data type defining the various command line arguments that may be
-- supplied.
data Flags = Flags {
        serverFlag  ::  String
    ,   portFlag    ::  Int
    ,   nickFlag    ::  String
    ,   channelFlag ::  [String]
    ,   dataFlag    ::  FilePath
} deriving (Data, Typeable, Show)

-- | Declare the default values, help strings and options values for each of the
-- different flags.
flagDefinition = Flags {
        serverFlag  =   "crafting.dangerbear.in"
                    &=  explicit 
                    &=  help "The IRC server to connect to"
                    &=  name "server"
                    &=  typ "HostName"
    ,   portFlag    =   6667
                    &=  explicit 
                    &=  help "The port on which the IRC server is running"
                    &=  name "port"
                    &=  typ "PortNumber"
    ,   nickFlag    =   "zhenya_bot"
                    &=  explicit 
                    &=  help "The nick that the bot should take"
                    &=  name "nick"
                    &=  typ "Nick"
    ,   channelFlag =   []
                    &=  explicit 
                    &=  help "The channel that the bot should join"
                    &=  name "channel"
                    &=  typ "Channel"
    ,   dataFlag    =   "data"
                    &=  explicit 
                    &=  help "The directory persistent files should be stored"
                    &=  name "data"
                    &=  typ "Directory"
}   &=  summary "Greatest guys IRC bot"
    &=  program "zhenya_bot"

-- | Grab configuration from the command line, attach appropriate BotComponents
-- and start the IRC bot.
main :: IO ()
main = do
    Flags{..} <-  cmdArgs flagDefinition
    -- Create a directory for runtime data if one does not already exist
    runBot $ defaultBotConfig {
            cfgServer   = serverFlag
        ,   cfgPort     = portFlag
        ,   cfgData     = dataFlag
        ,   cfgChannel  = nub channelFlag
        ,   cfgNick     = nickFlag
        } `withComponents` [
            grantOps
        ,   rollDice
        ,   sayGoodbye
        ,   seen
        ,   uptime

        ,   command "!id" (ircReply . unwords)

        ,   conditional (nickFlag `isPrefixOf`) (ircReply "hm?") 

        ,   fuzzyMatch "pigups" 0.3 
                (ircReply "Jolly good pigups, jolly good.") 

        ,   fuzzyMatch "you can't dry a bug!" 0.5
                (ircReply "Noted.") 

        ,   fuzzyMatch "cheap meat" 0.2 
                (ircReply "Can we go to DQ?") 

        ,   fuzzyMatch "I'd expect it." 0.7
                (ircReply "me too")
        ]

{'fraction_non_alphanumeric': 0.09076356651192573, 'fraction_numerical': 0.004161997758924283, 'mean_word_length': 1.5213882163034704, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1096851', 'n_tokens_mistral': 1855, 'n_tokens_neox': 1712, 'n_words': 524}