2016-06-15 13:50:56 +02:00
|
|
|
// Copyright (c) 2012-2014 Jeremy Latt
|
|
|
|
// Copyright (c) 2016- Daniel Oaks <daniel@danieloaks.net>
|
|
|
|
// released under the MIT license
|
|
|
|
|
2014-03-17 20:11:35 +01:00
|
|
|
package irc
|
|
|
|
|
2016-06-17 14:17:42 +02:00
|
|
|
/*
|
2014-03-17 20:11:35 +01:00
|
|
|
type NickCommand struct {
|
|
|
|
BaseCommand
|
|
|
|
nickname Name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *NickCommand) HandleRegServer(s *Server) {
|
|
|
|
client := m.Client()
|
|
|
|
if !client.authorized {
|
|
|
|
client.ErrPasswdMismatch()
|
|
|
|
client.Quit("bad password")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if m.nickname == "" {
|
|
|
|
client.ErrNoNicknameGiven()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if s.clients.Get(m.nickname) != nil {
|
|
|
|
client.ErrNickNameInUse(m.nickname)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if !m.nickname.IsNickname() {
|
|
|
|
client.ErrErroneusNickname(m.nickname)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
client.SetNickname(m.nickname)
|
|
|
|
s.tryRegister(client)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (msg *NickCommand) HandleServer(server *Server) {
|
|
|
|
client := msg.Client()
|
|
|
|
|
|
|
|
if msg.nickname == "" {
|
|
|
|
client.ErrNoNicknameGiven()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if !msg.nickname.IsNickname() {
|
|
|
|
client.ErrErroneusNickname(msg.nickname)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if msg.nickname == client.nick {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
target := server.clients.Get(msg.nickname)
|
|
|
|
if (target != nil) && (target != client) {
|
|
|
|
client.ErrNickNameInUse(msg.nickname)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
client.ChangeNickname(msg.nickname)
|
|
|
|
}
|
|
|
|
|
|
|
|
type OperNickCommand struct {
|
|
|
|
BaseCommand
|
|
|
|
target Name
|
|
|
|
nick Name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (msg *OperNickCommand) HandleServer(server *Server) {
|
|
|
|
client := msg.Client()
|
|
|
|
|
|
|
|
if !client.flags[Operator] {
|
|
|
|
client.ErrNoPrivileges()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if !msg.nick.IsNickname() {
|
|
|
|
client.ErrErroneusNickname(msg.nick)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-03-28 21:47:49 +01:00
|
|
|
if msg.nick == client.nick {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-03-17 20:11:35 +01:00
|
|
|
target := server.clients.Get(msg.target)
|
|
|
|
if target == nil {
|
|
|
|
client.ErrNoSuchNick(msg.target)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-03-28 21:47:49 +01:00
|
|
|
if server.clients.Get(msg.nick) != nil {
|
|
|
|
client.ErrNickNameInUse(msg.nick)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-03-17 20:11:35 +01:00
|
|
|
target.ChangeNickname(msg.nick)
|
|
|
|
}
|
2016-06-17 14:17:42 +02:00
|
|
|
*/
|