By | fr33domlover |
At | 2016-01-25 |
Title | Add !puppet-end, now local puppet mode can be toggled |
Description |
Edit file src/FunBot/Commands.hs 33188 → 33188
73 73 , cmdAddWhereLocal
74 74 , cmdRemoveWhereLocal
75 75 , cmdAddWhereGlobal
76 76 , cmdRemoveWhereGlobal
77 77 , cmdPuppetStart
+ 78 , cmdPuppetEnd
78 79 ]
79 80 }
… … … … Edit file src/FunBot/Commands/Puppet.hs 33188 → 33188
15 15 16 16 {-# LANGUAGE OverloadedStrings #-}
17 17 18 18 module FunBot.Commands.Puppet
19 19 ( cmdPuppetStart
- 20 --, cmdPuppetEnd
+ 20 , cmdPuppetEnd
21 21 --, cmdPuppetStatus
22 22 --, cmdPuppetSay
23 23 )
24 24 where
25 25 … … … … 29 29 import FunBot.Util
30 30 import Network.IRC.Fun.Bot.Chat
31 31 import Network.IRC.Fun.Bot.Types
32 32 import Network.IRC.Fun.Color.Format (formatMsg)
33 33 import Network.IRC.Fun.Color.Format.Long
- 34 import Network.IRC.Fun.Types (Channel (..))
+ 34 import Network.IRC.Fun.Types.Base
35 35 + 36 start :: Channel -> Nickname -> (MsgContent -> BotSession ()) -> BotSession ()
36 37 start chan nick send = do
37 38 result <- puppetStart chan nick
38 39 send $ case result of
39 40 Just False ->
40 41 formatMsg
… … … … 73 74 \channel\n\
74 75 \‘puppet-start <channel>’ - enable puppet mode in the given channel"
75 76 , cmdExamples =
76 77 [ "puppet-start"
77 78 , "puppet-start #freepost-bot"
+ 79 ]
+ 80 }
+ 81 + 82 end :: Channel -> Nickname -> (MsgContent -> BotSession ()) -> BotSession ()
+ 83 end chan nick send = do
+ 84 result <- puppetEnd chan nick
+ 85 send $ case result of
+ 86 Just False ->
+ 87 formatMsg
+ 88 (nickname % ", I don’t have " % channel % " in puppet mode.")
+ 89 nick chan
+ 90 Just True ->
+ 91 formatMsg
+ 92 ( nickname
+ 93 % ", you aren’t listed as a puppeteer for "
+ 94 % channel
+ 95 )
+ 96 nick chan
+ 97 Nothing ->
+ 98 formatMsg
+ 99 (nickname % ", puppet mode ended for " % channel)
+ 100 nick chan
+ 101 + 102 respondPuppetEnd :: Respond
+ 103 respondPuppetEnd Nothing _nick [] send =
+ 104 send "Please specify a channel, or use this command in a channel."
+ 105 respondPuppetEnd (Just chan) nick [] send = end chan nick send
+ 106 respondPuppetEnd _mchan nick [chant] send =
+ 107 let chan = Channel chant
+ 108 in if looksLikeChan chan
+ 109 then end chan nick send
+ 110 else send $ notchan chan
+ 111 respondPuppetEnd mchan nick args _send =
+ 112 failBack mchan nick $ WrongNumArgsN (Just $ length args) Nothing
+ 113 + 114 cmdPuppetEnd :: BotCmd
+ 115 cmdPuppetEnd = Command
+ 116 { cmdNames = cmds ["puppet-end"]
+ 117 , cmdRespond = respondPuppetEnd
+ 118 , cmdHelp =
+ 119 "‘puppet-end’ - stop puppet mode in the current channel\n\
+ 120 \‘puppet-end <channel>’ - stop puppet mode in the given channel"
+ 121 , cmdExamples =
+ 122 [ "puppet-end"
+ 123 , "puppet-end #freepost-bot"
78 124 ]
79 125 }
… … … …