@@ -14,6 +14,10 @@ import Reaction
1414import Regexp
1515import Text.InterpolatedString.QM
1616import Transport
17+ import Entity
18+ import Data.Proxy
19+ import Property
20+ import Data.Maybe
1721
1822sayMessage :: Reaction Message T. Text
1923sayMessage =
@@ -87,14 +91,39 @@ nonEmptyRoles reaction =
8791 (Reaction noTrust)
8892 (cmapR extract reaction)
8993
94+ data NoTrustReply = NoTrustReply
95+ { noTrustCommandReply :: T. Text
96+ , noTrustLinkReply :: T. Text
97+ } deriving (Eq )
98+
99+ instance IsEntity NoTrustReply where
100+ nameOfEntity Proxy = " NoTrustReply"
101+ toProperties reply =
102+ M. fromList
103+ [ (" command" , PropertyText $ noTrustCommandReply reply)
104+ , (" link" , PropertyText $ noTrustLinkReply reply)
105+ ]
106+ fromProperties properties =
107+ NoTrustReply <$> extractProperty " command" properties <*>
108+ extractProperty " link" properties
109+
110+ noTrustReply :: Effect (Entity NoTrustReply )
111+ noTrustReply = do
112+ reply <- listToMaybe <$> selectEntities Proxy (Take 1 $ All )
113+ case reply of
114+ Just reply' -> return reply'
115+ Nothing ->
116+ createEntity Proxy $
117+ NoTrustReply
118+ [qms |You have to be trusted to use this command.
119+ Mods can change this message with !TODO|]
120+ [qms |You have to be trusted to send links.
121+ Mods can change this message with !TODO|]
122+
90123noTrust :: Message a -> Effect ()
91- noTrust msg = replyToSender (messageSender msg) reply
92- where
93- reply =
94- [qms |You have to be trusted to use this command.
95- Subscribe to gain the trust instantly:
96- https://twitch.tv/{channel'}/subscribe|]
97- channel' = unChannel $ channelToName $ senderChannel $ messageSender msg
124+ noTrust Message {messageSender = sender} = do
125+ reply <- entityPayload <$> noTrustReply
126+ replyToSender sender $ noTrustCommandReply reply
98127
99128onlyForTwitch :: Reaction Message a -> Reaction Message a
100129onlyForTwitch reaction =
0 commit comments