Skip to content

Commit 04c661e

Browse files
authored
Merge pull request #838 from tsoding/mod-permissions
Only for mr strimmer :)
2 parents f6aef13 + 8c6db8e commit 04c661e

File tree

5 files changed

+33
-49
lines changed

5 files changed

+33
-49
lines changed

src/Bot.hs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ builtinCommands =
7878
, mkBuiltinCommand
7979
( "Delete quote from quote database"
8080
, $githubLinkLocationStr
81-
, onlyForRoles "Only for mods" authorityRoles $
81+
, onlyForRoles "Only for mr strimmer :)" authorityRoles $
8282
cmapR (readMaybe . T.unpack) $
8383
replyOnNothing "Expected integer as an argument" deleteQuoteCommand))
8484
, ( "quote"
@@ -91,14 +91,14 @@ builtinCommands =
9191
( "Update FFZ cache"
9292
, $githubLinkLocationStr
9393
, authorizeSender senderAuthority $
94-
replyOnNothing "Only for mods" $
94+
replyOnNothing "Only for mr strimmer :)" $
9595
cmapR (const ()) updateFfzEmotesCommand))
9696
, ( "updatebttv"
9797
, mkBuiltinCommand
9898
( "Update BTTV cache"
9999
, $githubLinkLocationStr
100100
, authorizeSender senderAuthority $
101-
replyOnNothing "Only for mods" $
101+
replyOnNothing "Only for mr strimmer :)" $
102102
cmapR (const ()) updateBttvEmotesCommand))
103103
, ( "help"
104104
, mkBuiltinCommand
@@ -108,7 +108,7 @@ builtinCommands =
108108
( "Starts a poll. !poll <duration:secs> option1; option2; ...; option3"
109109
, $githubLinkLocationStr
110110
, authorizeSender senderAuthority $
111-
replyOnNothing "Only for mods" $
111+
replyOnNothing "Only for mr strimmer :)" $
112112
-- TODO(#362): !poll command does not parse negative numbers
113113
regexArgs "([0-9]+) (.*)" $
114114
replyLeft $
@@ -141,7 +141,7 @@ builtinCommands =
141141
( "Add periodic command"
142142
, $githubLinkLocationStr
143143
, authorizeSender senderAuthority $
144-
replyOnNothing "Only for mods" $
144+
replyOnNothing "Only for mr strimmer :)" $
145145
regexArgs "([0-9]+) (.*)" $
146146
replyLeft $
147147
pairArgs $
@@ -161,7 +161,7 @@ builtinCommands =
161161
( "Delete periodic command"
162162
, $githubLinkLocationStr
163163
, authorizeSender senderAuthority $
164-
replyOnNothing "Only for mods" removePeriodicCommand))
164+
replyOnNothing "Only for mr strimmer :)" removePeriodicCommand))
165165
, ( "addtimer"
166166
, mkBuiltinCommand
167167
( "Add Periodic Timer"
@@ -190,13 +190,13 @@ builtinCommands =
190190
( "Enable periodic timer"
191191
, $githubLinkLocationStr
192192
, authorizeSender senderAuthority $
193-
replyOnNothing "Only for mods" enablePeriodicTimerCommand))
193+
replyOnNothing "Only for mr strimmer :)" enablePeriodicTimerCommand))
194194
, ( "periodicoff"
195195
, mkBuiltinCommand
196196
( "Disable periodic timer"
197197
, $githubLinkLocationStr
198198
, authorizeSender senderAuthority $
199-
replyOnNothing "Only for mods" disablePeriodicTimerCommand))
199+
replyOnNothing "Only for mr strimmer :)" disablePeriodicTimerCommand))
200200
, ( "periodicstat"
201201
, mkBuiltinCommand
202202
( "Status of Periodic Timer"
@@ -207,21 +207,22 @@ builtinCommands =
207207
( "Add custom command"
208208
, $githubLinkLocationStr
209209
, authorizeSender senderAuthority $
210-
replyOnNothing "Only for mods" $
210+
replyOnNothing "Only for mr strimmer :)" $
211211
regexArgs "([a-zA-Z0-9]+) ?(.*)" $
212212
replyLeft $ pairArgs $ replyLeft $ addCustomCommand builtinCommands))
213213
, ( "delcmd"
214214
, mkBuiltinCommand
215215
( "Delete custom command"
216216
, $githubLinkLocationStr
217217
, authorizeSender senderAuthority $
218-
replyOnNothing "Only for mods" $ deleteCustomCommand builtinCommands))
218+
replyOnNothing "Only for mr strimmer :)" $
219+
deleteCustomCommand builtinCommands))
219220
, ( "updcmd"
220221
, mkBuiltinCommand
221222
( "Update custom command"
222223
, $githubLinkLocationStr
223224
, authorizeSender senderAuthority $
224-
replyOnNothing "Only for mods" $
225+
replyOnNothing "Only for mr strimmer :)" $
225226
regexArgs "([a-zA-Z0-9]+) ?(.*)" $
226227
replyLeft $
227228
pairArgs $ replyLeft $ updateCustomCommand builtinCommands))
@@ -254,42 +255,42 @@ builtinCommands =
254255
( "Add command alias"
255256
, $githubLinkLocationStr
256257
, authorizeSender senderAuthority $
257-
replyOnNothing "Only for mods" $
258+
replyOnNothing "Only for mr strimmer :)" $
258259
regexArgs "([a-zA-Z0-9]+) ([a-zA-Z0-9]+)" $
259260
replyLeft $ pairArgs $ replyLeft addAliasCommand))
260261
, ( "delalias"
261262
, mkBuiltinCommand
262263
( "Remove command alias"
263264
, $githubLinkLocationStr
264265
, authorizeSender senderAuthority $
265-
replyOnNothing "Only for mods" removeAliasCommand))
266+
replyOnNothing "Only for mr strimmer :)" removeAliasCommand))
266267
, ( "addvar"
267268
, mkBuiltinCommand
268269
( "Add variable"
269270
, $githubLinkLocationStr
270271
, authorizeSender senderAuthority $
271-
replyOnNothing "Only for mods" addVariable))
272+
replyOnNothing "Only for mr strimmer :)" addVariable))
272273
, ( "updvar"
273274
, mkBuiltinCommand
274275
( "Update variable"
275276
, $githubLinkLocationStr
276277
, authorizeSender senderAuthority $
277-
replyOnNothing "Only for mods" $
278+
replyOnNothing "Only for mr strimmer :)" $
278279
regexArgs "([a-zA-Z0-9]+) ?(.*)" $
279280
replyLeft $ pairArgs $ replyLeft updateVariable))
280281
, ( "delvar"
281282
, mkBuiltinCommand
282283
( "Delete variable"
283284
, $githubLinkLocationStr
284285
, authorizeSender senderAuthority $
285-
replyOnNothing "Only for mods" deleteVariable))
286+
replyOnNothing "Only for mr strimmer :)" deleteVariable))
286287
, ( "nuke"
287288
, mkBuiltinCommand
288289
( [qms|Looks at N previous messages and bans all of
289290
the users whose messages match provided regex|]
290291
, $githubLinkLocationStr
291292
, authorizeSender senderAuthority $
292-
replyOnNothing "Only for mods" $
293+
replyOnNothing "Only for mr strimmer :)" $
293294
regexArgs "([0-9]+) (.*)" $
294295
replyLeft $
295296
pairArgs $
@@ -324,7 +325,7 @@ builtinCommands =
324325
( "Makes the user trusted"
325326
, $githubLinkLocationStr
326327
, authorizeSender senderAuthority $
327-
replyOnNothing "Only for mods" $
328+
replyOnNothing "Only for mr strimmer :)" $
328329
regexArgs "(.+)" $
329330
replyLeft $
330331
cmapR headMay $ replyOnNothing "Not enough arguments" trustCommand))
@@ -333,7 +334,7 @@ builtinCommands =
333334
( "Untrusts the user"
334335
, $githubLinkLocationStr
335336
, authorizeSender senderAuthority $
336-
replyOnNothing "Only for mods" $
337+
replyOnNothing "Only for mr strimmer :)" $
337338
regexArgs "(.+)" $
338339
replyLeft $
339340
cmapR headMay $ replyOnNothing "Not enough arguments" untrustCommand))
@@ -379,7 +380,8 @@ builtinCommands =
379380
( "Start the raffle"
380381
, $githubLinkLocationStr
381382
, authorizeSender senderAuthority $
382-
replyOnNothing "Only for mods" $ cmapR (const 5) raffleCommand))
383+
replyOnNothing "Only for mr strimmer :)" $
384+
cmapR (const 5) raffleCommand))
383385
, ( "join"
384386
, mkBuiltinCommand
385387
("Join the raffle", $githubLinkLocationStr, joinCommand))
@@ -407,7 +409,7 @@ builtinCommands =
407409
, mkBuiltinCommand
408410
( "Get the next video for Smart Stream"
409411
, $githubLinkLocationStr
410-
, onlyForRoles "Only for mods" authorityRoles $
412+
, onlyForRoles "Only for mr strimmer :)" authorityRoles $
411413
transR void nextVideoCommand))
412414
, ( "video"
413415
, mkBuiltinCommand
@@ -448,14 +450,14 @@ builtinCommands =
448450
, mkBuiltinCommand
449451
( "Reloads Markov model file"
450452
, $githubLinkLocationStr
451-
, onlyForRoles "Only for mods" authorityRoles $
453+
, onlyForRoles "Only for mr strimmer :)" authorityRoles $
452454
liftR (const reloadMarkov) $
453455
replyOnNothing "Nothing to reload" $ Reaction replyMessage))
454456
, ( "config"
455457
, mkBuiltinCommand
456458
( "Bot configuration command"
457459
, $githubLinkLocationStr
458-
, onlyForRoles "Only for mods" authorityRoles $
460+
, onlyForRoles "Only for mr strimmer :)" authorityRoles $
459461
subcommand
460462
[ ( "help"
461463
, subcommand

src/Bot/Friday.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,12 @@ videoQueueCommand =
315315
subcommand
316316
[ ("", videoQueueLinkCommand)
317317
, ( "gist"
318-
, onlyForRoles "Only for mods" authorityRoles setVideoQueueGistCommand)
318+
, onlyForRoles
319+
"Only for mr strimmer :)"
320+
authorityRoles
321+
setVideoQueueGistCommand)
319322
, ( "refresh"
320-
, onlyForRoles "Only for mods" authorityRoles $
323+
, onlyForRoles "Only for mr strimmer :)" authorityRoles $
321324
liftR (const currentFridayState) $
322325
cmapR (updateFridayStateGistFresh False <$>) $
323326
liftR updateEntityById $

src/Bot/Links.hs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module Bot.Links
1313
) where
1414

1515
import Bot.Replies
16-
import Control.Applicative
1716
import Control.Monad
1817
import Control.Monad.Trans.Maybe
1918
import Data.Either
@@ -56,12 +55,6 @@ findTrustedUser name =
5655
findTrustedSender :: Sender -> MaybeT Effect (Entity TrustedUser)
5756
findTrustedSender = findTrustedUser . senderName
5857

59-
autoTrustSender :: Sender -> MaybeT Effect (Entity TrustedUser)
60-
autoTrustSender sender
61-
| senderSubscriber sender || senderAuthority sender =
62-
MaybeT $ fmap Just $ createEntity Proxy $ TrustedUser $ senderName sender
63-
| otherwise = MaybeT $ return Nothing
64-
6558
textContainsLink :: T.Text -> Bool
6659
textContainsLink t =
6760
isRight $ do
@@ -102,8 +95,7 @@ amitrustedCommand :: Reaction Message ()
10295
amitrustedCommand =
10396
cmapR (const id) $
10497
transR (reflect messageSender) $
105-
liftR
106-
(\sender -> runMaybeT (findTrustedSender sender <|> autoTrustSender sender)) $
98+
liftR (runMaybeT . findTrustedSender) $
10799
cmapR (maybe "no PepeHands" (const "yes Pog")) $ Reaction replyMessage
108100

109101
istrustedCommand :: Reaction Message T.Text

src/Bot/Replies.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ onlyForRoles reply roles reaction =
8282
(cmapR (const reply) $ Reaction replyMessage)
8383

8484
onlyForMods :: Reaction Message a -> Reaction Message a
85-
onlyForMods = onlyForRoles "Only for mods" authorityRoles
85+
onlyForMods = onlyForRoles "Only for mr strimmer :)" authorityRoles
8686

8787
nonEmptyRoles :: Reaction Message a -> Reaction Message a
8888
nonEmptyRoles reaction =

src/Transport.hs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,8 @@ data Sender = Sender
4949
, senderRoles :: [Role]
5050
}
5151

52-
senderSubscriber :: Sender -> Bool
53-
senderSubscriber = elem TwitchSub . senderRoles
54-
55-
senderMod :: Sender -> Bool
56-
senderMod = elem TwitchMod . senderRoles
57-
58-
senderBroadcaster :: Sender -> Bool
59-
senderBroadcaster = elem TwitchBroadcaster . senderRoles
60-
61-
senderOwner :: Sender -> Bool
62-
senderOwner = elem TwitchBotOwner . senderRoles
63-
6452
authorityRoles :: [Role]
65-
authorityRoles =
66-
[TwitchMod, TwitchBroadcaster, TwitchBotOwner, DiscordGuildOwner]
53+
authorityRoles = [TwitchBroadcaster, TwitchBotOwner, DiscordGuildOwner]
6754

6855
paidRoles :: [Role]
6956
paidRoles = [tsodingTwitchedDiscordRole, TwitchSub]

0 commit comments

Comments
 (0)