-
Notifications
You must be signed in to change notification settings - Fork 66
/
image_reaction.yag
64 lines (54 loc) · 1.9 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
62
63
64
{{/*
Trigger: .*
Trigger Type: Regex
Description: YAGPDB will react on images and videos. You can optionally turn on an auto delete for none images.
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, 2023
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*/}}
{{/*Don't touch variables below*/}}
{{$woulddelete := false}}{{$skip := false}}
{{/*Attachment Media*/}}
{{range .Message.Attachments}}
{{if (reFind `(?i)\.(jpg|jpeg|png|gif|tif|webp|mp4|webm|mov)\z` .Filename)}}
{{$skip = true}}
{{else}}
{{$woulddelete = true}}
{{end}}
{{else}}
{{$woulddelete = true}}
{{end}}
{{/*Embed Media*/}}
{{if not $skip}}
{{if reFind `https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)` .Message.Content}}
{{$emb := .Message.Embeds}}{{$tmp := true}}
{{range (seq 0 3)}}{{if not (getMessage nil $.Message.ID)}}{{return}}{{end}}{{if not ($emb = (getMessage nil $.Message.ID).Embeds)}}{{sleep 1}}{{end}}{{end}}
{{range $emb}}
{{if or .Thumbnail .Video}}
{{$tmp = false}}
{{end}}
{{end}}
{{if $tmp}}
{{$woulddelete = true}}
{{else}}
{{$woulddelete = false}}
{{end}}
{{end}}
{{end}}
{{/*Delete Message*/}}
{{if $delete}}
{{if $woulddelete}}
{{deleteTrigger 0}}
{{end}}
{{end}}
{{/*Add Reactions*/}}
{{if and (not $woulddelete) $react}}
{{range $emojis}}{{addReactions .}}{{end}}
{{end}}