forked from BlackWolfWoof/yagpdb-cc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
image_reaction.yag
61 lines (51 loc) · 2.1 KB
/
image_reaction.yag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{{/*
Trigger: .*
Trigger Type: Regex
Description: YAGPDB will react on images and videos. You can optionally turn on an auto delete for none images. Watch this gif if you have no clue what I am talking about https://i.imgur.com/4xvBJeo.gif
Note: Please configure the variables after pasting the code into your control panel and also make sure to limit this to a channel if needed!
Copyright (c): Black Wolf, 2021
License: MIT
Repository: https://github.com/BlackWolfWoof/yagpdb-cc/
*/}}
{{$delete := false}}
{{/*Set this to true if you want to delete all messages that are not images or videos*/}}
{{$react := true}}
{{/*Set this to true if you want yagpdb to react with the emojis*/}}
{{$emojis := cslice "❤" "checkmark:705738821425299527" "cross:705738821110595607"}}
{{/*Replace the emojis if you want. Default emojis will be the unicode like 👎 or 👍 and custom emojis will have to be emojiname:emojiid*/}}
{{$woulddelete1 := false}}{{$woulddelete2 := false}}{{$woulddelete3 := false}}
{{/*Attachment Media*/}}
{{range .Message.Attachments}}
{{if not (reFind `(?i)\.(?:jpg|jpeg|png|gif|tif|webp|mp4|webm|mov)` .Filename)}}
{{$woulddelete1 = true}}
{{end}}
{{else}}
{{$woulddelete1 = true}}
{{end}}
{{/*Media Link*/}}
{{range (reFindAll `https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)` .Message.Content)}}
{{range (reFindAll `(?i)https?:(?://([^/?#]*))?(?:[^?\n#\s]*?/[^?\n#\s]+\.(jpg|jpeg|png|gif|tif|webp|mp4|webm|mov))(?:\?([^?\n#\s]*))?(?:#(.*))?` .)}}
{{else}}
{{$woulddelete2 = true}}
{{end}}
{{else}}
{{$woulddelete2 = true}}
{{end}}
{{/*Embed Media*/}}
{{range (seq 1 6)}}{{if not $.Message.Embeds}}{{sleep 1}}{{end}}{{end}}
{{range .Message.Embeds}}
{{if eq .Type "video" "image" "gifv"}}
{{else}}
{{$woulddelete3 = true}}
{{end}}
{{else}}
{{$woulddelete3 = true}}
{{end}}
{{/*Delete Message*/}}
{{if and $delete $woulddelete1 $woulddelete2 $woulddelete3}}
{{deleteTrigger 0}}
{{end}}
{{/*Add Reactions*/}}
{{if and (or (not $woulddelete1) (not $woulddelete2) (not $woulddelete3)) $react}}
{{range $emojis}}{{addReactions .}}{{end}}
{{end}}