]> git.lizzy.rs Git - furrybot-discord.git/blob - bullshit.awk
Add bad apple
[furrybot-discord.git] / bullshit.awk
1 function min(a, b){
2         if(a > b)
3                 return b
4         else
5                 return a
6 }
7 function suffix(){
8         if(hassuffix = (rand() < 0.2))
9                 return suffixes[int(rand() * nsuffix)]
10         return ""
11 }
12 $2 == "*" { protocol[nprotocol++] = $1; next }
13 $2 == "$" { end[nend++] = $1; next }
14 $2 == "%" { suffixes[nsuffix++] = $1; next }
15 $2 == "^" { start[nstart++] = $1; next }
16 $2 == "|" { noend[nword] = 1 }
17 { word[nword++] = $1; next }
18 END {
19         srand()
20         last = -1
21         out = 0
22         total = int(rand() * 7) + 3
23         n = int(rand() * min(total - out, 3))
24         for(i = 0; i < n; i++)
25                 printf "%s ", start[int(rand() * nstart)]
26         out += n
27         hassuffix = 0
28         n = int(rand() * min(total - out, 3))
29         for(i = 0; i < n; i++)
30                 printf "%s%s ", word[last = int(rand() * nword)], suffix()
31         out += n
32         if(rand() > 0.5){
33                 n = int(rand() * 3)
34                 for(i = 0; i < n; i++)
35                         printf "%s %s", protocol[int(rand() * nprotocol)], (i != n-1) ? "over " : ""
36                 out += n
37                 last = -1
38                 hassuffix = 0
39         }
40         n = int(rand() * min(total - out, 3))
41         if(out + n == 1 || last == -1)
42                 n += 2
43         for(i = 0; i < n; i++)
44                 printf "%s%s ", word[last = int(rand() * nword)], suffix()
45         if(rand() < 0.1 || (last >= 0 && noend[last]) || hassuffix)
46                 printf "%s ", end[int(rand() * nend)]
47         print ""
48 }