By | fr33domlover |
At | 2016-01-26 |
Title | Use new Formatting integration in History.hs |
Description |
Edit file src/FunBot/History.hs 33188 → 33188
28 28 import Data.Foldable (find, mapM_)
29 29 import Data.Int (Int64)
30 30 import Data.Monoid ((<>))
31 31 import Data.Sequence ((|>), Seq, ViewL (..))
32 32 import Data.Text (Text)
- 33 import Formatting hiding (text)
+ 33 import Formatting ((%), int)
34 34 import FunBot.Config (quoteDir)
35 35 import FunBot.Types
36 36 import Network.IRC.Fun.Bot.Chat
37 37 import Network.IRC.Fun.Bot.MsgCount
38 38 import Network.IRC.Fun.Bot.State
… … … … 95 95 if c
96 96 then do
97 97 res <- msgsSinceParted recip chan
98 98 case res of
99 99 Left n -> do
- 100 send recip $ MsgContent $
- 101 sformat
- 102 ( "You missed at least "
- 103 % int
- 104 % " messages in "
- 105 % stext
- 106 % "."
+ 100 send recip $
+ 101 formatMsg
+ 102 ("You missed at least " % int % " messages in "
+ 103 % channel % "."
107 104 )
- 108 n
- 109 (unChannel chan)
+ 105 n chan
110 106 return Nothing
111 107 Right n -> do
- 112 send recip $ MsgContent $
+ 108 send recip $
113 109 if n == 0
- 114 then sformat
- 115 ( "You didn't miss any messages in "
- 116 % stext
- 117 % "."
- 118 )
- 119 (unChannel chan)
- 120 else sformat
- 121 ( "You missed "
- 122 % int
- 123 % " messages in "
- 124 % stext
- 125 % "."
- 126 )
- 127 n
- 128 (unChannel chan)
+ 110 then formatMsg
+ 111 ("You didn't miss any messages in "
+ 112 % channel % "."
+ 113 )
+ 114 chan
+ 115 else formatMsg
+ 116 ("You missed " % int % " messages in "
+ 117 % channel % "."
+ 118 )
+ 119 n chan
129 120 return $ Just n
130 121 else return Nothing
131 122 mhls <- liftM (M.lookup chan) getHistory
132 123 case mhls of
133 124 Nothing -> return ()
… … … … 135 126 let lAll = Q.length hlsAll
136 127 maxlen' = maybe maxlen (min maxlen) missed
137 128 hls = Q.drop (lAll - maxlen') hlsAll
138 129 l = Q.length hls
139 130 unless (Q.null hls) $ do
- 140 send recip $ MsgContent $
- 141 sformat
- 142 ("Last " % int % " messages in " % stext % ":")
- 143 l
- 144 (unChannel chan)
+ 131 send recip $
+ 132 formatMsg
+ 133 ("Last " % int % " messages in " % channel % ":")
+ 134 l chan
145 135 mapM_ (send recip . formatLine) hls
146 136 147 137 -- Send recent channel messages to a user, for a specific channel.
148 138 reportHistory'
149 139 :: Nickname -- ^ User nickname
… … … … 159 149 Just hlsAll -> do
160 150 now <- getMinutes
161 151 let recent hl = now - hlMinute hl <= mins
162 152 hls = Q.takeWhileR recent hlsAll
163 153 if Q.null hls
- 164 then sendToUser recip $ MsgContent $
- 165 sformat
+ 154 then sendToUser recip $
+ 155 formatMsg
166 156 ("No messages in last " % int % " minutes.")
167 157 mins
168 158 else do
- 169 sendToUser recip $ MsgContent $
- 170 sformat
- 171 ( "Messages I remember from last "
- 172 % int
- 173 % " minutes in "
- 174 % stext
- 175 % ":"
+ 159 sendToUser recip $
+ 160 formatMsg
+ 161 ("Messages I remember from last " % int
+ 162 % " minutes in " % channel % ":"
176 163 )
- 177 mins
- 178 (unChannel chan)
+ 164 mins chan
179 165 mapM_ (sendToUser recip . formatLine) hls
… … … …