Skip to content

Commit

Permalink
Use . for private messages
Browse files Browse the repository at this point in the history
  • Loading branch information
bahner committed Apr 12, 2024
1 parent 87f8ac5 commit 9665b79
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
8 changes: 4 additions & 4 deletions entity/actor/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ var ErrInvalidDotContentType = fmt.Errorf("actor: invalid content type for dot m
func (a *Actor) defaultMessageHandler(m *msg.Message) error {

switch m.Type {
case msg.DOT:
return a.handleDotMessage(m)
case msg.AT:
return a.handleAtMessage(m)
default:
return msg.ErrInvalidType
}
}

func (a *Actor) handleDotMessage(m *msg.Message) error {
func (a *Actor) handleAtMessage(m *msg.Message) error {

// Only receive messages with default content type
if m.ContentType != msg.DEFAULT_CONTENT_TYPE {
Expand All @@ -28,7 +28,7 @@ func (a *Actor) handleDotMessage(m *msg.Message) error {

var cmd string

msgStr := strings.TrimPrefix(string(m.Content), ".")
msgStr := strings.TrimPrefix(string(m.Content), "@")
elements := strings.Split(msgStr, " ")

if len(elements) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22
require (
github.com/adrg/xdg v0.4.0
github.com/ayush6624/go-chatgpt v0.3.0
github.com/bahner/go-ma v0.7.7-0.20240412234107-a34c2121822d
github.com/bahner/go-ma v0.7.7-0.20240412235320-63dbdd4090f2
github.com/ergo-services/ergo v1.999.224
github.com/fsnotify/fsnotify v1.7.0
github.com/fxamacker/cbor/v2 v2.6.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ github.com/bahner/go-ma v0.7.7-0.20240412233014-cca9fc3aa0a4 h1:a/3zg7XWrAhreCPd
github.com/bahner/go-ma v0.7.7-0.20240412233014-cca9fc3aa0a4/go.mod h1:IgMPcdPzH1GkP5mMz2PhJh8831hGi4TzhYbOV8UFzZ0=
github.com/bahner/go-ma v0.7.7-0.20240412234107-a34c2121822d h1:6b3kZiRDZFBaXtBPkD3M1OfR3ZF5buVEmSGJ+XjOvnQ=
github.com/bahner/go-ma v0.7.7-0.20240412234107-a34c2121822d/go.mod h1:IgMPcdPzH1GkP5mMz2PhJh8831hGi4TzhYbOV8UFzZ0=
github.com/bahner/go-ma v0.7.7-0.20240412235320-63dbdd4090f2 h1:3rpxKmh+r7BriXW7H12rUkAAA92febakwqJFQwNpxaM=
github.com/bahner/go-ma v0.7.7-0.20240412235320-63dbdd4090f2/go.mod h1:IgMPcdPzH1GkP5mMz2PhJh8831hGi4TzhYbOV8UFzZ0=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o=
Expand Down
2 changes: 1 addition & 1 deletion ui/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (ui *ChatUI) displaySentPrivateMessage(cm *msg.Message) {
log.Debugf("entity lookup error: %s", err)
return
}
prompt := withColor("green", fmt.Sprintf("@%s:", e.Nick()))
prompt := withColor("green", fmt.Sprintf(".%s:", e.Nick()))
fmt.Fprintf(ui.msgW, "%s %s\n", prompt, string(cm.Content))
}

Expand Down
2 changes: 1 addition & 1 deletion ui/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (ui *ChatUI) handleEvents() {
ui.handleCommands(input)
continue
}
if strings.HasPrefix(input, "@") {
if strings.HasPrefix(input, ".") {
log.Debug("handleEvents got command: ", input)
ui.handleMsgCommand(input)
continue
Expand Down
4 changes: 2 additions & 2 deletions ui/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (ui *ChatUI) handleHelpCommands(args []string) {
ui.displayHelpText(helpText)
ui.displaySystemMessage("")
ui.displaySystemMessage("Available commands:")
ui.displaySystemMessage("/help @")
ui.displaySystemMessage("/help .")
ui.displaySystemMessage("/help '")
ui.displaySystemMessage("/help broadcast")
ui.displaySystemMessage("/help enter")
Expand All @@ -56,7 +56,7 @@ func (ui *ChatUI) handleHelpCommands(args []string) {
ui.displaySystemMessage("/help")
} else {
switch args[1] {
case "@":
case ".":
ui.handleHelpCommand(msgUsage, msgHelp)
case "'":
ui.handleHelpCommand(editorUsage, editorHelp)
Expand Down
2 changes: 1 addition & 1 deletion ui/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (ui *ChatUI) pushToHistory(line string) {
func appendToPersistentHistory(text string) error {

if !(strings.HasPrefix(text, "/") ||
strings.HasPrefix(text, "@")) {
strings.HasPrefix(text, ".")) {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions ui/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

const (
msgUsage = "/@<DID|NICK> <message>"
msgUsage = "/.<DID|NICK> <message>"
msgHelp = "Sends a private message directly the specified DID"
)

Expand All @@ -22,7 +22,7 @@ func (ui *ChatUI) handleMsgCommand(input string) {

if len(parts) == 2 {

recipient := parts[0][1:] // The recipient is the first argument, without the leading @
recipient := parts[0][1:] // The recipient is the first argument, without the leading .
if !did.IsValid(recipient) {
recipient = entity.Lookup(recipient)
}
Expand Down

0 comments on commit 9665b79

Please sign in to comment.