From e33a65ec7261251c978800aa7ee209a237b60628 Mon Sep 17 00:00:00 2001 From: Jeremy Latt Date: Wed, 26 Feb 2014 21:52:17 -0800 Subject: [PATCH] fix channel persistence --- irc/channel.go | 19 +++++++++++++------ irc/constants.go | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/irc/channel.go b/irc/channel.go index 91a5fbed..52f18610 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -1,6 +1,7 @@ package irc import ( + "log" "strconv" "strings" ) @@ -209,7 +210,9 @@ func (channel *Channel) SetTopic(client *Client, topic string) { member.Reply(reply) } - channel.Persist() + if err := channel.Persist(); err != nil { + log.Println(err) + } } func (channel *Channel) CanSpeak(client *Client) bool { @@ -384,21 +387,25 @@ func (channel *Channel) Mode(client *Client, changes ChannelModeChanges) { member.Reply(reply) } - channel.Persist() + if err := channel.Persist(); err != nil { + log.Println(err) + } } } -func (channel *Channel) Persist() { +func (channel *Channel) Persist() (err error) { if channel.flags[Persistent] { - channel.server.db.Exec(` + _, err = channel.server.db.Exec(` INSERT OR REPLACE INTO channel - (name, flags, key, topic, user_list) + (name, flags, key, topic, user_limit) VALUES (?, ?, ?, ?, ?)`, channel.name, channel.flags.String(), channel.key, channel.topic, channel.userLimit) } else { - channel.server.db.Exec(`DELETE FROM channel WHERE name = ?`, channel.name) + _, err = channel.server.db.Exec(` + DELETE FROM channel WHERE name = ?`, channel.name) } + return } func (channel *Channel) Notice(client *Client, message string) { diff --git a/irc/constants.go b/irc/constants.go index a03cf77c..6ec510bb 100644 --- a/irc/constants.go +++ b/irc/constants.go @@ -23,7 +23,7 @@ var ( ) const ( - SEM_VER = "ergonomadic-1.2.8" + SEM_VER = "ergonomadic-1.2.9" CRLF = "\r\n" MAX_REPLY_LEN = 512 - len(CRLF)