Fix remainging "hiera" issues

Fixes #2 and #5
configurable-file-paths
Robert Gerus 2015-11-10 02:06:09 +01:00
parent 23b632ae86
commit ebf31d91bb
3 changed files with 22 additions and 4 deletions

View File

@ -8,15 +8,15 @@ import (
)
func channeljoin(output chan irc.Message, msg irc.Message) {
for _, channel := range C.Lookup(msg.Context, "Channels").([]string) {
for _, channel := range C.Lookup(*msg.Context, "Channels").([]interface{}) {
log.Println(msg.Context.Network, "joining channel", channel)
output <- irc.Message{
Command: "JOIN",
Params: []string{channel},
Params: []string{channel.(string)},
}
}
}
func init() {
// AddCallback("001", "channel join", channeljoin)
AddCallback("001", "channel join", channeljoin)
}

View File

@ -7,6 +7,8 @@ import (
"net"
"sync"
"time"
. "github.com/arachnist/gorepost/config"
)
const delim byte = '\n'
@ -51,6 +53,7 @@ func (c *Connection) Receiver() {
for {
c.conn.SetReadDeadline(time.Now().Add(time.Second * 600))
raw, err := c.reader.ReadString(delim)
var src, tgt string
if err != nil {
log.Println(c.Network, "error reading message", err.Error())
log.Println(c.Network, "closing Receiver")
@ -68,6 +71,21 @@ func (c *Connection) Receiver() {
} else {
log.Println(c.Network, "<--", msg.String())
}
if msg.Params == nil {
tgt = ""
} else {
tgt = msg.Params[0]
}
if msg.Prefix == nil {
src = ""
} else {
src = msg.Prefix.Name
}
msg.Context = &Context{
Network: c.Network,
Source: src,
Target: tgt,
}
select {
case c.Output <- *msg:
case <-c.quitrecv:

View File

@ -154,7 +154,7 @@ func (p *Prefix) writeTo(buffer *bytes.Buffer) {
//
// <crlf> ::= CR LF
type Message struct {
Context
*Context
*Prefix
Command string
Params []string