|
@@ -57,6 +57,10 @@ type IRCConfig struct {
|
|
|
AutoJoin []string `json: AutoJoin`
|
|
|
RejoinDelay int `json: RejoinDelay`
|
|
|
Version string `json: Version`
|
|
|
+ Flood_Num int `json: FloodNum`
|
|
|
+ Flood_Time int `json: FloodTime`
|
|
|
+ Flood_Delay int `json: FloodDelay`
|
|
|
+ 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
|
|
|
- Flood_Time int
|
|
|
- Flood_Delay int
|
|
|
+ ISupport map[string]string
|
|
|
wg sync.WaitGroup
|
|
|
}
|
|
|
|
|
@@ -134,6 +136,7 @@ func (Config *IRCConfig) Connect() bool {
|
|
|
|
|
|
Config.WriteChannel = make(chan IRCWrite, 3)
|
|
|
Config.DelChannel = make(chan string)
|
|
|
+ Config.ISupport = make(map[string]string)
|
|
|
|
|
|
|
|
|
go Config.WriterRoutine()
|
|
@@ -162,7 +165,9 @@ func (Config *IRCConfig) Connect() bool {
|
|
|
|
|
|
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() {
|
|
|
|
|
|
|
|
|
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() {
|
|
|
|
|
|
|
|
|
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" {
|
|
|
+
|
|
|
+ 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 {
|
|
|
|
|
|
|