mirror of
https://github.com/IllusionMan1212/gorc.git
synced 2026-10-24 02:12:33 +00:00
feat: handle more commands and properly implement older ones
* fix parser tests * write logs to file * gracefully terminate program * make viewport follow output * properly handle channel nicks and display them in the sidepanel * general refactors and fixes
This commit is contained in:
+23
-11
@@ -17,6 +17,7 @@
|
||||
package mainscreen
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
@@ -26,19 +27,18 @@ import (
|
||||
|
||||
func (s *State) ReadLoop() {
|
||||
for {
|
||||
select {
|
||||
case <-s.Client.Quit:
|
||||
msg, err := s.ConnReader.ReadString('\n')
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
log.Println(err)
|
||||
}
|
||||
s.Client.TcpConn.Close()
|
||||
return
|
||||
default:
|
||||
msg, err := s.ConnReader.ReadString('\n')
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
msg = strings.Replace(msg, "\r\n", "", 1)
|
||||
if ircMessage, valid := parser.ParseIRCMessage(msg); valid {
|
||||
s.HandleCommand(ircMessage)
|
||||
}
|
||||
msg = strings.Replace(msg, "\r\n", "", 1)
|
||||
if ircMessage, valid := parser.ParseIRCMessage(msg); valid {
|
||||
s.HandleCommand(ircMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,3 +52,15 @@ func (s InputState) SendingPrivMsg(msg string) tea.Cmd {
|
||||
return SendPrivMsg{Msg: msg}
|
||||
}
|
||||
}
|
||||
|
||||
type ReceivedIRCMsgMsg struct{}
|
||||
|
||||
func ReceivedIRCMsg() tea.Msg {
|
||||
return ReceivedIRCMsgMsg{}
|
||||
}
|
||||
|
||||
type SwitchChannelsMsg struct{}
|
||||
|
||||
func SwitchChannels() tea.Msg {
|
||||
return SwitchChannelsMsg{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user