mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
Remove unnecessary Database struct and add more persistence.
This commit is contained in:
parent
ccdf7779a5
commit
be60d503be
5 changed files with 28 additions and 26 deletions
|
|
@ -2,6 +2,7 @@ package irc
|
|||
|
||||
import (
|
||||
"code.google.com/p/go.crypto/bcrypt"
|
||||
"database/sql"
|
||||
"log"
|
||||
"net"
|
||||
"time"
|
||||
|
|
@ -24,7 +25,7 @@ type Server struct {
|
|||
channels ChannelNameMap
|
||||
services ServiceNameMap
|
||||
commands chan<- Command
|
||||
db *Database
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func NewServer(name string) *Server {
|
||||
|
|
@ -40,7 +41,7 @@ func NewServer(name string) *Server {
|
|||
}
|
||||
go server.receiveCommands(commands)
|
||||
NewNickServ(server)
|
||||
server.db.Transact(func(q Queryable) bool {
|
||||
Transact(server.db, func(q Queryable) bool {
|
||||
urs, err := FindAllUsers(server.db)
|
||||
if err != nil {
|
||||
return false
|
||||
|
|
@ -146,6 +147,9 @@ func (s *Server) Nick() string {
|
|||
|
||||
func (s *Server) DeleteChannel(channel *Channel) {
|
||||
delete(s.channels, channel.name)
|
||||
if err := DeleteChannel(s.db, channel); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue