forked from BlackWolfWoof/yagpdb-cc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wordchain.yag
47 lines (45 loc) · 1.38 KB
/
wordchain.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
{{/*
Trigger Type: Regex
Trigger: \A
Copyright (c): Black Wolf, 2021
License: MIT
Repository: https://github.com/BlackWolfWoof/yagpdb-cc/
*/}}
{{$user := 0}}{{$char := ""}}
{{$db := dbGet 2000 "wordchain"}}
{{with $db}}
{{$cslice := cslice.AppendSlice .Value}}
{{$user = index $cslice 0}}
{{$char = index $cslice 1}}
{{end}}
{{if $db}}
{{if eq .User.ID $user}}
{{$x := sendMessageRetID nil (print .User.Mention ", you send two words in a row!")}}
{{deleteMessage nil $x 5}}
{{deleteTrigger 1}}
{{else}}
{{with (reFindAllSubmatches `(?i)\A(\w)(?:\S+)?\z` (lower .Message.Content))}}
{{if eq (index . 0 1) $char}}
{{with reFindAllSubmatches `(?i)\A\S*(\w)\S?\z` $.Message.Content}}
{{dbSet 2000 "wordchain" (cslice $.User.ID (index . 0 1|lower))}}
{{else}}
{{deleteTrigger 1}}
{{end}}
{{else}}
{{$x := sendMessageRetID nil (print $.User.Mention ", start your word with the letter `" (lower $char) "`!")}}
{{deleteMessage nil $x 5}}
{{deleteTrigger 1}}
{{end}}
{{else}}
{{$x := sendMessageRetID nil (print .User.Mention ", start your word with the letter `" (lower $char) "`!")}}
{{deleteMessage nil $x 5}}
{{deleteTrigger 1}}
{{end}}
{{end}}
{{else}}
{{with reFindAllSubmatches `(?i)\A\S+(\w)\S?\z` .Message.Content}}
{{dbSet 2000 "wordchain" (cslice $.User.ID (index . 0 1|lower))}}
{{else}}
{{deleteTrigger 1}}
{{end}}
{{end}}