By | fr33domlover |
At | 2016-01-16 |
Title | Hacky adaptation to irc-fun-color and base 4.8 |
Description |
Edit file src/FunBot/ExtHandlers.hs 33188 → 33188
52 52 makeEllip len = T.center len ' ' "..."
53 53 54 54 formatCommit :: BranchName -> RepoName -> Commit -> MsgContent
55 55 formatCommit branch repo c =
56 56 MsgContent $ encode $
- 57 Green #> text (commitAuthor c) <> " " <>
- 58 Maroon #> text (unBranchName branch) <> " " <>
- 59 Purple #> text (CI.original $ unRepoName repo) <> " | " <>
- 60 Teal #> text (commitTitle c) <> " " <>
- 61 Gray #> text (commitUrl c)
+ 57 Green #> plain (commitAuthor c) <> " " <>
+ 58 Maroon #> plain (unBranchName branch) <> " " <>
+ 59 Purple #> plain (CI.original $ unRepoName repo) <> " | " <>
+ 60 Teal #> plain (commitTitle c) <> " " <>
+ 61 Gray #> plain (commitUrl c)
62 62 63 63 formatEllipsis :: Int -> BranchName -> RepoName -> Int -> MsgContent
64 64 formatEllipsis len branch repo n =
65 65 MsgContent $ encode $
- 66 Green #> text (makeEllip len) <> " " <>
- 67 Maroon #> text (unBranchName branch) <> " " <>
- 68 Purple #> text (CI.original $ unRepoName repo) <> " | " <>
- 69 Navy #> text (sformat ("... another " % int % " commits ...") n)
+ 66 Green #> plain (makeEllip len) <> " " <>
+ 67 Maroon #> plain (unBranchName branch) <> " " <>
+ 68 Purple #> plain (CI.original $ unRepoName repo) <> " | " <>
+ 69 Navy #> plain (sformat ("... another " % int % " commits ...") n)
70 70 71 71 formatTag :: ProjectObject Tag -> MsgContent
72 72 formatTag (ProjectObject repo tag) =
73 73 MsgContent $ encode $
- 74 Green #> text (tagAuthor tag) <> " " <>
- 75 Purple #> text (repoName repo) <> " " <>
- 76 Teal #> text (tagRef tag)
+ 74 Green #> plain (tagAuthor tag) <> " " <>
+ 75 Purple #> plain (repoName repo) <> " " <>
+ 76 Teal #> plain (tagRef tag)
77 77 78 78 formatMR :: ProjectObject MergeRequest -> MsgContent
79 79 formatMR (ProjectObject repo mr) =
80 80 MsgContent $ encode $
- 81 Green #> text (mrAuthor mr) <> " " <>
- 82 Maroon #> (text $ mrAction mr <> " MR") <> " " <>
- 83 Orange #> text (sformat ("#" % int) (mrId mr)) <> " " <>
- 84 Purple #> text (repoName repo) <> " | " <>
- 85 Teal #> text (mrTitle mr) <> " " <>
- 86 Gray #> text (mrUrl mr)
+ 81 Green #> plain (mrAuthor mr) <> " " <>
+ 82 Maroon #> (plain $ mrAction mr <> " MR") <> " " <>
+ 83 Orange #> plain (sformat ("#" % int) (mrId mr)) <> " " <>
+ 84 Purple #> plain (repoName repo) <> " | " <>
+ 85 Teal #> plain (mrTitle mr) <> " " <>
+ 86 Gray #> plain (mrUrl mr)
87 87 88 88 formatIssue :: ProjectObject Issue -> MsgContent
89 89 formatIssue (ProjectObject repo i) =
90 90 MsgContent $ encode $
- 91 Green #> text (issueAuthor i) <> " " <>
- 92 Maroon #> (text $ issueAction i <> " issue") <> " " <>
- 93 Orange #> text (sformat ("#" % int) (issueId i)) <> " " <>
- 94 Purple #> text (repoName repo) <> " | " <>
- 95 Teal #> text (issueTitle i) <> " " <>
- 96 Gray #> text (issueUrl i)
+ 91 Green #> plain (issueAuthor i) <> " " <>
+ 92 Maroon #> (plain $ issueAction i <> " issue") <> " " <>
+ 93 Orange #> plain (sformat ("#" % int) (issueId i)) <> " " <>
+ 94 Purple #> plain (repoName repo) <> " | " <>
+ 95 Teal #> plain (issueTitle i) <> " " <>
+ 96 Gray #> plain (issueUrl i)
97 97 98 98 formatNote :: ProjectObject Note -> MsgContent
99 99 formatNote (ProjectObject repo n) =
100 100 MsgContent $ encode $
- 101 Green #> text (noteAuthor n) <>
+ 101 Green #> plain (noteAuthor n) <>
102 102 Maroon #> " commented on " <>
- 103 Orange #> text (noteTarget n) <> " " <>
- 104 Purple #> text (repoName repo) <> " | " <>
- 105 Teal #> text (noteContent n) <> " " <>
- 106 Gray #> text (noteUrl n)
+ 103 Orange #> plain (noteTarget n) <> " " <>
+ 104 Purple #> plain (repoName repo) <> " | " <>
+ 105 Teal #> plain (noteContent n) <> " " <>
+ 106 Gray #> plain (noteUrl n)
107 107 108 108 formatNews :: NewsItem -> NewsItemFields -> MsgContent
109 109 formatNews item fields =
110 110 let -- Filtered fields
111 111 filt pass val = if pass then val else Nothing
112 112 authorF = filt (dispAuthor fields) (itemAuthor item)
113 113 fTitleF = filt (dispFeedTitle fields) (itemFeedTitle item)
114 114 urlF = filt (dispUrl fields) (itemUrl item)
115 115 -- Separate components
- 116 author = fmap (\ a -> Green #> text a) authorF
- 117 fTitle = fmap (\ ft -> Purple #> text ft) fTitleF
- 118 iTitle = Teal #> text (itemTitle item)
- 119 url = fmap (\ u -> Gray #> text u) urlF
+ 116 author = fmap (\ a -> Green #> plain a) authorF
+ 117 fTitle = fmap (\ ft -> Purple #> plain ft) fTitleF
+ 118 iTitle = Teal #> plain (itemTitle item)
+ 119 url = fmap (\ u -> Gray #> plain u) urlF
120 120 -- Now combine them
121 121 af = case (author, fTitle) of
122 122 (Nothing, Nothing) -> Nothing
123 123 (a@(Just _), Nothing) -> a
124 124 (Nothing, t@(Just _)) -> t
… … … … Edit file src/FunBot/History.hs 33188 → 33188
51 51 findLast :: (a -> Bool) -> Seq a -> Maybe a
52 52 findLast p s = fmap (Q.index s) $ Q.findIndexR p s
53 53 54 54 formatLine :: HistoryLine -> MsgContent
55 55 formatLine hl =
- 56 let time = Purple #> text (hlTime hl <> " UTC")
+ 56 let time = Purple #> plain (hlTime hl <> " UTC")
57 57 nick = unNickname $ hlNick hl
58 58 sender =
59 59 if hlAction hl
60 60 then
- 61 "* " <> Green #> text nick
+ 61 "* " <> Green #> plain nick
62 62 else
- 63 Gray #> "<" <> Green #> text nick <> Gray #> ">"
- 64 content = text $ unMsgContent $ hlMessage hl
+ 63 Gray #> "<" <> Green #> plain nick <> Gray #> ">"
+ 64 content = plain $ unMsgContent $ hlMessage hl
65 65 in MsgContent $ encode $ time <> " " <> sender <> " " <> content
66 66 67 67 -- | Record someone's last message as a quote.
68 68 quote :: Channel -> Nickname -> BotSession ()
69 69 quote chan nick = do
… … … … Edit file src/FunBot/Memos.hs 33188 → 33188
105 105 (unNickname recip)
106 106 (unNickname $ memoSender memo)
107 107 (memoTime memo)
108 108 (unMsgContent $ memoContent memo)
109 109 formatMemo Nothing idx memo =
- 110 let n = Maroon #> text (sformat ("[" % int % "]") idx)
- 111 time = Purple #> text (memoTime memo <> " UTC")
- 112 sender = Gray #> "<" <> Green #> text (unNickname $ memoSender memo) <> Gray #> ">"
- 113 content = text $ unMsgContent $ memoContent memo
+ 110 let n = Maroon #> plain (sformat ("[" % int % "]") idx)
+ 111 time = Purple #> plain (memoTime memo <> " UTC")
+ 112 sender = Gray #> "<" <> Green #> plain (unNickname $ memoSender memo) <> Gray #> ">"
+ 113 content = plain $ unMsgContent $ memoContent memo
114 114 in MsgContent $
115 115 encode $ n <> " " <> time <> " " <> sender <> " " <> content
116 116 117 117 -- | Send a memo to its destination, nicely formatted.
118 118 sendMemo
… … … … Edit file src/FunBot/Settings.hs 33188 → 33188
69 69 showError (InvalidValueForType t) = t <> " : Invalid value for option type"
70 70 showError (InvalidValue t) = t <> " : Invalid value"
71 71 72 72 showOptLine :: Text -> Text -> Text -> Text
73 73 showOptLine opt op val =
- 74 encode $ Yellow #> text opt <> Teal #> text op <> Maroon #> text val
+ 74 encode $ Yellow #> plain opt <> Teal #> plain op <> Maroon #> plain val
75 75 76 76 showGet :: Text -> Text -> Text
77 77 showGet opt val = showOptLine opt " = " val
78 78 79 79 showSec :: OptPath -> [Text] -> [Text] -> Text
80 80 showSec path subs opts =
81 81 let showSub = ('‣' `T.cons`)
82 82 showOpt = ('•' `T.cons`)
83 83 showList = T.unwords . sort
- 84 pathF = Yellow #> text path
- 85 subsF = Green #> text (showList $ map showSub subs)
- 86 optsF = Purple #> text (showList $ map showOpt opts)
+ 84 pathF = Yellow #> plain path
+ 85 subsF = Green #> plain (showList $ map showSub subs)
+ 86 optsF = Purple #> plain (showList $ map showOpt opts)
87 87 in encode $ case (null subs, null opts) of
88 88 (False, False) -> pathF <> " : " <> subsF <> " | " <> optsF
89 89 (False, True) -> pathF <> " : " <> subsF
90 90 (True, False) -> pathF <> " : " <> optsF
91 91 (True, True) -> pathF <> " : Empty section"
… … … … Edit file src/FunBot/Util.hs 33188 → 33188
92 92 cmds = map $ CommandName . CI.mk
93 93 94 94 looksLikeChan (Channel chan) =
95 95 case T.uncons chan of
96 96 Nothing -> False
- 97 Just (c, _) -> c `elem` "#+!&"
+ 97 Just (c, _) -> c `elem` ("#+!&" :: String)
98 98 99 99 notchan chan = MsgContent $ unChannel chan <> " doesn’t look like a channel name."
100 100 101 101 looksLikeNick nick =
102 102 case T.uncons nick of
103 103 Nothing -> False
104 104 Just (c, r) -> first c && T.all rest r
105 105 where
106 106 isAsciiLetter c = isAsciiLower c || isAsciiUpper c
- 107 isSpecial = (`elem` "[]\\`_^{|}")
+ 107 isSpecial = (`elem` ("[]\\`_^{|}" :: String))
108 108 first c = isAsciiLetter c || isSpecial c
109 109 rest c = isAsciiLetter c || isDigit c || isSpecial c || c == '-'
110 110 111 111 notnick nick = MsgContent $ nick <> " doesn’t look like a nickname."
… … … …