diff options
author | Hubert Hirtz <hubert@hirtz.pm> | 2021-05-18 12:16:13 +0200 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtz.pm> | 2021-05-18 12:17:12 +0200 |
commit | a0e0d6c3a7a93db7a3caec9c2fd3ecaab47d31a8 (patch) | |
tree | 3e201e0b7ce741cd2823fc9d251e9b73056f5d66 /commands.go | |
parent | Add port if missing (v2) and don't set keepalives (diff) |
Add /nick
Diffstat (limited to 'commands.go')
-rw-r--r-- | commands.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/commands.go b/commands.go index 621b034..9bf2f13 100644 --- a/commands.go +++ b/commands.go @@ -64,6 +64,14 @@ func init() { Desc: "show the member list of the current channel", Handle: commandDoNames, }, + "NICK": { + AllowHome: true, + MinArgs: 1, + MaxArgs: 1, + Usage: "<nickname>", + Desc: "change your nickname", + Handle: commandDoNick, + }, "PART": { AllowHome: true, MaxArgs: 2, @@ -250,6 +258,15 @@ func commandDoNames(app *App, buffer string, args []string) (err error) { return } +func commandDoNick(app *App, buffer string, args []string) (err error) { + nick := args[0] + if i := strings.IndexAny(nick, " :@!*?"); i >= 0 { + return fmt.Errorf("illegal char %q in nickname", nick[i]) + } + app.s.ChangeNick(nick) + return +} + func commandDoPart(app *App, buffer string, args []string) (err error) { channel := buffer reason := "" |