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:
2022-01-15 21:56:06 +02:00
parent 8a7e1568ae
commit 22d5e39899
15 changed files with 487 additions and 181 deletions
+23 -11
View File
@@ -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{}
}