Initial Commit
This commit is contained in:
commit
b765d02edc
21
LICENSE.txt
Normal file
21
LICENSE.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Elliott Pardee
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
15
README.md
Normal file
15
README.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
irc-osric
|
||||||
|
=========
|
||||||
|
|
||||||
|
Goal: Create an IRC bot that can effectively maintain an active OSRIC session.
|
||||||
|
|
||||||
|
TODO:
|
||||||
|
|
||||||
|
* Logging
|
||||||
|
* Stat Manipulation
|
||||||
|
* Permission System
|
||||||
|
* Character System
|
||||||
|
* Story Interaction (through PM w/ dungeon master)
|
||||||
|
* Dice Rolling
|
||||||
|
* Battle System
|
||||||
|
* Rule System
|
80
bot.go
Normal file
80
bot.go
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
|
||||||
|
"github.com/thoj/go-ircevent"
|
||||||
|
"strings"
|
||||||
|
"strconv"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
server = "localhost"
|
||||||
|
port = 6667
|
||||||
|
channel = "#bot"
|
||||||
|
nickname = "bot"
|
||||||
|
|
||||||
|
gabens = []string{"vypr"}
|
||||||
|
dunmas = ""
|
||||||
|
|
||||||
|
charmap = make(map[string]string)
|
||||||
|
monsmap = make(map[string]string)
|
||||||
|
)
|
||||||
|
|
||||||
|
func stringInSlice(a string, list []string) bool {
|
||||||
|
// thanks stackoverflow
|
||||||
|
for _, b := range list {
|
||||||
|
if b == a { return true }
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func fillCharmap(nick string, sect string, val string) {
|
||||||
|
// TODO: Command that creates a map of maps for a nick.
|
||||||
|
// vypr["stat"]["armor"] = 9001
|
||||||
|
// vypr["stat"]["health"] = 100
|
||||||
|
// vypr["info"]["name"] = "Peapod"
|
||||||
|
// make(map[string]map[string]string)
|
||||||
|
}
|
||||||
|
|
||||||
|
func processMsg(nick string, msg string, conn *irc.Connection) {
|
||||||
|
if strings.HasPrefix(msg, ".set") && len(strings.Split(msg, " ")) == 3 {
|
||||||
|
// TODO
|
||||||
|
} else if strings.HasPrefix(msg, ".dm") && len(strings.Split(msg, " ")) == 2 {
|
||||||
|
if len(dunmas) == 0 && len(strings.Split(msg, " ")[1]) > 0 {
|
||||||
|
var cmdarray = strings.Split(msg, " ")
|
||||||
|
dunmas = cmdarray[1]
|
||||||
|
fmt.Println("[cmd] dm - " + dunmas)
|
||||||
|
conn.Privmsg(channel, "dm is now set to " + dunmas)
|
||||||
|
} else {
|
||||||
|
conn.Privmsg(channel, "dm has already been set, the current DM is " + dunmas)
|
||||||
|
}
|
||||||
|
} else if msg == ".resetdm" && (nick == dunmas || stringInSlice(nick, gabens)) {
|
||||||
|
dunmas = ""
|
||||||
|
fmt.Println("[cmd] resetdm")
|
||||||
|
conn.Privmsg(channel, "dm has been reset")
|
||||||
|
} else if msg == ".quit" && stringInSlice(nick, gabens) {
|
||||||
|
fmt.Println("[cmd] lord " + nick + " has requested a shutdown")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
conn := irc.IRC(nickname, nickname)
|
||||||
|
|
||||||
|
err := conn.Connect(server + ":" + strconv.Itoa(port))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Print("[err] connection failed - ")
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.AddCallback("001", func(e *irc.Event) { conn.Join("#bot") })
|
||||||
|
|
||||||
|
conn.AddCallback("PRIVMSG", func(e *irc.Event) {
|
||||||
|
processMsg(e.Nick, e.Message(), conn)
|
||||||
|
})
|
||||||
|
|
||||||
|
conn.Loop()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user