|
@@ -57,6 +57,10 @@ type IRCConfig struct {
|
|
|
AutoJoin []string `json: AutoJoin` // Channels to auto-join
|
|
|
RejoinDelay int `json: RejoinDelay` // ms to rejoin
|
|
|
Version string `json: Version` // Version displayed
|
|
|
+ Flood_Num int `json: FloodNum` // Number of lines sent before considered a flood
|
|
|
+ Flood_Time int `json: FloodTime` // Number of Seconds to track previous messages
|
|
|
+ Flood_Delay int `json: FloodDelay` // Delay between sending when flood protection on (Milliseconds)
|
|
|
+ Debug_Output bool `json: Debug`
|
|
|
MyNick string
|
|
|
OnExit func()
|
|
|
Socket net.Conn
|
|
@@ -66,9 +70,7 @@ type IRCConfig struct {
|
|
|
WriteChannel chan IRCWrite
|
|
|
DelChannel chan string
|
|
|
Registered bool
|
|
|
- Flood_Num int // Number of lines sent before considered a flood
|
|
|
- Flood_Time int // Number of Seconds to track previous messages
|
|
|
- Flood_Delay int // Delay between sending when flood protection on (Milliseconds)
|
|
|
+ ISupport map[string]string // 005
|
|
|
wg sync.WaitGroup
|
|
|
}
|
|
|
|
|
@@ -134,6 +136,7 @@ func (Config *IRCConfig) Connect() bool {
|
|
|
// WriteChannel may contain a message when we're trying to PriorityWrite from sigChannel.
|
|
|
Config.WriteChannel = make(chan IRCWrite, 3)
|
|
|
Config.DelChannel = make(chan string)
|
|
|
+ Config.ISupport = make(map[string]string)
|
|
|
|
|
|
// We are connected.
|
|
|
go Config.WriterRoutine()
|
|
@@ -162,7 +165,9 @@ func (Config *IRCConfig) Connect() bool {
|
|
|
// Low level write to [TLS]Socket routine.
|
|
|
func (Config *IRCConfig) write(output string) error {
|
|
|
var err error
|
|
|
- log.Println(">>", output)
|
|
|
+ if Config.Debug_Output {
|
|
|
+ log.Println(">>", output)
|
|
|
+ }
|
|
|
output += "\r\n"
|
|
|
/*
|
|
|
if Config.UseTLS {
|
|
@@ -224,7 +229,9 @@ func (Config *IRCConfig) WriterRoutine() {
|
|
|
//os.Exit(2)
|
|
|
|
|
|
case remove := <-Config.DelChannel:
|
|
|
- log.Printf("Remove: [%s]\n", remove)
|
|
|
+ if Config.Debug_Output {
|
|
|
+ log.Printf("Remove: [%s]\n", remove)
|
|
|
+ }
|
|
|
throttle.delete(remove)
|
|
|
|
|
|
case <-time.After(time.Millisecond * time.Duration(Config.Flood_Delay)):
|
|
@@ -259,7 +266,9 @@ func (Config *IRCConfig) WriterRoutine() {
|
|
|
// os.Exit(2)
|
|
|
|
|
|
case remove := <-Config.DelChannel:
|
|
|
- log.Printf("Remove: [%s]\n", remove)
|
|
|
+ if Config.Debug_Output {
|
|
|
+ log.Printf("Remove: [%s]\n", remove)
|
|
|
+ }
|
|
|
throttle.delete(remove)
|
|
|
|
|
|
case output := <-Config.WriteChannel:
|
|
@@ -361,7 +370,9 @@ func (Config *IRCConfig) ReaderRoutine() {
|
|
|
line, err = Config.Reader.ReadString('\n')
|
|
|
if err == nil {
|
|
|
line = strings.Trim(line, "\r\n")
|
|
|
- log.Println("<<", line)
|
|
|
+ if Config.Debug_Output {
|
|
|
+ log.Println("<<", line)
|
|
|
+ }
|
|
|
|
|
|
results = IRCParse(line)
|
|
|
|
|
@@ -427,6 +438,7 @@ func (Config *IRCConfig) ReaderRoutine() {
|
|
|
close(Config.ReadChannel)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
var msg IRCMsg = IRCMsg{MsgParts: results}
|
|
|
if len(results) >= 3 {
|
|
|
msg.From = IRCNick(results[0])
|
|
@@ -450,6 +462,19 @@ func (Config *IRCConfig) ReaderRoutine() {
|
|
|
Config.DelChannel <- msg.MsgParts[3]
|
|
|
}
|
|
|
|
|
|
+ if msg.Cmd == "005" {
|
|
|
+ // ISUPPORT msg.MsgParts[3:len(msg.MsgParts)-1]
|
|
|
+ var support string
|
|
|
+ for _, support = range msg.MsgParts[3 : len(msg.MsgParts)-1] {
|
|
|
+ if strings.Contains(support, "=") {
|
|
|
+ var suppart []string = strings.Split(support, "=")
|
|
|
+ Config.ISupport[suppart[0]] = suppart[1]
|
|
|
+ } else {
|
|
|
+ Config.ISupport[support] = ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if !Config.Registered {
|
|
|
// We're not registered yet
|
|
|
|