mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-29 15:40:02 +01:00
commit
09909e3b3d
@ -1014,9 +1014,11 @@ func (channel *Channel) Invite(invitee *Client, inviter *Client, rb *ResponseBuf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rb.Add(nil, inviter.server.name, RPL_INVITING, inviter.Nick(), invitee.Nick(), chname)
|
cnick := inviter.Nick()
|
||||||
invitee.Send(nil, inviter.nickMaskString, "INVITE", invitee.nick, chname)
|
tnick := invitee.Nick()
|
||||||
|
rb.Add(nil, inviter.server.name, RPL_INVITING, cnick, tnick, chname)
|
||||||
|
invitee.Send(nil, inviter.NickMaskString(), "INVITE", tnick, chname)
|
||||||
if invitee.HasMode(modes.Away) {
|
if invitee.HasMode(modes.Away) {
|
||||||
rb.Add(nil, inviter.server.name, RPL_AWAY, invitee.nick, invitee.awayMessage)
|
rb.Add(nil, inviter.server.name, RPL_AWAY, cnick, tnick, invitee.AwayMessage())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,6 +143,19 @@ func (client *Client) SetRegistered() {
|
|||||||
client.stateMutex.Unlock()
|
client.stateMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (client *Client) AwayMessage() (result string) {
|
||||||
|
client.stateMutex.RLock()
|
||||||
|
result = client.awayMessage
|
||||||
|
client.stateMutex.RUnlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (client *Client) SetAwayMessage(message string) {
|
||||||
|
client.stateMutex.Lock()
|
||||||
|
client.awayMessage = message
|
||||||
|
client.stateMutex.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
func (client *Client) Destroyed() bool {
|
func (client *Client) Destroyed() bool {
|
||||||
client.stateMutex.RLock()
|
client.stateMutex.RLock()
|
||||||
defer client.stateMutex.RUnlock()
|
defer client.stateMutex.RUnlock()
|
||||||
|
@ -408,18 +408,18 @@ func authExternalHandler(server *Server, client *Client, mechanism string, value
|
|||||||
// AWAY [<message>]
|
// AWAY [<message>]
|
||||||
func awayHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
|
func awayHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
|
||||||
var isAway bool
|
var isAway bool
|
||||||
var text string
|
var awayMessage string
|
||||||
if len(msg.Params) > 0 {
|
if len(msg.Params) > 0 {
|
||||||
isAway = true
|
isAway = true
|
||||||
text = msg.Params[0]
|
awayMessage = msg.Params[0]
|
||||||
awayLen := server.Limits().AwayLen
|
awayLen := server.Limits().AwayLen
|
||||||
if len(text) > awayLen {
|
if len(awayMessage) > awayLen {
|
||||||
text = text[:awayLen]
|
awayMessage = awayMessage[:awayLen]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client.SetMode(modes.Away, isAway)
|
client.SetMode(modes.Away, isAway)
|
||||||
client.awayMessage = text
|
client.SetAwayMessage(awayMessage)
|
||||||
|
|
||||||
var op modes.ModeOp
|
var op modes.ModeOp
|
||||||
if isAway {
|
if isAway {
|
||||||
@ -439,7 +439,7 @@ func awayHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
|||||||
// dispatch away-notify
|
// dispatch away-notify
|
||||||
for friend := range client.Friends(caps.AwayNotify) {
|
for friend := range client.Friends(caps.AwayNotify) {
|
||||||
if isAway {
|
if isAway {
|
||||||
friend.SendFromClient("", client, nil, "AWAY", client.awayMessage)
|
friend.SendFromClient("", client, nil, "AWAY", awayMessage)
|
||||||
} else {
|
} else {
|
||||||
friend.SendFromClient("", client, nil, "AWAY")
|
friend.SendFromClient("", client, nil, "AWAY")
|
||||||
}
|
}
|
||||||
@ -1783,6 +1783,7 @@ func monitorClearHandler(server *Server, client *Client, msg ircmsg.IrcMessage,
|
|||||||
|
|
||||||
// MONITOR L
|
// MONITOR L
|
||||||
func monitorListHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
|
func monitorListHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
|
||||||
|
nick := client.Nick()
|
||||||
monitorList := server.monitorManager.List(client)
|
monitorList := server.monitorManager.List(client)
|
||||||
|
|
||||||
var nickList []string
|
var nickList []string
|
||||||
@ -1796,10 +1797,10 @@ func monitorListHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, line := range utils.ArgsToStrings(maxLastArgLength, nickList, ",") {
|
for _, line := range utils.ArgsToStrings(maxLastArgLength, nickList, ",") {
|
||||||
rb.Add(nil, server.name, RPL_MONLIST, client.Nick(), line)
|
rb.Add(nil, server.name, RPL_MONLIST, nick, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
rb.Add(nil, server.name, RPL_ENDOFMONLIST, "End of MONITOR list")
|
rb.Add(nil, server.name, RPL_ENDOFMONLIST, nick, "End of MONITOR list")
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -2095,6 +2096,7 @@ func privmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R
|
|||||||
// split privmsg
|
// split privmsg
|
||||||
splitMsg := utils.MakeSplitMessage(message, !client.capabilities.Has(caps.MaxLine))
|
splitMsg := utils.MakeSplitMessage(message, !client.capabilities.Has(caps.MaxLine))
|
||||||
|
|
||||||
|
cnick := client.Nick()
|
||||||
for i, targetString := range targets {
|
for i, targetString := range targets {
|
||||||
// max of four targets per privmsg
|
// max of four targets per privmsg
|
||||||
if i > maxTargets-1 {
|
if i > maxTargets-1 {
|
||||||
@ -2112,7 +2114,7 @@ func privmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
channel := server.channels.Get(target)
|
channel := server.channels.Get(target)
|
||||||
if channel == nil {
|
if channel == nil {
|
||||||
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, client.t("No such channel"))
|
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, cnick, targetString, client.t("No such channel"))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !channel.CanSpeak(client) {
|
if !channel.CanSpeak(client) {
|
||||||
@ -2130,7 +2132,7 @@ func privmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R
|
|||||||
user := server.clients.Get(target)
|
user := server.clients.Get(target)
|
||||||
if err != nil || user == nil {
|
if err != nil || user == nil {
|
||||||
if len(target) > 0 {
|
if len(target) > 0 {
|
||||||
client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, target, "No such nick")
|
client.Send(nil, server.name, ERR_NOSUCHNICK, cnick, target, "No such nick")
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -2150,7 +2152,7 @@ func privmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R
|
|||||||
}
|
}
|
||||||
if user.HasMode(modes.Away) {
|
if user.HasMode(modes.Away) {
|
||||||
//TODO(dan): possibly implement cooldown of away notifications to users
|
//TODO(dan): possibly implement cooldown of away notifications to users
|
||||||
rb.Add(nil, server.name, RPL_AWAY, user.nick, user.awayMessage)
|
rb.Add(nil, server.name, RPL_AWAY, cnick, user.Nick(), user.AwayMessage())
|
||||||
}
|
}
|
||||||
|
|
||||||
user.history.Add(history.Item{
|
user.history.Add(history.Item{
|
||||||
@ -2349,6 +2351,7 @@ func tagmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
|||||||
|
|
||||||
targets := strings.Split(msg.Params[0], ",")
|
targets := strings.Split(msg.Params[0], ",")
|
||||||
|
|
||||||
|
cnick := client.Nick()
|
||||||
for i, targetString := range targets {
|
for i, targetString := range targets {
|
||||||
// max of four targets per privmsg
|
// max of four targets per privmsg
|
||||||
if i > maxTargets-1 {
|
if i > maxTargets-1 {
|
||||||
@ -2366,7 +2369,7 @@ func tagmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
channel := server.channels.Get(target)
|
channel := server.channels.Get(target)
|
||||||
if channel == nil {
|
if channel == nil {
|
||||||
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, client.t("No such channel"))
|
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, cnick, targetString, client.t("No such channel"))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !channel.CanSpeak(client) {
|
if !channel.CanSpeak(client) {
|
||||||
@ -2381,7 +2384,7 @@ func tagmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
|||||||
user := server.clients.Get(target)
|
user := server.clients.Get(target)
|
||||||
if err != nil || user == nil {
|
if err != nil || user == nil {
|
||||||
if len(target) > 0 {
|
if len(target) > 0 {
|
||||||
client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, target, client.t("No such nick"))
|
client.Send(nil, server.name, ERR_NOSUCHNICK, cnick, target, client.t("No such nick"))
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -2397,7 +2400,7 @@ func tagmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
|||||||
}
|
}
|
||||||
if user.HasMode(modes.Away) {
|
if user.HasMode(modes.Away) {
|
||||||
//TODO(dan): possibly implement cooldown of away notifications to users
|
//TODO(dan): possibly implement cooldown of away notifications to users
|
||||||
rb.Add(nil, server.name, RPL_AWAY, user.nick, user.awayMessage)
|
rb.Add(nil, server.name, RPL_AWAY, cnick, user.Nick(), user.AwayMessage())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,13 +63,15 @@ func sendRoleplayMessage(server *Server, client *Client, source string, targetSt
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
user.Send(nil, source, "PRIVMSG", user.nick, message)
|
cnick := client.Nick()
|
||||||
|
tnick := user.Nick()
|
||||||
|
user.Send(nil, source, "PRIVMSG", tnick, message)
|
||||||
if client.capabilities.Has(caps.EchoMessage) {
|
if client.capabilities.Has(caps.EchoMessage) {
|
||||||
rb.Add(nil, source, "PRIVMSG", user.nick, message)
|
rb.Add(nil, source, "PRIVMSG", tnick, message)
|
||||||
}
|
}
|
||||||
if user.HasMode(modes.Away) {
|
if user.HasMode(modes.Away) {
|
||||||
//TODO(dan): possibly implement cooldown of away notifications to users
|
//TODO(dan): possibly implement cooldown of away notifications to users
|
||||||
rb.Add(nil, server.name, RPL_AWAY, user.nick, user.awayMessage)
|
rb.Add(nil, server.name, RPL_AWAY, cnick, tnick, user.AwayMessage())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user