]> git.lizzy.rs Git - furrybot.git/blob - bullshit.lua
Add video command
[furrybot.git] / bullshit.lua
1 local http, env, storage
2 local C = minetest.get_color_escape_sequence
3
4 -- taken from 9front source code: /rc/bin/bullshit
5 local bullshit_code = [[
6 function min(a, b){
7         if(a > b)
8                 return b
9         else
10                 return a
11 }
12 function suffix(){
13         if(hassuffix = (rand() < 0.2))
14                 return suffixes[int(rand() * nsuffix)]
15         return ""
16 }
17 $2 == "*" { protocol[nprotocol++] = $1; next }
18 $2 == "$" { end[nend++] = $1; next }
19 $2 == "%" { suffixes[nsuffix++] = $1; next }
20 $2 == "^" { start[nstart++] = $1; next }
21 $2 == "|" { noend[nword] = 1 }
22 { word[nword++] = $1; next }
23 END {
24         srand()
25         last = -1
26         out = 0
27         total = int(rand() * 7) + 3
28         n = int(rand() * min(total - out, 3))
29         for(i = 0; i < n; i++)
30                 printf "%s ", start[int(rand() * nstart)]
31         out += n
32         hassuffix = 0
33         n = int(rand() * min(total - out, 3))
34         for(i = 0; i < n; i++)
35                 printf "%s%s ", word[last = int(rand() * nword)], suffix()
36         out += n
37         if(rand() > 0.5){
38                 n = int(rand() * 3)
39                 for(i = 0; i < n; i++)
40                         printf "%s %s", protocol[int(rand() * nprotocol)], (i != n-1) ? "over " : ""
41                 out += n
42                 last = -1
43                 hassuffix = 0
44         }
45         n = int(rand() * min(total - out, 3))
46         if(out + n == 1 || last == -1)
47                 n += 2
48         for(i = 0; i < n; i++)
49                 printf "%s%s ", word[last = int(rand() * nword)], suffix()
50         if(rand() < 0.1 || (last >= 0 && noend[last]) || hassuffix)
51                 printf "%s ", end[int(rand() * nend)]
52         print ""
53 }
54 ]]
55
56 function furrybot.commands.bullshit(name)
57         local pf = env.io.popen("awk '" .. bullshit_code .. "' clientmods/furrybot/bullshit", "r")
58         local bullshit = pf:read("*a")
59         furrybot.ping_message(name, bullshit:sub(1, #bullshit - 2), furrybot.colors.system)
60 end
61
62 return function(_http, _env, _storage)
63         http, env, storage = _http, _env, _storage
64 end