CTCP action roundtrip conversion

--HG--
branch : nmdc-ircfrontend
This commit is contained in:
. 2016-05-08 13:07:10 +12:00
parent a5f4bc2535
commit 22f08d6d57
2 changed files with 30 additions and 8 deletions

View File

@ -2,18 +2,16 @@
PRE-RELEASE PRE-RELEASE
=========== ===========
- detect our own /me messages + don't echo back
- client descriptions (CTCP USERINFO) - client descriptions (CTCP USERINFO)
- expose upstream op status
- remove color code escape sequences - remove color code escape sequences
WISHLIST WISHLIST
======== ========
- "implying" colours
- send client keepalives (PING) /and/ ensure we get a reply (PONG) - send client keepalives (PING) /and/ ensure we get a reply (PONG)
- client version sync (CTCP VERSION) - client version sync (CTCP VERSION)
@ -56,3 +54,7 @@ https://en.wikipedia.org/wiki/Client-to-client_protocol
https://wiki.mibbit.com/index.php/Ctcp_(version) https://wiki.mibbit.com/index.php/Ctcp_(version)
https://github.com/eXeC64/Rosella AGPLv3 license
https://github.com/edmund-huber/ergonomadic MIT license

View File

@ -143,6 +143,7 @@ func (s *Server) RunWorker() {
func (s *Server) upstreamWorker() { func (s *Server) upstreamWorker() {
// FIXME blank names work well in hexchat, but not in yaaic
var BLANK_NICK = "" // "!@" + s.name // "PtokaX" // "\xC2\xA0" var BLANK_NICK = "" // "!@" + s.name // "PtokaX" // "\xC2\xA0"
// Read loop // Read loop
@ -180,20 +181,39 @@ func (s *Server) upstreamWorker() {
s.sendChannelTopic(hubEvent.Nick) s.sendChannelTopic(hubEvent.Nick)
case libnmdc.EVENT_PRIVATE: case libnmdc.EVENT_PRIVATE:
//s.reply(rplMsg, hubEvent.Nick, s.upstreamLauncher.Self.Nick, hubEvent.Message)
s.reply(rplMsg, hubEvent.Nick+"!"+hubEvent.Nick+"@"+hubEvent.Nick, s.upstreamLauncher.Self.Nick, hubEvent.Message) s.reply(rplMsg, hubEvent.Nick+"!"+hubEvent.Nick+"@"+hubEvent.Nick, s.upstreamLauncher.Self.Nick, hubEvent.Message)
case libnmdc.EVENT_PUBLIC: case libnmdc.EVENT_PUBLIC:
if hubEvent.Nick == s.upstreamLauncher.Self.Nick { if hubEvent.Nick == s.upstreamLauncher.Self.Nick {
// irc doesn't echo our own pubchat // irc doesn't echo our own pubchat
} else { } else {
// s.reply(rplMsg, hubEvent.Nick, BLESSED_CHANNEL, hubEvent.Message) // nick!username@userhost, but for us all three of those are always identical
s.reply(rplMsg, hubEvent.Nick+"!"+hubEvent.Nick+"@"+hubEvent.Nick, BLESSED_CHANNEL, hubEvent.Message) s.reply(rplMsg, hubEvent.Nick+"!"+hubEvent.Nick+"@"+hubEvent.Nick, BLESSED_CHANNEL, hubEvent.Message)
} }
case libnmdc.EVENT_SYSTEM_MESSAGE_FROM_CONN, libnmdc.EVENT_SYSTEM_MESSAGE_FROM_HUB: case libnmdc.EVENT_SYSTEM_MESSAGE_FROM_CONN, libnmdc.EVENT_SYSTEM_MESSAGE_FROM_HUB:
// FIXME blank names work well in hexchat, but not in yaaic words := strings.Split(hubEvent.Message, " ")
firstWord := words[0]
remainder := strings.Join(words[1:], " ")
if firstWord == "*" {
firstWord = words[1]
remainder = strings.Join(words[2:], " ")
}
if s.upstream.UserExists(firstWord) {
// it's a /me in disguise - convert back to a CTCP ACTION
// If it's **our own** action, skip it
if firstWord != s.upstreamLauncher.Self.Nick {
s.reply(
rplMsg, firstWord+"!"+firstWord+"@"+firstWord, BLESSED_CHANNEL,
"\x01ACTION "+remainder+"\x01",
)
}
} else {
// genuine system message
s.reply(rplMsg, BLANK_NICK, BLESSED_CHANNEL, hubEvent.Message) s.reply(rplMsg, BLANK_NICK, BLESSED_CHANNEL, hubEvent.Message)
}
} }
} }