mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
fix channel persistence
This commit is contained in:
parent
04f0b2c48d
commit
e33a65ec72
@ -1,6 +1,7 @@
|
|||||||
package irc
|
package irc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -209,7 +210,9 @@ func (channel *Channel) SetTopic(client *Client, topic string) {
|
|||||||
member.Reply(reply)
|
member.Reply(reply)
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.Persist()
|
if err := channel.Persist(); err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) CanSpeak(client *Client) bool {
|
func (channel *Channel) CanSpeak(client *Client) bool {
|
||||||
@ -384,21 +387,25 @@ func (channel *Channel) Mode(client *Client, changes ChannelModeChanges) {
|
|||||||
member.Reply(reply)
|
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] {
|
if channel.flags[Persistent] {
|
||||||
channel.server.db.Exec(`
|
_, err = channel.server.db.Exec(`
|
||||||
INSERT OR REPLACE INTO channel
|
INSERT OR REPLACE INTO channel
|
||||||
(name, flags, key, topic, user_list)
|
(name, flags, key, topic, user_limit)
|
||||||
VALUES (?, ?, ?, ?, ?)`,
|
VALUES (?, ?, ?, ?, ?)`,
|
||||||
channel.name, channel.flags.String(), channel.key, channel.topic,
|
channel.name, channel.flags.String(), channel.key, channel.topic,
|
||||||
channel.userLimit)
|
channel.userLimit)
|
||||||
} else {
|
} 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) {
|
func (channel *Channel) Notice(client *Client, message string) {
|
||||||
|
@ -23,7 +23,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SEM_VER = "ergonomadic-1.2.8"
|
SEM_VER = "ergonomadic-1.2.9"
|
||||||
CRLF = "\r\n"
|
CRLF = "\r\n"
|
||||||
MAX_REPLY_LEN = 512 - len(CRLF)
|
MAX_REPLY_LEN = 512 - len(CRLF)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user