~kris/9p

glenda

glenda/x/mux/fortunes.go -rw-r--r-- 1.5 KiB
48661367 — Kris Yotam chore: sync local state after restore (push updates, no pull) a month ago
                                                                                
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
65
66
67
68
69
70
71
package mux

import (
	"github.com/bwmarrin/discordgo"
	"strings"
	"os/exec"
	"fmt"
)

// Display fortunes from various 9front /lib/ files
func (m *Mux) Fortunes(ds *discordgo.Session, dm *discordgo.Message, ctx *Context) {
	resp := "```\n"

	// Read relevant file
	path := Config.Db["fortunes"]

	f := ""
	if strings.Contains(dm.Content, "theo") {
		f = "theo"
	} else if strings.Contains(dm.Content, "troll") {
		f = "troll"
	} else if strings.Contains(dm.Content, "rsc") {
		f = "rsc"
	} else if strings.Contains(dm.Content, "terry") {
		f = "terry"
	} else if strings.Contains(dm.Content, "rob") {
		f = "rob"
	} else if strings.Contains(dm.Content, "ken") {
		f = "ken"
	} else if strings.Contains(dm.Content, "henesy") {
		f = "henesy"
	} else if strings.Contains(dm.Content, "davros") {
		f = "davros"
	} else if strings.Contains(dm.Content, "mao") {
		f = "mao"
	} else {
		f = Config.Db["extrafortunes"]
	}

	// Linux solution
	out, err := exec.Command("fortune", path + f).Output()
	if err != nil {
		fmt.Println("Error calling fortune(1), see: x/mux/fortunes.go")
		fmt.Println("%s\n", err)
	}
	resp += string(out)

	resp += "```\n"

	ds.ChannelMessageSend(dm.ChannelID, resp)

	return
}

// Display bullshit from 9front
func (m *Mux) Bullshit(ds *discordgo.Session, dm *discordgo.Message, ctx *Context) {
	resp := "```\n"
	
	out, err := exec.Command(Config.Db["bullshit"]).Output()
	if err != nil {
		resp += "No bullshit script found."
		goto END
	} else {
		resp += string(out)
	}
	
	END:
	resp += "```\n"
	ds.ChannelMessageSend(dm.ChannelID, resp)
	return
}