summaryrefslogtreecommitdiffstats
path: root/wat
diff options
context:
space:
mode:
authormogad0n2021-03-10 19:33:48 +0530
committermogad0n2021-03-10 19:33:48 +0530
commit379891b2d09ced1187df3226f8693d39b64e36e2 (patch)
tree03b58f4245e16c2d6667acee5920bbc42babe01e /wat
parent85ff6578e812248367b75c574e55dd19ec472087 (diff)
downloadwatbot-379891b2d09ced1187df3226f8693d39b64e36e2.tar.gz
watbot-379891b2d09ced1187df3226f8693d39b64e36e2.tar.bz2
watbot-379891b2d09ced1187df3226f8693d39b64e36e2.zip
initial commit
Diffstat (limited to 'wat')
-rw-r--r--wat/bot.go8
-rw-r--r--wat/db.go14
-rw-r--r--wat/game.go2
3 files changed, 12 insertions, 12 deletions
diff --git a/wat/bot.go b/wat/bot.go
index 100e4df..370641b 100644
--- a/wat/bot.go
+++ b/wat/bot.go
@@ -45,7 +45,7 @@ func (w *WatBot) HandleIrcMsg(c *irc.Client, m *irc.Message) {
}
func (w *WatBot) Admin(m *irc.Message) bool {
- return m.Prefix.Host == "tripsit/operator/hibs"
+ return m.Prefix.Host == "mph.monster"
}
func (w *WatBot) Allowed(c string, r []string) bool {
@@ -64,9 +64,9 @@ func (w *WatBot) CanRespond(m *irc.Message) bool {
if w.Allowed(m.Prefix.Host, w.c.IgnoredHosts) {
return false
}
- if !strings.Contains(m.Prefix.Host, "tripsit") {
- return false
- }
+ // if !strings.Contains(m.Prefix.Host, "") {
+ // return false
+ // }
if !w.Allowed(m.Params[0], w.c.PermittedChannels) {
return false
}
diff --git a/wat/db.go b/wat/db.go
index aa86f1c..85a598b 100644
--- a/wat/db.go
+++ b/wat/db.go
@@ -4,8 +4,8 @@ import (
"fmt"
"time"
- "github.com/jinzhu/gorm"
- _ "github.com/jinzhu/gorm/dialects/sqlite"
+ "gorm.io/gorm"
+ "gorm.io/driver/sqlite"
)
type Player struct {
@@ -15,7 +15,7 @@ type Player struct {
Watting int64
Anarchy int64
Trickery int64
- Coins uint64 `gorm:"default:'100'"`
+ Coins uint64 `gorm:"default:100"`
Health int64
LastMined int64
LastRested int64
@@ -54,12 +54,12 @@ type WatDb struct {
func NewWatDb() *WatDb {
w := WatDb{}
- var err error
- w.db, err = gorm.Open("sqlite3", "wat.db")
+ var err error
+ w.db, err = gorm.Open(sqlite.Open("wat.db"), &gorm.Config{})
if err != nil {
panic(err)
}
- w.db.AutoMigrate(&Action{}, &Player{})
+ w.db.AutoMigrate(&Action{}, &Player{})
return &w
}
@@ -102,7 +102,7 @@ func (w *WatDb) LastActed(player *Player, actionType ActionType) int64 {
func (w *WatDb) Act(player *Player, actionType ActionType) {
action := Action{player.Model.ID, actionType, time.Now().Unix()}
- if w.db.First(&action, "type = ? AND player_id = ?", actionType, player.ID).RecordNotFound() {
+ if err := w.db.First(&action, "type = ? AND player_id = ?", actionType, player.Model.ID).Error; err != nil {
w.db.Create(&action)
} else {
action.Performed = time.Now().Unix()
diff --git a/wat/game.go b/wat/game.go
index b46707b..40aa6f3 100644
--- a/wat/game.go
+++ b/wat/game.go
@@ -28,7 +28,7 @@ var unconscious = "wat, your hands fumble and fail you. try resting, weakling."
func NewWatGame(bot *WatBot, db *WatDb) *WatGame {
g := WatGame{bot, db, Player{}, nil, nil, nil, nil, map[string]int{}}
- g.me = g.db.User(bot.Nick, "tripsit/user/"+bot.Nick, true)
+ g.me = g.db.User(bot.Nick, "amia8t89xfp8y.liberta.casa", true)
g.commands = map[string](func(*Player, []string) string){
//"wat": g.megaWat,
"steroid": g.Steroid,