2012-04-18 03:16:57 +02:00
|
|
|
package irc
|
|
|
|
|
2012-12-09 21:51:50 +01:00
|
|
|
import (
|
|
|
|
"errors"
|
2013-05-11 22:55:01 +02:00
|
|
|
"fmt"
|
2012-12-09 21:51:50 +01:00
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2013-05-09 20:05:10 +02:00
|
|
|
type Command interface {
|
|
|
|
Client() *Client
|
2013-05-12 03:28:18 +02:00
|
|
|
Source() Identifier
|
2013-05-09 20:05:10 +02:00
|
|
|
HandleServer(*Server)
|
2012-12-13 08:27:17 +01:00
|
|
|
}
|
|
|
|
|
2013-05-09 18:12:03 +02:00
|
|
|
type EditableCommand interface {
|
|
|
|
Command
|
|
|
|
SetClient(*Client)
|
|
|
|
}
|
|
|
|
|
2012-12-17 04:13:53 +01:00
|
|
|
var (
|
2013-05-09 20:05:10 +02:00
|
|
|
NotEnoughArgsError = errors.New("not enough arguments")
|
|
|
|
ErrParseCommand = errors.New("failed to parse message")
|
|
|
|
parseCommandFuncs = map[string]func([]string) (EditableCommand, error){
|
2012-12-17 04:13:53 +01:00
|
|
|
"JOIN": NewJoinCommand,
|
|
|
|
"MODE": NewModeCommand,
|
|
|
|
"NICK": NewNickCommand,
|
|
|
|
"PART": NewPartCommand,
|
|
|
|
"PASS": NewPassCommand,
|
|
|
|
"PING": NewPingCommand,
|
|
|
|
"PONG": NewPongCommand,
|
|
|
|
"PRIVMSG": NewPrivMsgCommand,
|
|
|
|
"QUIT": NewQuitCommand,
|
|
|
|
"TOPIC": NewTopicCommand,
|
|
|
|
"USER": NewUserMsgCommand,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2013-05-09 20:05:10 +02:00
|
|
|
type BaseCommand struct {
|
|
|
|
client *Client
|
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (command *BaseCommand) Client() *Client {
|
2013-05-11 22:55:01 +02:00
|
|
|
return command.client
|
2013-05-09 20:05:10 +02:00
|
|
|
}
|
|
|
|
|
2013-05-11 22:55:01 +02:00
|
|
|
func (command *BaseCommand) SetClient(c *Client) {
|
|
|
|
command.client = c
|
2013-05-09 20:05:10 +02:00
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (command *BaseCommand) Source() Identifier {
|
|
|
|
client := command.Client()
|
|
|
|
if client == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if client.user != nil {
|
|
|
|
return client.user
|
|
|
|
}
|
|
|
|
return client
|
|
|
|
}
|
|
|
|
|
2013-05-09 18:12:03 +02:00
|
|
|
func ParseCommand(line string) (EditableCommand, error) {
|
2012-12-17 04:13:53 +01:00
|
|
|
command, args := parseLine(line)
|
|
|
|
constructor := parseCommandFuncs[command]
|
|
|
|
if constructor == nil {
|
|
|
|
return NewUnknownCommand(command, args), nil
|
|
|
|
}
|
|
|
|
return constructor(args)
|
|
|
|
}
|
|
|
|
|
|
|
|
func parseArg(line string) (arg string, rest string) {
|
|
|
|
if line == "" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if strings.HasPrefix(line, ":") {
|
|
|
|
arg = line[1:]
|
|
|
|
} else {
|
|
|
|
parts := strings.SplitN(line, " ", 2)
|
|
|
|
arg = parts[0]
|
|
|
|
if len(parts) > 1 {
|
|
|
|
rest = parts[1]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func parseLine(line string) (command string, args []string) {
|
|
|
|
args = make([]string, 0)
|
|
|
|
for arg, rest := parseArg(line); arg != ""; arg, rest = parseArg(rest) {
|
|
|
|
args = append(args, arg)
|
|
|
|
}
|
|
|
|
command, args = strings.ToUpper(args[0]), args[1:]
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// <command> [args...]
|
2012-12-09 07:54:58 +01:00
|
|
|
|
2012-12-15 23:34:20 +01:00
|
|
|
type UnknownCommand struct {
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand
|
2012-12-09 07:54:58 +01:00
|
|
|
command string
|
2012-12-12 07:34:22 +01:00
|
|
|
args []string
|
2012-12-09 07:54:58 +01:00
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (cmd *UnknownCommand) String() string {
|
|
|
|
return fmt.Sprintf("UNKNOWN(command=%s, args=%s)", cmd.command, cmd.args)
|
|
|
|
}
|
|
|
|
|
2012-12-17 04:13:53 +01:00
|
|
|
func NewUnknownCommand(command string, args []string) *UnknownCommand {
|
2012-12-15 23:34:20 +01:00
|
|
|
return &UnknownCommand{
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand: BaseCommand{},
|
2012-12-15 23:34:20 +01:00
|
|
|
command: command,
|
|
|
|
args: args,
|
|
|
|
}
|
|
|
|
}
|
2012-12-09 21:51:50 +01:00
|
|
|
|
2012-12-13 08:27:17 +01:00
|
|
|
// PING <server1> [ <server2> ]
|
2012-12-09 07:54:58 +01:00
|
|
|
|
2012-12-15 23:34:20 +01:00
|
|
|
type PingCommand struct {
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand
|
2012-12-09 07:54:58 +01:00
|
|
|
server string
|
|
|
|
server2 string
|
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (cmd *PingCommand) String() string {
|
2013-05-11 22:55:01 +02:00
|
|
|
return fmt.Sprintf("PING(server=%s, server2=%s)", cmd.server, cmd.server2)
|
|
|
|
}
|
|
|
|
|
2013-05-09 18:12:03 +02:00
|
|
|
func NewPingCommand(args []string) (EditableCommand, error) {
|
2012-12-09 21:51:50 +01:00
|
|
|
if len(args) < 1 {
|
2012-12-10 05:24:53 +01:00
|
|
|
return nil, NotEnoughArgsError
|
2012-12-09 21:51:50 +01:00
|
|
|
}
|
2012-12-15 23:34:20 +01:00
|
|
|
msg := &PingCommand{
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand: BaseCommand{},
|
2012-12-13 08:27:17 +01:00
|
|
|
server: args[0],
|
|
|
|
}
|
2012-12-09 21:51:50 +01:00
|
|
|
if len(args) > 1 {
|
|
|
|
msg.server2 = args[1]
|
|
|
|
}
|
|
|
|
return msg, nil
|
|
|
|
}
|
|
|
|
|
2012-12-13 08:27:17 +01:00
|
|
|
// PONG <server> [ <server2> ]
|
2012-12-09 07:54:58 +01:00
|
|
|
|
2012-12-15 23:34:20 +01:00
|
|
|
type PongCommand struct {
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand
|
2012-12-09 07:54:58 +01:00
|
|
|
server1 string
|
|
|
|
server2 string
|
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (cmd *PongCommand) String() string {
|
2013-05-11 22:55:01 +02:00
|
|
|
return fmt.Sprintf("PONG(server1=%s, server2=%s)", cmd.server1, cmd.server2)
|
|
|
|
}
|
|
|
|
|
2013-05-09 18:12:03 +02:00
|
|
|
func NewPongCommand(args []string) (EditableCommand, error) {
|
2012-12-09 21:51:50 +01:00
|
|
|
if len(args) < 1 {
|
2012-12-10 05:24:53 +01:00
|
|
|
return nil, NotEnoughArgsError
|
2012-12-09 21:51:50 +01:00
|
|
|
}
|
2012-12-15 23:34:20 +01:00
|
|
|
message := &PongCommand{
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand: BaseCommand{},
|
2012-12-15 23:34:20 +01:00
|
|
|
server1: args[0],
|
|
|
|
}
|
2012-12-09 21:51:50 +01:00
|
|
|
if len(args) > 1 {
|
|
|
|
message.server2 = args[1]
|
|
|
|
}
|
|
|
|
return message, nil
|
|
|
|
}
|
|
|
|
|
2012-12-10 05:24:53 +01:00
|
|
|
// PASS <password>
|
|
|
|
|
2012-12-15 23:34:20 +01:00
|
|
|
type PassCommand struct {
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand
|
2012-12-10 05:24:53 +01:00
|
|
|
password string
|
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (cmd *PassCommand) String() string {
|
|
|
|
return fmt.Sprintf("PASS(password=%s)", cmd.password)
|
|
|
|
}
|
|
|
|
|
2013-05-09 18:12:03 +02:00
|
|
|
func NewPassCommand(args []string) (EditableCommand, error) {
|
2012-12-10 05:24:53 +01:00
|
|
|
if len(args) < 1 {
|
|
|
|
return nil, NotEnoughArgsError
|
|
|
|
}
|
2012-12-15 23:34:20 +01:00
|
|
|
return &PassCommand{
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand: BaseCommand{},
|
2012-12-13 08:27:17 +01:00
|
|
|
password: args[0],
|
2012-12-12 07:34:22 +01:00
|
|
|
}, nil
|
2012-12-10 05:24:53 +01:00
|
|
|
}
|
|
|
|
|
2012-12-13 08:27:17 +01:00
|
|
|
// NICK <nickname>
|
2012-12-09 07:54:58 +01:00
|
|
|
|
2012-12-15 23:34:20 +01:00
|
|
|
type NickCommand struct {
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand
|
2012-12-09 07:54:58 +01:00
|
|
|
nickname string
|
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (m *NickCommand) String() string {
|
2013-05-11 22:55:01 +02:00
|
|
|
return fmt.Sprintf("NICK(nickname=%s)", m.nickname)
|
|
|
|
}
|
|
|
|
|
2013-05-09 18:12:03 +02:00
|
|
|
func NewNickCommand(args []string) (EditableCommand, error) {
|
2012-12-09 21:51:50 +01:00
|
|
|
if len(args) != 1 {
|
2012-12-10 05:24:53 +01:00
|
|
|
return nil, NotEnoughArgsError
|
2012-12-09 21:51:50 +01:00
|
|
|
}
|
2012-12-15 23:34:20 +01:00
|
|
|
return &NickCommand{
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand: BaseCommand{},
|
2012-12-13 08:27:17 +01:00
|
|
|
nickname: args[0],
|
|
|
|
}, nil
|
2012-12-09 21:51:50 +01:00
|
|
|
}
|
|
|
|
|
2012-12-13 08:27:17 +01:00
|
|
|
// USER <user> <mode> <unused> <realname>
|
2012-12-09 07:54:58 +01:00
|
|
|
|
2012-12-17 04:13:53 +01:00
|
|
|
type UserMsgCommand struct {
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand
|
2012-12-09 07:54:58 +01:00
|
|
|
user string
|
|
|
|
mode uint8
|
|
|
|
unused string
|
|
|
|
realname string
|
2012-04-18 03:16:57 +02:00
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (cmd *UserMsgCommand) String() string {
|
2013-05-11 22:55:01 +02:00
|
|
|
return fmt.Sprintf("USER(user=%s, mode=%o, unused=%s, realname=%s)",
|
|
|
|
cmd.user, cmd.mode, cmd.unused, cmd.realname)
|
|
|
|
}
|
|
|
|
|
2013-05-09 18:12:03 +02:00
|
|
|
func NewUserMsgCommand(args []string) (EditableCommand, error) {
|
2012-12-09 21:51:50 +01:00
|
|
|
if len(args) != 4 {
|
2012-12-10 05:24:53 +01:00
|
|
|
return nil, NotEnoughArgsError
|
2012-12-09 21:51:50 +01:00
|
|
|
}
|
2012-12-17 04:13:53 +01:00
|
|
|
msg := &UserMsgCommand{
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand: BaseCommand{},
|
2012-12-13 08:27:17 +01:00
|
|
|
user: args[0],
|
|
|
|
unused: args[2],
|
|
|
|
realname: args[3],
|
2012-12-09 21:51:50 +01:00
|
|
|
}
|
|
|
|
mode, err := strconv.ParseUint(args[1], 10, 8)
|
|
|
|
if err == nil {
|
|
|
|
msg.mode = uint8(mode)
|
|
|
|
}
|
|
|
|
return msg, nil
|
|
|
|
}
|
|
|
|
|
2012-12-15 23:34:20 +01:00
|
|
|
// QUIT [ <Quit Command> ]
|
2012-04-18 03:16:57 +02:00
|
|
|
|
2012-12-15 23:34:20 +01:00
|
|
|
type QuitCommand struct {
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand
|
2012-12-09 07:54:58 +01:00
|
|
|
message string
|
2012-04-18 03:16:57 +02:00
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (cmd *QuitCommand) String() string {
|
2013-05-11 22:55:01 +02:00
|
|
|
return fmt.Sprintf("QUIT(message=%s)", cmd.message)
|
|
|
|
}
|
|
|
|
|
2013-05-09 18:12:03 +02:00
|
|
|
func NewQuitCommand(args []string) (EditableCommand, error) {
|
2012-12-15 23:34:20 +01:00
|
|
|
msg := &QuitCommand{
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand: BaseCommand{},
|
2012-12-13 08:27:17 +01:00
|
|
|
}
|
2012-12-09 21:51:50 +01:00
|
|
|
if len(args) > 0 {
|
|
|
|
msg.message = args[0]
|
|
|
|
}
|
|
|
|
return msg, nil
|
|
|
|
}
|
|
|
|
|
2012-12-10 05:24:53 +01:00
|
|
|
// JOIN ( <channel> *( "," <channel> ) [ <key> *( "," <key> ) ] ) / "0"
|
2012-12-09 07:54:58 +01:00
|
|
|
|
2012-12-15 23:34:20 +01:00
|
|
|
type JoinCommand struct {
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand
|
2012-12-17 04:13:53 +01:00
|
|
|
channels map[string]string
|
2012-12-09 07:54:58 +01:00
|
|
|
zero bool
|
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (cmd *JoinCommand) String() string {
|
|
|
|
return fmt.Sprintf("JOIN(channels=%s, zero=%t)", cmd.channels, cmd.zero)
|
|
|
|
}
|
|
|
|
|
2013-05-09 18:12:03 +02:00
|
|
|
func NewJoinCommand(args []string) (EditableCommand, error) {
|
2012-12-15 23:34:20 +01:00
|
|
|
msg := &JoinCommand{
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand: BaseCommand{},
|
2012-12-17 04:13:53 +01:00
|
|
|
channels: make(map[string]string),
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(args) == 0 {
|
|
|
|
return nil, NotEnoughArgsError
|
2012-12-13 08:27:17 +01:00
|
|
|
}
|
2012-12-09 21:51:50 +01:00
|
|
|
|
2012-12-17 04:13:53 +01:00
|
|
|
if args[0] == "0" {
|
|
|
|
msg.zero = true
|
|
|
|
return msg, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
channels := strings.Split(args[0], ",")
|
|
|
|
keys := make([]string, len(channels))
|
|
|
|
if len(args) > 1 {
|
|
|
|
for i, key := range strings.Split(args[1], ",") {
|
|
|
|
keys[i] = key
|
2012-12-09 21:51:50 +01:00
|
|
|
}
|
|
|
|
}
|
2012-12-17 04:13:53 +01:00
|
|
|
for i, channel := range channels {
|
|
|
|
msg.channels[channel] = keys[i]
|
|
|
|
}
|
|
|
|
|
2012-12-09 21:51:50 +01:00
|
|
|
return msg, nil
|
|
|
|
}
|
|
|
|
|
2012-12-15 23:34:20 +01:00
|
|
|
// PART <channel> *( "," <channel> ) [ <Part Command> ]
|
2012-12-09 07:54:58 +01:00
|
|
|
|
2012-12-15 23:34:20 +01:00
|
|
|
type PartCommand struct {
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand
|
2012-12-09 07:54:58 +01:00
|
|
|
channels []string
|
|
|
|
message string
|
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (cmd *PartCommand) String() string {
|
|
|
|
return fmt.Sprintf("PART(channels=%s, message=%s)", cmd.channels, cmd.message)
|
|
|
|
}
|
|
|
|
|
2013-05-09 18:12:03 +02:00
|
|
|
func NewPartCommand(args []string) (EditableCommand, error) {
|
2012-12-09 21:51:50 +01:00
|
|
|
if len(args) < 1 {
|
2012-12-10 05:24:53 +01:00
|
|
|
return nil, NotEnoughArgsError
|
2012-12-09 21:51:50 +01:00
|
|
|
}
|
2012-12-15 23:34:20 +01:00
|
|
|
msg := &PartCommand{
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand: BaseCommand{},
|
2012-12-13 08:27:17 +01:00
|
|
|
channels: strings.Split(args[0], ","),
|
|
|
|
}
|
2012-12-09 21:51:50 +01:00
|
|
|
if len(args) > 1 {
|
|
|
|
msg.message = args[1]
|
|
|
|
}
|
|
|
|
return msg, nil
|
|
|
|
}
|
|
|
|
|
2012-12-13 08:27:17 +01:00
|
|
|
// PRIVMSG <target> <message>
|
2012-12-09 07:54:58 +01:00
|
|
|
|
2012-12-15 23:34:20 +01:00
|
|
|
type PrivMsgCommand struct {
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand
|
2012-12-09 07:54:58 +01:00
|
|
|
target string
|
|
|
|
message string
|
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (cmd *PrivMsgCommand) String() string {
|
2013-05-11 22:55:01 +02:00
|
|
|
return fmt.Sprintf("PRIVMSG(target=%s, message=%s)", cmd.target, cmd.message)
|
|
|
|
}
|
|
|
|
|
2013-05-09 18:12:03 +02:00
|
|
|
func NewPrivMsgCommand(args []string) (EditableCommand, error) {
|
2012-12-09 21:51:50 +01:00
|
|
|
if len(args) < 2 {
|
2012-12-10 05:24:53 +01:00
|
|
|
return nil, NotEnoughArgsError
|
2012-12-09 21:51:50 +01:00
|
|
|
}
|
2012-12-15 23:34:20 +01:00
|
|
|
return &PrivMsgCommand{
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand: BaseCommand{},
|
2012-12-13 08:27:17 +01:00
|
|
|
target: args[0],
|
|
|
|
message: args[1],
|
2012-12-09 21:51:50 +01:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2012-12-15 23:34:20 +01:00
|
|
|
func (m *PrivMsgCommand) TargetIsChannel() bool {
|
2012-12-09 07:54:58 +01:00
|
|
|
switch m.target[0] {
|
|
|
|
case '&', '#', '+', '!':
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2012-12-09 23:59:28 +01:00
|
|
|
// TOPIC [newtopic]
|
2012-12-09 07:54:58 +01:00
|
|
|
|
2012-12-15 23:34:20 +01:00
|
|
|
type TopicCommand struct {
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand
|
2012-12-09 07:54:58 +01:00
|
|
|
channel string
|
|
|
|
topic string
|
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (cmd *TopicCommand) String() string {
|
|
|
|
return fmt.Sprintf("TOPIC(channel=%s, topic=%s)", cmd.channel, cmd.topic)
|
|
|
|
}
|
|
|
|
|
2013-05-09 18:12:03 +02:00
|
|
|
func NewTopicCommand(args []string) (EditableCommand, error) {
|
2012-12-09 21:51:50 +01:00
|
|
|
if len(args) < 1 {
|
2012-12-10 05:24:53 +01:00
|
|
|
return nil, NotEnoughArgsError
|
2012-12-09 21:51:50 +01:00
|
|
|
}
|
2012-12-15 23:34:20 +01:00
|
|
|
msg := &TopicCommand{
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand: BaseCommand{},
|
2012-12-13 08:27:17 +01:00
|
|
|
channel: args[0],
|
|
|
|
}
|
2012-12-09 21:51:50 +01:00
|
|
|
if len(args) > 1 {
|
|
|
|
msg.topic = args[1]
|
|
|
|
}
|
|
|
|
return msg, nil
|
|
|
|
}
|
|
|
|
|
2012-12-17 04:13:53 +01:00
|
|
|
type ModeCommand struct {
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand
|
2012-12-17 04:13:53 +01:00
|
|
|
nickname string
|
|
|
|
modes string
|
2012-12-10 05:24:53 +01:00
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (cmd *ModeCommand) String() string {
|
2013-05-11 22:55:01 +02:00
|
|
|
return fmt.Sprintf("MODE(nickname=%s, modes=%s)", cmd.nickname, cmd.modes)
|
|
|
|
}
|
|
|
|
|
2013-05-09 18:12:03 +02:00
|
|
|
func NewModeCommand(args []string) (EditableCommand, error) {
|
2012-12-17 04:13:53 +01:00
|
|
|
if len(args) == 0 {
|
2012-12-10 05:24:53 +01:00
|
|
|
return nil, NotEnoughArgsError
|
|
|
|
}
|
2012-12-15 23:34:20 +01:00
|
|
|
|
2012-12-17 04:13:53 +01:00
|
|
|
cmd := &ModeCommand{
|
2013-05-09 18:12:03 +02:00
|
|
|
BaseCommand: BaseCommand{},
|
2012-12-17 04:13:53 +01:00
|
|
|
nickname: args[0],
|
|
|
|
}
|
2012-12-15 23:34:20 +01:00
|
|
|
|
2012-12-17 04:13:53 +01:00
|
|
|
if len(args) > 1 {
|
|
|
|
cmd.modes = args[1]
|
2012-12-15 23:34:20 +01:00
|
|
|
}
|
2012-12-17 04:13:53 +01:00
|
|
|
|
|
|
|
return cmd, nil
|
2012-12-10 05:24:53 +01:00
|
|
|
}
|