Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion plugins/urban.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import (

type Urban struct{}

// Keep the Urban Dictionary marker to the base code point so terminal clients
// do not have to interpret the optional emoji presentation selector U+FE0F.
const urbanPrefix = "🗣"

func (p *Urban) Name() string { return "urban" }
func (p *Urban) Commands() []string { return []string{"urban", "u", "ud"} }
func (p *Urban) Help() string {
Expand Down Expand Up @@ -64,7 +68,7 @@ func (p *Urban) Handle(b *bot.Bot, m bot.Message) bool {
if definition == "" {
definition = "(empty definition)"
}
b.Send(m.ReplyTarget(), fmt.Sprintf("🗣️ %s [%d/%d]: %s — %s", cleanExternalText(entry.Word), index, len(data.List), definition, cleanExternalText(entry.Permalink)))
b.Send(m.ReplyTarget(), fmt.Sprintf("%s %s [%d/%d]: %s — %s", urbanPrefix, cleanExternalText(entry.Word), index, len(data.List), definition, cleanExternalText(entry.Permalink)))
return true
}

Expand Down
6 changes: 6 additions & 0 deletions plugins/urban_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ func TestUrbanArgs(t *testing.T) {
}
}

func TestUrbanPrefixHasNoEmojiVariationSelector(t *testing.T) {
if urbanPrefix != "\U0001F5E3" {
t.Fatalf("urbanPrefix = %q, want only U+1F5E3 without U+FE0F", urbanPrefix)
}
}

func TestCleanExternalText(t *testing.T) {
got := cleanExternalText("hello\x02 world\r\nagain")
if got != "hello worldagain" {
Expand Down