chore: upgrade dependencies. remove deprecated code. conform to linter style

This commit is contained in:
2025-08-11 22:51:50 +02:00
parent bfe490cd5c
commit e24201c204
15 changed files with 133 additions and 142 deletions
+17 -17
View File
@@ -54,7 +54,7 @@ type Channel struct {
type Client struct {
// tcp connection
TcpConn net.Conn
TCPConn net.Conn
// Host that client is connected to
Host string
@@ -98,7 +98,7 @@ type MsgFmtOpts struct {
var notImpl = lipgloss.NewStyle().Foreground(ui.ErrorColor).Render("[NOT IMPL]")
var serverMsgStyle = lipgloss.NewStyle().Foreground(ui.ServerMsgColor)
var timestampStyle = serverMsgStyle.Copy()
var timestampStyle = serverMsgStyle
var dateStyle = lipgloss.NewStyle().Foreground(ui.DateColor)
const CRLF = "\r\n"
@@ -127,7 +127,7 @@ func (c *Channel) AppendMsg(timestamp string, fullMsg string, opts MsgFmtOpts) {
c.History += prefixes + style.Render(fullMsg) + CRLF
}
func (s *Client) Initialize(host string, port string, tlsEnabled bool) {
func (c *Client) Initialize(host string, port string, tlsEnabled bool) {
addr := fmt.Sprintf("%s:%s", host, port)
if tlsEnabled {
@@ -138,12 +138,12 @@ func (s *Client) Initialize(host string, port string, tlsEnabled bool) {
log.Fatal(err)
}
s.TcpConn = conn
s.Host = host
s.Port = port
s.ActiveChannel = host
s.Channels = make([]Channel, 0)
s.EnabledCapabilities = make(Capabilities, 0)
c.TCPConn = conn
c.Host = host
c.Port = port
c.ActiveChannel = host
c.Channels = make([]Channel, 0)
c.EnabledCapabilities = make(Capabilities, 0)
return
}
@@ -157,12 +157,12 @@ func (s *Client) Initialize(host string, port string, tlsEnabled bool) {
log.Fatal(err)
}
s.TcpConn = conn
s.Host = host
s.Port = port
s.ActiveChannel = host
s.Channels = make([]Channel, 0)
s.EnabledCapabilities = make(Capabilities, 0)
c.TCPConn = conn
c.Host = host
c.Port = port
c.ActiveChannel = host
c.Channels = make([]Channel, 0)
c.EnabledCapabilities = make(Capabilities, 0)
}
func (c *Client) Register(nick string, password string, channel string) {
@@ -198,7 +198,7 @@ func (c *Client) SetDay() {
}
func (c Client) SendCommand(cmd string, params ...string) {
if c.TcpConn == nil {
if c.TCPConn == nil {
// TODO: properly handle the error instead of Fatal-ing
log.Fatal("Attempted to write data to nil connection")
}
@@ -229,5 +229,5 @@ func (c Client) SendCommand(cmd string, params ...string) {
}
}
c.TcpConn.Write([]byte(cmd + paramsString + CRLF))
c.TCPConn.Write([]byte(cmd + paramsString + CRLF))
}
+5 -3
View File
@@ -25,6 +25,8 @@ import (
"strings"
"time"
"slices"
"github.com/illusionman1212/gorc/cmds"
"github.com/illusionman1212/gorc/irc"
"github.com/illusionman1212/gorc/irc/commands"
@@ -33,7 +35,7 @@ import (
func ReadLoop(client *irc.Client) {
// 512 bytes as a base + 8192 additional bytes for tags
r := bufio.NewReaderSize(client.TcpConn, 8192+512)
r := bufio.NewReaderSize(client.TCPConn, 8192+512)
for {
msg, err := r.ReadString('\n')
@@ -41,7 +43,7 @@ func ReadLoop(client *irc.Client) {
if err != io.EOF {
log.Println(err)
}
client.TcpConn.Close()
client.TCPConn.Close()
return
}
@@ -153,7 +155,7 @@ func handlePart(msg parser.IRCMessage, client *irc.Client) {
for i, c := range client.Channels {
if c.Name == channel {
if nick == client.Nickname {
client.Channels = append(client.Channels[:i], client.Channels[i+1:]...)
client.Channels = slices.Delete(client.Channels, i, i+1)
if client.ActiveChannelIndex >= i {
client.ActiveChannelIndex--
client.ActiveChannel = client.Channels[client.ActiveChannelIndex].Name
+3 -3
View File
@@ -115,9 +115,9 @@ func parseTags(rawTags string) Tags {
func ParseIRCMessage(line string) (IRCMessage, bool) {
ircMessage := IRCMessage{}
multipleSpacesRegex := regexp.MustCompile("[^\\S\\t]+")
trailingParamRegex := regexp.MustCompile("[^\\S\\t]+:")
whitespaceRegex := regexp.MustCompile("^[^\\S\\t]+$")
multipleSpacesRegex := regexp.MustCompile(`[^\S\t]+`)
trailingParamRegex := regexp.MustCompile(`[^\S\t]+:`)
whitespaceRegex := regexp.MustCompile(`^[^\S\t]+$`)
if len(line) <= 0 {
// TODO: do something here ???