Automatic group adding

This commit is contained in:
Horscchtey 2022-02-03 21:08:20 +00:00
commit fe7055298a
4 changed files with 178 additions and 162 deletions

View file

@ -32,6 +32,7 @@ func scanline_privmsg (msg string) irc_msg {
if ! strings.HasPrefix(irc.channel, "#") {
irc.channel = irc.author
}
irc.retmsg = ""
return irc
}
@ -44,12 +45,9 @@ func listenToIRC (foo bot) <-chan []byte {
return nil
}
var line []byte
var err error
go func() {
for {
line, err = reader.ReadBytes('\n')
line, err := reader.ReadString('\n')
if err != nil {
LOG_ERR.Printf("Error while reading bytes from connection.\n")
dead = true
@ -57,7 +55,7 @@ func listenToIRC (foo bot) <-chan []byte {
return
}
c <- line
c <- []byte(line)
if bytes.Contains([]byte(line), []byte("PING :")) {
v := []byte(bytes.Replace([]byte(line), []byte("PING"), []byte("PONG"), 1))
@ -69,8 +67,11 @@ func listenToIRC (foo bot) <-chan []byte {
if !bytes.Contains([]byte(line), []byte("PRIVMSG")) {
continue
}
parsemsg(scanline_privmsg(string(line)), foo)
msg := scanline_privmsg(string(line))
parsemsg(&msg, foo)
if msg.retmsg != "" {
sendmsg(foo.conn, msg.channel, msg.retmsg)
}
}
} ()
return c