summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/irc/main.go8
-rw-r--r--irc/states.go9
2 files changed, 15 insertions, 2 deletions
diff --git a/cmd/irc/main.go b/cmd/irc/main.go
index 51a6b0a..6245793 100644
--- a/cmd/irc/main.go
+++ b/cmd/irc/main.go
@@ -188,7 +188,7 @@ func handleUIEvent(app *ui.UI, s *irc.Session, ev tcell.Event) {
case tcell.KeyEnter:
buffer := app.CurrentBuffer()
input := app.InputEnter()
- handleInput(s, buffer, input)
+ handleInput(app, s, buffer, input)
case tcell.KeyRune:
app.InputRune(ev.Rune())
if app.CurrentBuffer() != "home" && !strings.HasPrefix(app.Input(), "/") {
@@ -219,7 +219,7 @@ func parseCommand(s string) (command, args string) {
return
}
-func handleInput(s *irc.Session, buffer, content string) {
+func handleInput(app *ui.UI, s *irc.Session, buffer, content string) {
cmd, args := parseCommand(content)
switch cmd {
@@ -229,6 +229,10 @@ func handleInput(s *irc.Session, buffer, content string) {
}
s.PrivMsg(buffer, args)
+ if !s.HasCapability("echo-message") {
+ line := formatIRCMessage(s.Nick(), args)
+ app.AddLine(buffer, line, time.Now(), false)
+ }
case "QUOTE":
s.SendRaw(args)
case "J", "JOIN":
diff --git a/irc/states.go b/irc/states.go
index 28fabb7..8f16d95 100644
--- a/irc/states.go
+++ b/irc/states.go
@@ -220,6 +220,15 @@ func (s *Session) Poll() (events <-chan Event) {
return s.evts
}
+func (s *Session) HasCapability(capability string) bool {
+ _, ok := s.enabledCaps[capability]
+ return ok
+}
+
+func (s *Session) Nick() string {
+ return s.nick
+}
+
func (s *Session) IsChannel(name string) bool {
return strings.IndexAny(name, "#&") == 0 // TODO compute CHANTYPES
}