Update to new yaboli version
[testbot] Add echo command that works like Sumairu's
This commit is contained in:
parent
6c28d16a6e
commit
b93f7f38ec
6 changed files with 29 additions and 16 deletions
|
|
@ -38,7 +38,7 @@ infoBot mPasswd = do
|
||||||
|
|
||||||
botMain :: MVar BotState -> Client T.Text ()
|
botMain :: MVar BotState -> Client T.Text ()
|
||||||
botMain stateVar = forever $ do
|
botMain stateVar = forever $ do
|
||||||
event <- respondingToCommands (getCommands stateVar) $
|
event <- respondingToCommand (getCommand stateVar) $
|
||||||
respondingToPing nextEvent
|
respondingToPing nextEvent
|
||||||
updateFromEventVia botListing stateVar event
|
updateFromEventVia botListing stateVar event
|
||||||
updateNick stateVar
|
updateNick stateVar
|
||||||
|
|
@ -61,11 +61,11 @@ longHelp = T.concat
|
||||||
, "Source code available at https://github.com/Garmelon/haboli-bot-collection."
|
, "Source code available at https://github.com/Garmelon/haboli-bot-collection."
|
||||||
]
|
]
|
||||||
|
|
||||||
getCommands :: MVar BotState -> Client e [Command T.Text]
|
getCommand :: MVar BotState -> Client e (Command T.Text)
|
||||||
getCommands stateVar = do
|
getCommand stateVar = do
|
||||||
state <- liftIO $ readMVar stateVar
|
state <- liftIO $ readMVar stateVar
|
||||||
let name = state ^. botListing . lsSelfL . svNickL
|
let name = state ^. botListing . lsSelfL . svNickL
|
||||||
pure
|
pure $ cmdSequential
|
||||||
[ botrulezPingGeneral
|
[ botrulezPingGeneral
|
||||||
, botrulezPingSpecific name
|
, botrulezPingSpecific name
|
||||||
, botrulezPingSpecific "InfoBot"
|
, botrulezPingSpecific "InfoBot"
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ cabal-version: 1.12
|
||||||
--
|
--
|
||||||
-- see: https://github.com/sol/hpack
|
-- see: https://github.com/sol/hpack
|
||||||
--
|
--
|
||||||
-- hash: c59191837f2f234376576136c23122cdc5288703e37b782ee1908d225e22dcee
|
-- hash: d5c030fa8dd9717353e88856ef71c7e7c92cc984be5d40a99a071c221cf9c1e5
|
||||||
|
|
||||||
name: haboli-testbot
|
name: haboli-testbot
|
||||||
version: 0.1.0.0
|
version: 0.1.0.0
|
||||||
|
|
@ -35,6 +35,7 @@ library
|
||||||
base >=4.7 && <5
|
base >=4.7 && <5
|
||||||
, containers
|
, containers
|
||||||
, haboli
|
, haboli
|
||||||
|
, megaparsec
|
||||||
, microlens-platform
|
, microlens-platform
|
||||||
, text
|
, text
|
||||||
, time
|
, time
|
||||||
|
|
@ -52,6 +53,7 @@ executable haboli-testbot
|
||||||
, containers
|
, containers
|
||||||
, haboli
|
, haboli
|
||||||
, haboli-testbot
|
, haboli-testbot
|
||||||
|
, megaparsec
|
||||||
, microlens-platform
|
, microlens-platform
|
||||||
, text
|
, text
|
||||||
, time
|
, time
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ dependencies:
|
||||||
- base >= 4.7 && < 5
|
- base >= 4.7 && < 5
|
||||||
- containers
|
- containers
|
||||||
- haboli
|
- haboli
|
||||||
|
- megaparsec
|
||||||
- microlens-platform
|
- microlens-platform
|
||||||
- text
|
- text
|
||||||
- time
|
- time
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,12 @@ import Control.Monad.IO.Class
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Data.Time
|
import Data.Time
|
||||||
import Lens.Micro.Platform
|
import Lens.Micro.Platform
|
||||||
|
import Text.Megaparsec
|
||||||
|
import Text.Megaparsec.Char
|
||||||
|
|
||||||
import Haboli.Euphoria
|
import Haboli.Euphoria
|
||||||
import Haboli.Euphoria.Botrulez
|
import Haboli.Euphoria.Botrulez
|
||||||
|
import Haboli.Euphoria.Command.Megaparsec
|
||||||
|
|
||||||
data BotState = BotState
|
data BotState = BotState
|
||||||
{ _botStartTime :: UTCTime
|
{ _botStartTime :: UTCTime
|
||||||
|
|
@ -35,7 +38,7 @@ testBot mPasswd = do
|
||||||
|
|
||||||
botMain :: MVar BotState -> Client T.Text ()
|
botMain :: MVar BotState -> Client T.Text ()
|
||||||
botMain stateVar = forever $ do
|
botMain stateVar = forever $ do
|
||||||
event <- respondingToCommands (getCommands stateVar) $
|
event <- respondingToCommand (getCommand stateVar) $
|
||||||
respondingToPing nextEvent
|
respondingToPing nextEvent
|
||||||
updateFromEventVia botListing stateVar event
|
updateFromEventVia botListing stateVar event
|
||||||
|
|
||||||
|
|
@ -49,14 +52,21 @@ longHelp = T.concat
|
||||||
, "Source code available at https://github.com/Garmelon/haboli-bot-collection."
|
, "Source code available at https://github.com/Garmelon/haboli-bot-collection."
|
||||||
]
|
]
|
||||||
|
|
||||||
getCommands :: MVar BotState -> Client e [Command T.Text]
|
getCommand :: MVar BotState -> Client e (Command T.Text)
|
||||||
getCommands stateVar = do
|
getCommand stateVar = do
|
||||||
state <- liftIO $ readMVar stateVar
|
state <- liftIO $ readMVar stateVar
|
||||||
let name = state ^. botListing . lsSelfL . svNickL
|
let name = state ^. botListing . lsSelfL . svNickL
|
||||||
pure
|
pure $ cmdSequential
|
||||||
[ botrulezPingGeneral
|
[ botrulezPingGeneral
|
||||||
, botrulezPingSpecific name
|
, botrulezPingSpecific name
|
||||||
, botrulezHelpSpecific name longHelp
|
, botrulezHelpSpecific name longHelp
|
||||||
, botrulezUptimeSpecific name $ state ^. botStartTime
|
, botrulezUptimeSpecific name $ state ^. botStartTime
|
||||||
, botrulezKillSpecific name
|
, botrulezKillSpecific name
|
||||||
|
, cmdEcho name
|
||||||
]
|
]
|
||||||
|
|
||||||
|
cmdEcho :: T.Text -> Command e
|
||||||
|
cmdEcho name = cmdMega parser $ \msg text -> void $ reply msg text
|
||||||
|
where
|
||||||
|
parser :: Parsec () T.Text T.Text
|
||||||
|
parser = pNick name *> space1 *> pUntilEof
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,4 @@ packages:
|
||||||
|
|
||||||
extra-deps:
|
extra-deps:
|
||||||
- github: Garmelon/haboli
|
- github: Garmelon/haboli
|
||||||
commit: 86b6134c00d23b0e2e80208079a1975ac0c91f9a
|
commit: 46dc9242cf643b59a3f9f3b2cad3dfd538f44898
|
||||||
|
|
|
||||||
|
|
@ -5,19 +5,19 @@
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
- completed:
|
- completed:
|
||||||
size: 19510
|
size: 19868
|
||||||
url: https://github.com/Garmelon/haboli/archive/86b6134c00d23b0e2e80208079a1975ac0c91f9a.tar.gz
|
url: https://github.com/Garmelon/haboli/archive/46dc9242cf643b59a3f9f3b2cad3dfd538f44898.tar.gz
|
||||||
cabal-file:
|
cabal-file:
|
||||||
size: 1576
|
size: 1576
|
||||||
sha256: d3dea9408d036abe5aa663343b63ffd39cb5fbf14d80773248dab42c607b69b6
|
sha256: d3dea9408d036abe5aa663343b63ffd39cb5fbf14d80773248dab42c607b69b6
|
||||||
name: haboli
|
name: haboli
|
||||||
version: 0.3.1.0
|
version: 0.3.1.0
|
||||||
sha256: c137c08d5ccb6c55c6cd3f03b6d50cc073cb885050e4f5815242b11fb2da2307
|
sha256: 86664c11fbea686271664f1e764985ee47c632497519e3d666198c5a258b17cc
|
||||||
pantry-tree:
|
pantry-tree:
|
||||||
size: 1193
|
size: 1193
|
||||||
sha256: 7d7f3fe4fdd753fd6022c1c5f56b30333318130e40b53e0c202f3ea897ff6e79
|
sha256: 69e998d628007ca4f8143e57b8c7c1342215653646d38a1bd2dd4356f50bfc0e
|
||||||
original:
|
original:
|
||||||
url: https://github.com/Garmelon/haboli/archive/86b6134c00d23b0e2e80208079a1975ac0c91f9a.tar.gz
|
url: https://github.com/Garmelon/haboli/archive/46dc9242cf643b59a3f9f3b2cad3dfd538f44898.tar.gz
|
||||||
snapshots:
|
snapshots:
|
||||||
- completed:
|
- completed:
|
||||||
size: 491389
|
size: 491389
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue