Beispiel #1
0
func (p *sqlite3) saveMessage(acct Account, msg irc.Message) error {
	stmt, err := p.db.Prepare(`INSERT INTO messages(accountid, command, channel, message, timestamp) ` +
		`VALUES(?, ?, ?, ?, ?)`)
	if err != nil {
		return err
	}
	defer stmt.Close()

	channel := ""
	if msg.Command() == "PRIVMSG" || msg.Command() == "ACTION" && len(msg.Params()) > 1 {
		channel = msg.Params()[0]
	}
	_, err = stmt.Exec(acct.ID(), msg.Command(), channel, msg.Message(), msg.Timestamp())
	return err
}
Beispiel #2
0
//Sends a message to the client/user.
func (wsclient wsClient) SendMessage(msg irc.Message) error {
	_, err := wsclient.conn.Write([]byte(msg.String()))
	return err
}