~kris/9p

glenda

6ea1264a5d804bb128682d758c562222f6542cca — Sean Hinchee 8 years ago 0ec5c1c
added mkindex by adding helper script because os/exec.Command() is braindead
3 files changed, 27 insertions(+), 1 deletions(-)

A gendex
M mux.go
M x/mux/man.go
A gendex => gendex +6 -0
@@ 0,0 1,6 @@
#!/bin/rc

# Helper to make os/exec.Command() easier
cd x/mux/lookman
./mkindex


M mux.go => mux.go +2 -0
@@ 28,6 28,8 @@ func init() {

	Router.Route("dump", "Dump config to file.", Router.Dump)
	
	Router.Route("mkindex", "Generate index for lookman from mirror.", Router.Mkindex)
	
	Router.Route("subscribe", "Subscribe current channel to a given feed id.", Router.Subscribe)
	
	Router.Route("unsubscribe", "Unsubscribe current channel to a given feed id.", Router.Unsubscribe)

M x/mux/man.go => x/mux/man.go +19 -1
@@ 131,7 131,6 @@ func (m *Mux) Lookman(ds *discordgo.Session, dm *discordgo.Message, ctx *Context
		// rc or get out
		//fmt.Println("Running: ", args)
		out, err := exec.Command("./x/mux/lookman/lookman", args...).Output()
		fmt.Println("", err)
		if err != nil {
			resp += "No lookman script found."
			goto END


@@ 175,3 174,22 @@ func (m *Mux) Lookman(ds *discordgo.Session, dm *discordgo.Message, ctx *Context
	resp += "\n"
	_, _ = ds.ChannelMessageSend(dm.ChannelID, resp)
}

// Call lookman on a given query
func (m *Mux) Mkindex(ds *discordgo.Session, dm *discordgo.Message, ctx *Context) {
	resp := "\n"

	out, err := exec.Command("./gendex").Output()
	if err != nil {
		fmt.Println(err)
		resp += "No mkindex script found."
		goto END
	} else {
		fmt.Println("Generating out: ", out)
		resp += "Ok."
	}

	END: 
	resp += "\n"
	ds.ChannelMessageSend(dm.ChannelID, resp)
}