Add restart command to bots
This commit is contained in:
parent
c9e80b2df4
commit
f187790136
4 changed files with 89 additions and 66 deletions
|
|
@ -1,28 +0,0 @@
|
|||
import System.IO
|
||||
|
||||
import qualified System.Log.Formatter as LF
|
||||
import qualified System.Log.Handler as LH
|
||||
import qualified System.Log.Handler.Simple as LH
|
||||
import qualified System.Log.Logger as L
|
||||
|
||||
import qualified EuphApi.Bot as B
|
||||
|
||||
myBotConfig :: B.BotConfig () ()
|
||||
myBotConfig = B.BotConfig
|
||||
{ B.botAddress = "euphoria.io"
|
||||
, B.botRoom = "test"
|
||||
, B.botPassword = Nothing
|
||||
, B.botNick = "EuphApiTestBot"
|
||||
, B.botHandler = const $ return ()
|
||||
, B.botInfo = ()
|
||||
, B.botNewConnectionInfo = return ()
|
||||
, B.botReconnectPolicy = B.defaultReconnectPolicy
|
||||
}
|
||||
|
||||
main = do
|
||||
myHandler <- LH.verboseStreamHandler stdout L.INFO
|
||||
let myFormatter = LF.simpleLogFormatter "<$time> [$loggername/$prio] $msg"
|
||||
myFormattedHandler = LH.setFormatter myHandler myFormatter
|
||||
L.updateGlobalLogger L.rootLoggerName (L.setHandlers [myFormattedHandler])
|
||||
L.updateGlobalLogger L.rootLoggerName (L.setLevel L.INFO)
|
||||
B.runBot myBotConfig
|
||||
|
|
@ -23,12 +23,8 @@ myCommands =
|
|||
, E.generalHelpCommand "I help test @Garmy's EuphApi"
|
||||
, E.uptimeCommand
|
||||
, E.generalUptimeCommand -- most bots don't do this
|
||||
, E.command "whatsmynick" (\msg -> do
|
||||
nick <- E.sessName <$> B.getOwnView
|
||||
let content = nick <> "\n" <> E.mention nick <> "\n" <> E.atMention nick
|
||||
<> "\n" <> E.mentionReduce nick
|
||||
void $ B.reply (E.msgID msg) content
|
||||
)
|
||||
, E.killCommand "Bye!"
|
||||
, E.restartCommand "brb"
|
||||
]
|
||||
|
||||
myBotHandler :: E.EventType -> B.Bot b c ()
|
||||
|
|
@ -48,9 +44,9 @@ myBotConfig = B.BotConfig
|
|||
}
|
||||
|
||||
main = do
|
||||
myHandler <- LH.verboseStreamHandler stdout L.DEBUG
|
||||
myHandler <- LH.verboseStreamHandler stdout L.INFO
|
||||
let myFormatter = LF.simpleLogFormatter "<$time> [$loggername/$prio] $msg"
|
||||
myFormattedHandler = LH.setFormatter myHandler myFormatter
|
||||
L.updateGlobalLogger L.rootLoggerName (L.setHandlers [myFormattedHandler])
|
||||
L.updateGlobalLogger L.rootLoggerName (L.setLevel L.DEBUG)
|
||||
B.runBot myBotConfig
|
||||
L.updateGlobalLogger L.rootLoggerName (L.setLevel L.INFO)
|
||||
B.runBot (return myBotConfig)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue