File tree Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ executable HyperNerd
108108 , Bot.Asciify
109109 , Free
110110 , OrgMode
111+ , Bot.Flip
111112
112113 -- LANGUAGE extensions used by modules in this package.
113114 other-extensions : OverloadedStrings
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ module Bot.CustomCommand
1212 ) where
1313
1414import Bot.Expr
15+ import Bot.Flip
1516import Bot.Replies
1617import Command
1718import Control.Monad
@@ -179,6 +180,8 @@ evalExpr vars (FunCallExpr "or" args) =
179180 fromMaybe " " $ listToMaybe $ dropWhile T. null $ map (evalExpr vars) args
180181evalExpr vars (FunCallExpr " urlencode" args) =
181182 T. concat $ map (T. pack . URI. encode . T. unpack . evalExpr vars) args
183+ evalExpr vars (FunCallExpr " flip" args) =
184+ T. concat $ map (flipText . evalExpr vars) args
182185evalExpr vars (FunCallExpr funame _) = fromMaybe " " $ M. lookup funame vars
183186
184187expandVars :: M. Map T. Text T. Text -> [Expr ] -> T. Text
Original file line number Diff line number Diff line change 1+ module Bot.Flip where
2+
3+ import qualified Data.Map as M
4+ import Data.Maybe
5+ import qualified Data.Text as T
6+
7+ -- https://github.com/doherty/Text-UpsideDown/blob/master/lib/Text/UpsideDown.pm
8+ -- http://www.fileformat.info/convert/text/upside-down-map.htm
9+ flipText :: T. Text -> T. Text
10+ flipText = T. map (\ x -> fromMaybe x $ M. lookup x table) . T. reverse
11+
12+ table :: M. Map Char Char
13+ table =
14+ M. fromList
15+ [ (' \x0021 ' , ' \x00A1 ' )
16+ , (' \x0022 ' , ' \x201E ' )
17+ , (' \x0026 ' , ' \x214B ' )
18+ , (' \x0027 ' , ' \x002C ' )
19+ , (' \x0028 ' , ' \x0029 ' )
20+ , (' \x002E ' , ' \x02D9 ' )
21+ , (' \x0033 ' , ' \x0190 ' )
22+ , (' \x0034 ' , ' \x152D ' )
23+ , (' \x0036 ' , ' \x0039 ' )
24+ , (' \x0037 ' , ' \x2C62 ' )
25+ , (' \x003B ' , ' \x061B ' )
26+ , (' \x003C ' , ' \x003E ' )
27+ , (' \x003F ' , ' \x00BF ' )
28+ , (' \x0041 ' , ' \x2200 ' )
29+ , (' \x0042 ' , ' \x10412 ' )
30+ , (' \x0043 ' , ' \x2183 ' )
31+ , (' \x0044 ' , ' \x25D6 ' )
32+ , (' \x0045 ' , ' \x018E ' )
33+ , (' \x0046 ' , ' \x2132 ' )
34+ , (' \x0047 ' , ' \x2141 ' )
35+ , (' \x004A ' , ' \x017F ' )
36+ , (' \x004B ' , ' \x22CA ' )
37+ , (' \x004C ' , ' \x2142 ' )
38+ , (' \x004D ' , ' \x0057 ' )
39+ , (' \x004E ' , ' \x1D0E ' )
40+ , (' \x0050 ' , ' \x0500 ' )
41+ , (' \x0051 ' , ' \x038C ' )
42+ , (' \x0052 ' , ' \x1D1A ' )
43+ , (' \x0054 ' , ' \x22A5 ' )
44+ , (' \x0055 ' , ' \x2229 ' )
45+ , (' \x0056 ' , ' \x1D27 ' )
46+ , (' \x0059 ' , ' \x2144 ' )
47+ , (' \x005B ' , ' \x005D ' )
48+ , (' \x005F ' , ' \x203E ' )
49+ , (' \x0061 ' , ' \x0250 ' )
50+ , (' \x0062 ' , ' \x0071 ' )
51+ , (' \x0063 ' , ' \x0254 ' )
52+ , (' \x0064 ' , ' \x0070 ' )
53+ , (' \x0065 ' , ' \x01DD ' )
54+ , (' \x0066 ' , ' \x025F ' )
55+ , (' \x0067 ' , ' \x0183 ' )
56+ , (' \x0068 ' , ' \x0265 ' )
57+ , (' \x0069 ' , ' \x0131 ' )
58+ , (' \x006A ' , ' \x027E ' )
59+ , (' \x006B ' , ' \x029E ' )
60+ , (' \x006C ' , ' \x0283 ' )
61+ , (' \x006D ' , ' \x026F ' )
62+ , (' \x006E ' , ' \x0075 ' )
63+ , (' \x0072 ' , ' \x0279 ' )
64+ , (' \x0074 ' , ' \x0287 ' )
65+ , (' \x0076 ' , ' \x028C ' )
66+ , (' \x0077 ' , ' \x028D ' )
67+ , (' \x0079 ' , ' \x028E ' )
68+ , (' \x007B ' , ' \x007D ' )
69+ , (' \x203F ' , ' \x2040 ' )
70+ , (' \x2045 ' , ' \x2046 ' )
71+ , (' \x2234 ' , ' \x2235 ' )
72+ ]
You can’t perform that action at this time.
0 commit comments