mirror of
https://github.com/IllusionMan1212/gorc.git
synced 2026-10-24 02:12:33 +00:00
irc: NOT IMPL -> UNIMPL; red color for error messages; deduplicate some code
This commit is contained in:
+21
-15
@@ -101,13 +101,17 @@ type Capabilities map[string]string
|
|||||||
|
|
||||||
type MsgFmtOpts struct {
|
type MsgFmtOpts struct {
|
||||||
WithTimestamp bool
|
WithTimestamp bool
|
||||||
AsServerMsg bool
|
// TODO: make these a bitset? they should compliment eachother instead of conflicting or rendering twice.
|
||||||
NotImpl bool
|
AsServerMsg bool
|
||||||
AsDate bool
|
AsErrorMsg bool
|
||||||
|
|
||||||
|
NotImpl bool
|
||||||
|
AsDate bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var notImpl = lipgloss.NewStyle().Foreground(ui.ErrorColor).Render("[NOT IMPL]")
|
var unimpl = lipgloss.NewStyle().Foreground(ui.ErrorColor).Render("[UNIMPL]")
|
||||||
var serverMsgStyle = lipgloss.NewStyle().Foreground(ui.ServerMsgColor)
|
var serverMsgStyle = lipgloss.NewStyle().Foreground(ui.ServerMsgColor)
|
||||||
|
var errorMsgStyle = lipgloss.NewStyle().Foreground(ui.ErrorColor)
|
||||||
var timestampStyle = serverMsgStyle
|
var timestampStyle = serverMsgStyle
|
||||||
var dateStyle = lipgloss.NewStyle().Foreground(ui.DateColor)
|
var dateStyle = lipgloss.NewStyle().Foreground(ui.DateColor)
|
||||||
|
|
||||||
@@ -136,7 +140,7 @@ func (c *Channel) AppendMsg(timestamp string, fullMsg string, opts MsgFmtOpts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if opts.NotImpl {
|
if opts.NotImpl {
|
||||||
prefixes += notImpl + " "
|
prefixes += unimpl + " "
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.AsServerMsg {
|
if opts.AsServerMsg {
|
||||||
@@ -144,6 +148,11 @@ func (c *Channel) AppendMsg(timestamp string, fullMsg string, opts MsgFmtOpts) {
|
|||||||
style = serverMsgStyle
|
style = serverMsgStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opts.AsErrorMsg {
|
||||||
|
prefixes += errorMsgStyle.Render("==") + " "
|
||||||
|
style = errorMsgStyle
|
||||||
|
}
|
||||||
|
|
||||||
if opts.AsDate {
|
if opts.AsDate {
|
||||||
style = dateStyle
|
style = dateStyle
|
||||||
}
|
}
|
||||||
@@ -154,6 +163,13 @@ func (c *Channel) AppendMsg(timestamp string, fullMsg string, opts MsgFmtOpts) {
|
|||||||
func (c *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)
|
addr := fmt.Sprintf("%s:%s", host, port)
|
||||||
|
|
||||||
|
c.Host = host
|
||||||
|
c.Port = port
|
||||||
|
c.ActiveChannel = host
|
||||||
|
c.Channels = make([]Channel, 0)
|
||||||
|
c.EnabledCapabilities = make(Capabilities, 0)
|
||||||
|
c.EnabledFeatures = make(Features, 0)
|
||||||
|
|
||||||
if tlsEnabled {
|
if tlsEnabled {
|
||||||
cfg := &tls.Config{ServerName: host}
|
cfg := &tls.Config{ServerName: host}
|
||||||
conn, err := tls.Dial("tcp", addr, cfg)
|
conn, err := tls.Dial("tcp", addr, cfg)
|
||||||
@@ -163,11 +179,6 @@ func (c *Client) Initialize(host string, port string, tlsEnabled bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.TCPConn = conn
|
c.TCPConn = conn
|
||||||
c.Host = host
|
|
||||||
c.Port = port
|
|
||||||
c.ActiveChannel = host
|
|
||||||
c.Channels = make([]Channel, 0)
|
|
||||||
c.EnabledCapabilities = make(Capabilities, 0)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,11 +193,6 @@ func (c *Client) Initialize(host string, port string, tlsEnabled bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.TCPConn = conn
|
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) {
|
func (c *Client) Register(nick string, password string, channel string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user