1 /***************************************************************************
2 * Copyright (C) 2005-2018 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #include "eventstringifier.h"
23 #include "coresession.h"
24 #include "ctcpevent.h"
25 #include "messageevent.h"
27 EventStringifier::EventStringifier(CoreSession *parent) : BasicHandler("handleCtcp", parent),
31 connect(this, SIGNAL(newMessageEvent(Event *)), coreSession()->eventManager(), SLOT(postEvent(Event *)));
35 void EventStringifier::displayMsg(NetworkEvent *event, Message::Type msgType, const QString &msg, const QString &sender,
36 const QString &target, Message::Flags msgFlags)
38 if (event->flags().testFlag(EventManager::Silent))
41 MessageEvent *msgEvent = createMessageEvent(event, msgType, msg, sender, target, msgFlags);
42 //sendMessageEvent(msgEvent);
43 emit newMessageEvent(msgEvent);
47 MessageEvent *EventStringifier::createMessageEvent(NetworkEvent *event, Message::Type msgType, const QString &msg, const QString &sender,
48 const QString &target, Message::Flags msgFlags)
50 MessageEvent *msgEvent = new MessageEvent(msgType, event->network(), msg, sender, target, msgFlags);
51 msgEvent->setTimestamp(event->timestamp());
56 bool EventStringifier::checkParamCount(IrcEvent *e, int minParams)
58 if (e->params().count() < minParams) {
59 if (e->type() == EventManager::IrcEventNumeric) {
60 qWarning() << "Command " << static_cast<IrcEventNumeric *>(e)->number() << " requires " << minParams << "params, got: " << e->params();
63 QString name = coreSession()->eventManager()->enumName(e->type());
64 qWarning() << qPrintable(name) << "requires" << minParams << "params, got:" << e->params();
73 /* These are only for legacy reasons; remove as soon as we handle NetworkSplitEvents properly */
74 void EventStringifier::processNetworkSplitJoin(NetworkSplitEvent *e)
76 QString msg = e->users().join("#:#") + "#:#" + e->quitMessage();
77 displayMsg(e, Message::NetsplitJoin, msg, QString(), e->channel());
81 void EventStringifier::processNetworkSplitQuit(NetworkSplitEvent *e)
83 QString msg = e->users().join("#:#") + "#:#" + e->quitMessage();
84 displayMsg(e, Message::NetsplitQuit, msg, QString(), e->channel());
90 void EventStringifier::processIrcEventNumeric(IrcEventNumeric *e)
92 //qDebug() << e->number();
93 switch (e->number()) {
94 // Welcome, status, info messages. Just display these.
115 displayMsg(e, Message::Server, e->params().join(" "), e->prefix());
118 // Server error messages without param, just display them
140 case 431: // ERR_NONICKNAMEGIVEN
141 displayMsg(e, Message::Error, e->params().join(" "), e->prefix());
144 // Server error messages, display them in red. Colon between first param and rest.
147 if (!checkParamCount(e, 1))
150 QStringList params = e->params();
151 QString target = params.takeFirst();
152 displayMsg(e, Message::Error, target + ": " + params.join(" "), e->prefix(), target, Message::Redirected);
165 if (!checkParamCount(e, 1))
168 QStringList params = e->params();
169 QString channelName = params.takeFirst();
170 displayMsg(e, Message::Error, channelName + ": " + params.join(" "), e->prefix());
174 // Server error messages which will be displayed with a colon between the first param and the rest
180 case 461: // FIXME see below for the 47x codes
190 case 436: // ERR_NICKCOLLISION
192 if (!checkParamCount(e, 1))
195 QStringList params = e->params();
196 QString p = params.takeFirst();
197 displayMsg(e, Message::Error, p + ": " + params.join(" "));
201 // Ignore these commands.
208 // SASL authentication stuff
209 // See: http://ircv3.net/specs/extensions/sasl-3.1.html
210 case 900: // RPL_LOGGEDIN
211 case 901: // RPL_LOGGEDOUT
213 // :server 900 <nick> <nick>!<ident>@<host> <account> :You are now logged in as <user>
214 // :server 901 <nick> <nick>!<ident>@<host> :You are now logged out
215 if (!checkParamCount(e, 3))
217 displayMsg(e, Message::Server, "SASL: " + e->params().at(2));
220 // Ignore SASL success, partially redundant with RPL_LOGGEDIN and RPL_LOGGEDOUT
221 case 903: // RPL_SASLSUCCESS :server 903 <nick> :SASL authentication successful
223 case 902: // ERR_NICKLOCKED :server 902 <nick> :You must use a nick assigned to you
224 case 904: // ERR_SASLFAIL :server 904 <nick> :SASL authentication failed
225 case 905: // ERR_SASLTOOLONG :server 905 <nick> :SASL message too long
226 case 906: // ERR_SASLABORTED :server 906 <nick> :SASL authentication aborted
227 case 907: // ERR_SASLALREADY :server 907 <nick> :You have already authenticated using SASL
228 case 908: // RPL_SASLMECHS :server 908 <nick> <mechanisms> :are available SASL mechanisms
230 displayMsg(e, Message::Server, "SASL: " + e->params().join(""));
234 // Everything else will be marked in red, so we can add them somewhere.
237 // many nets define their own WHOIS fields. we fetch those not in need of special attention here:
238 displayMsg(e, Message::Server, tr("[Whois] ") + e->params().join(" "), e->prefix());
241 // FIXME figure out how/where to do this in the future
242 //if(coreSession()->ircListHelper()->requestInProgress(network()->networkId()))
243 // coreSession()->ircListHelper()->reportError(params.join(" "));
245 displayMsg(e, Message::Error, QString("%1 %2").arg(e->number(), 3, 10, QLatin1Char('0')).arg(e->params().join(" ")), e->prefix());
251 void EventStringifier::processIrcEventInvite(IrcEvent *e)
253 displayMsg(e, Message::Invite, tr("%1 invited you to channel %2").arg(e->nick(), e->params().at(1)));
257 void EventStringifier::processIrcEventJoin(IrcEvent *e)
259 if (e->testFlag(EventManager::Netsplit))
262 Message::Flag msgFlags = Message::Flag::None;
263 if (e->testFlag(EventManager::Self)) {
264 // Mark the message as Self
265 msgFlags = Message::Self;
268 displayMsg(e, Message::Join, e->params()[0], e->prefix(), e->params()[0], msgFlags);
272 void EventStringifier::processIrcEventKick(IrcEvent *e)
274 if (!checkParamCount(e, 2))
277 IrcUser *victim = e->network()->ircUser(e->params().at(1));
279 QString channel = e->params().at(0);
280 QString msg = victim->nick();
281 if (e->params().count() > 2)
282 msg += " " + e->params().at(2);
284 Message::Flag msgFlags = Message::Flag::None;
285 if (e->testFlag(EventManager::Self)) {
286 // Mark the message as Self
287 msgFlags = Message::Self;
290 displayMsg(e, Message::Kick, msg, e->prefix(), channel, msgFlags);
295 void EventStringifier::processIrcEventMode(IrcEvent *e)
297 if (e->network()->isChannelName(e->params().first())) {
299 displayMsg(e, Message::Mode, e->params().join(" "), e->prefix(), e->params().first());
305 Message::Flag msgFlags = Message::Flag::None;
306 if (e->testFlag(EventManager::Self)) {
307 // Mark the message as Self
308 msgFlags = Message::Self;
310 displayMsg(e, Message::Mode, e->params().join(" "), e->prefix(), QString(), msgFlags);
315 // this needs to be called before the ircuser is renamed!
316 void EventStringifier::processIrcEventNick(IrcEvent *e)
318 if (!checkParamCount(e, 1))
321 IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
323 qWarning() << Q_FUNC_INFO << "Unknown IrcUser!";
327 QString newnick = e->params().at(0);
330 Message::Flag msgFlags = Message::Flag::None;
331 if (e->testFlag(EventManager::Self)) {
332 // Treat the sender as the new nickname, mark the message as Self
334 msgFlags = Message::Self;
336 // Take the sender from the event prefix, don't mark the message
337 sender = e->prefix();
340 // Announce to all channels the IrcUser is in
341 foreach(const QString &channel, ircuser->channels()) {
342 displayMsg(e, Message::Nick, newnick, sender, channel, msgFlags);
347 void EventStringifier::processIrcEventPart(IrcEvent *e)
349 if (!checkParamCount(e, 1))
352 QString channel = e->params().at(0);
353 QString msg = e->params().count() > 1 ? e->params().at(1) : QString();
356 Message::Flag msgFlags = Message::Flag::None;
357 if (e->testFlag(EventManager::Self)) {
358 // Mark the message as Self
359 msgFlags = Message::Self;
362 displayMsg(e, Message::Part, msg, e->prefix(), channel, msgFlags);
366 void EventStringifier::processIrcEventPong(IrcEvent *e)
368 // Some IRC servers respond with only one parameter, others respond with two, with the latter
369 // being the text sent. Handle both situations.
371 if (e->params().count() < 2) {
372 // Only one parameter received
373 // :localhost PONG 02:43:49.565
374 timestamp = e->params().at(0);
376 // Two parameters received, pick the second
377 // :localhost PONG localhost :02:43:49.565
378 timestamp = e->params().at(1);
381 // Attempt to parse the timestamp
382 QTime sendTime = QTime::fromString(timestamp, "hh:mm:ss.zzz");
383 if (!sendTime.isValid()) {
384 // No valid timestamp found, this is most likely a user-specified PING message.
386 // Or the IRC server is returning whatever it feels like to PING messages, in which case..
387 // sorry. Increase the ping timeout delay in Quassel to as high as possible, and go
388 // encourage your IRC server developer to fix their stuff.
389 displayMsg(e, Message::Server, "PONG " + e->params().join(" "), e->prefix());
394 void EventStringifier::processIrcEventQuit(IrcEvent *e)
396 if (e->testFlag(EventManager::Netsplit))
399 IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
404 Message::Flag msgFlags = Message::Flag::None;
405 if (e->testFlag(EventManager::Self)) {
406 // Mark the message as Self
407 msgFlags = Message::Self;
410 // Announce to all channels the IrcUser is in
411 foreach(const QString &channel, ircuser->channels()) {
412 displayMsg(e, Message::Quit, e->params().count() ? e->params().first() : QString(),
413 e->prefix(), channel, msgFlags);
418 void EventStringifier::processIrcEventTopic(IrcEvent *e)
420 Message::Flag msgFlags = Message::Flag::None;
421 if (e->testFlag(EventManager::Self)) {
422 // Mark the message as Self
423 msgFlags = Message::Self;
426 displayMsg(e, Message::Topic, tr("%1 has changed topic for %2 to: \"%3\"")
427 .arg(e->nick(), e->params().at(0), e->params().at(1)), QString(), e->params().at(0),
431 void EventStringifier::processIrcEventError(IrcEvent *e)
433 // Need an error reason
434 if (!checkParamCount(e, 1))
437 displayMsg(e, Message::Server, tr("Error from server: ") + e->params().join(""));
440 void EventStringifier::processIrcEventWallops(IrcEvent *e)
442 displayMsg(e, Message::Server, tr("[Operwall] %1: %2").arg(e->nick(), e->params().join(" ")));
447 void EventStringifier::processIrcEvent005(IrcEvent *e)
449 if (!e->params().last().contains(QRegExp("are supported (by|on) this server")))
450 displayMsg(e, Message::Error, tr("Received non-RFC-compliant RPL_ISUPPORT: this can lead to unexpected behavior!"), e->prefix());
451 displayMsg(e, Message::Server, e->params().join(" "), e->prefix());
455 /* RPL_AWAY - "<nick> :<away message>" */
456 void EventStringifier::processIrcEvent301(IrcEvent *e)
458 QString nick = e->params().at(0);
459 QString awayMsg = e->params().at(1);
463 // FIXME: proper redirection needed
465 msg = tr("[Whois] ");
469 IrcUser *ircuser = e->network()->ircUser(nick);
471 QDateTime now = QDateTime::currentDateTime();
472 now.setTimeSpec(Qt::UTC);
473 // Don't print "user is away" messages more often than this
474 const int silenceTime = 60;
475 if (ircuser->lastAwayMessageTime().addSecs(silenceTime) >= now)
477 ircuser->setLastAwayMessageTime(now);
481 displayMsg(e, Message::Server, msg + tr("%1 is away: \"%2\"").arg(nick, awayMsg), QString(), target);
485 /* RPL_UNAWAY - ":You are no longer marked as being away" */
486 void EventStringifier::processIrcEvent305(IrcEvent *e)
488 displayMsg(e, Message::Server, tr("You are no longer marked as being away"));
492 /* RPL_NOWAWAY - ":You have been marked as being away" */
493 void EventStringifier::processIrcEvent306(IrcEvent *e)
495 if (!e->network()->autoAwayActive())
496 displayMsg(e, Message::Server, tr("You have been marked as being away"));
502 Replies 311 - 313, 317 - 319 are all replies generated in response to a WHOIS message.
504 "<nick> :<away message>"
506 Replies 352 and 315 paired are used to answer a WHO message.
509 Replies 314 and 369 are responses to a WHOWAS message.
513 /* RPL_WHOISUSER - "<nick> <user> <host> * :<real name>" */
514 void EventStringifier::processIrcEvent311(IrcEvent *e)
518 const QString whoisUserString = tr("[Whois] %1 is %2 (%3)");
520 IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
522 displayMsg(e, Message::Server, whoisUserString.arg(ircuser->nick(), ircuser->hostmask(), ircuser->realName()));
524 QString host = QString("%1!%2@%3").arg(e->params().at(0), e->params().at(1), e->params().at(2));
525 displayMsg(e, Message::Server, whoisUserString.arg(e->params().at(0), host, e->params().last()));
530 /* RPL_WHOISSERVER - "<nick> <server> :<server info>" */
531 void EventStringifier::processIrcEvent312(IrcEvent *e)
534 displayMsg(e, Message::Server, tr("[Whois] %1 is online via %2 (%3)").arg(e->params().at(0), e->params().at(1), e->params().last()));
536 displayMsg(e, Message::Server, tr("[Whowas] %1 was online via %2 (%3)").arg(e->params().at(0), e->params().at(1), e->params().last()));
540 /* RPL_WHOWASUSER - "<nick> <user> <host> * :<real name>" */
541 void EventStringifier::processIrcEvent314(IrcEvent *e)
543 if (!checkParamCount(e, 3))
546 displayMsg(e, Message::Server, tr("[Whowas] %1 was %2@%3 (%4)").arg(e->params()[0], e->params()[1], e->params()[2], e->params().last()));
550 /* RPL_ENDOFWHO: "<name> :End of WHO list" */
551 void EventStringifier::processIrcEvent315(IrcEvent *e)
553 QStringList p = e->params();
554 p.takeLast(); // should be "End of WHO list"
555 displayMsg(e, Message::Server, tr("[Who] End of /WHO list for %1").arg(p.join(" ")));
559 /* RPL_WHOISIDLE - "<nick> <integer> :seconds idle"
560 (real life: "<nick> <integer> <integer> :seconds idle, signon time) */
561 void EventStringifier::processIrcEvent317(IrcEvent *e)
563 int idleSecs = e->params()[1].toInt();
565 if (e->params().count() > 3) { // if we have more then 3 params we have the above mentioned "real life" situation
566 // Time in IRC protocol is defined as seconds. Convert from seconds instead.
567 // See https://doc.qt.io/qt-5/qdatetime.html#fromSecsSinceEpoch
568 #if QT_VERSION >= 0x050800
569 QDateTime loginTime = QDateTime::fromSecsSinceEpoch(e->params()[2].toLongLong()).toUTC();
571 // fromSecsSinceEpoch() was added in Qt 5.8. Manually downconvert to seconds for now.
572 // See https://doc.qt.io/qt-5/qdatetime.html#fromMSecsSinceEpoch
573 QDateTime loginTime = QDateTime::fromMSecsSinceEpoch(
574 (qint64)(e->params()[2].toLongLong() * 1000)).toUTC();
576 displayMsg(e, Message::Server, tr("[Whois] %1 is logged in since %2")
577 .arg(e->params()[0], loginTime.toString("yyyy-MM-dd hh:mm:ss UTC")));
579 QDateTime idlingSince = e->timestamp().toLocalTime().addSecs(-idleSecs).toUTC();
580 displayMsg(e, Message::Server, tr("[Whois] %1 is idling for %2 (since %3)")
581 .arg(e->params()[0], secondsToString(idleSecs),
582 idlingSince.toString("yyyy-MM-dd hh:mm:ss UTC")));
586 /* RPL_ENDOFWHOIS - "<nick> :End of WHOIS list" */
587 void EventStringifier::processIrcEvent318(IrcEvent *e)
590 displayMsg(e, Message::Server, tr("[Whois] End of /WHOIS list"));
594 /* RPL_WHOISCHANNELS - "<nick> :*( ( "@" / "+" ) <channel> " " )" */
595 void EventStringifier::processIrcEvent319(IrcEvent *e)
597 if (!checkParamCount(e, 2))
600 QString nick = e->params().first();
604 foreach(QString channel, e->params().last().split(" ")) {
605 if (channel.startsWith("@"))
606 op.append(channel.remove(0, 1));
607 else if (channel.startsWith("+"))
608 voice.append(channel.remove(0, 1));
610 user.append(channel);
613 displayMsg(e, Message::Server, tr("[Whois] %1 is a user on channels: %2").arg(nick, user.join(" ")));
614 if (!voice.isEmpty())
615 displayMsg(e, Message::Server, tr("[Whois] %1 has voice on channels: %2").arg(nick, voice.join(" ")));
617 displayMsg(e, Message::Server, tr("[Whois] %1 is an operator on channels: %2").arg(nick, op.join(" ")));
621 /* RPL_LIST - "<channel> <# visible> :<topic>" */
622 void EventStringifier::processIrcEvent322(IrcEvent *e)
625 quint32 userCount = 0;
628 switch (e->params().count()) {
630 topic = e->params()[2];
631 [[clang::fallthrough]];
633 userCount = e->params()[1].toUInt();
634 [[clang::fallthrough]];
636 channelName = e->params()[0];
637 [[clang::fallthrough]];
641 displayMsg(e, Message::Server, tr("Channel %1 has %2 users. Topic is: \"%3\"")
642 .arg(channelName).arg(userCount).arg(topic));
646 /* RPL_LISTEND ":End of LIST" */
647 void EventStringifier::processIrcEvent323(IrcEvent *e)
649 displayMsg(e, Message::Server, tr("End of channel list"));
653 /* RPL_CHANNELMODEIS - "<channel> <mode> <mode params>" */
654 void EventStringifier::processIrcEvent324(IrcEvent *e)
656 processIrcEventMode(e);
660 /* RPL_??? - "<channel> <homepage> */
661 void EventStringifier::processIrcEvent328(IrcEvent *e)
663 if (!checkParamCount(e, 2))
666 QString channel = e->params()[0];
667 displayMsg(e, Message::Topic, tr("Homepage for %1 is %2").arg(channel, e->params()[1]), QString(), channel);
671 /* RPL_??? - "<channel> <creation time (unix)>" */
672 void EventStringifier::processIrcEvent329(IrcEvent *e)
674 if (!checkParamCount(e, 2))
677 QString channel = e->params()[0];
678 // Allow for 64-bit time
679 qint64 unixtime = e->params()[1].toLongLong();
681 qWarning() << Q_FUNC_INFO << "received invalid timestamp:" << e->params()[1];
684 // Time in IRC protocol is defined as seconds. Convert from seconds instead.
685 // See https://doc.qt.io/qt-5/qdatetime.html#fromSecsSinceEpoch
686 #if QT_VERSION >= 0x050800
687 QDateTime time = QDateTime::fromSecsSinceEpoch(unixtime).toUTC();
689 // fromSecsSinceEpoch() was added in Qt 5.8. Manually downconvert to seconds for now.
690 // See https://doc.qt.io/qt-5/qdatetime.html#fromMSecsSinceEpoch
691 QDateTime time = QDateTime::fromMSecsSinceEpoch((qint64)(unixtime * 1000)).toUTC();
693 displayMsg(e, Message::Topic, tr("Channel %1 created on %2")
694 .arg(channel, time.toString("yyyy-MM-dd hh:mm:ss UTC")),
699 /* RPL_WHOISACCOUNT: "<nick> <account> :is authed as */
700 void EventStringifier::processIrcEvent330(IrcEvent *e)
702 if (e->params().count() < 3)
705 // check for whois or whowas
707 displayMsg(e, Message::Server, tr("[Whois] %1 is authed as %2").arg(e->params()[0], e->params()[1]));
710 displayMsg(e, Message::Server, tr("[Whowas] %1 was authed as %2").arg(e->params()[0], e->params()[1]));
716 void EventStringifier::processIrcEvent331(IrcEvent *e)
718 QString channel = e->params().first();
719 displayMsg(e, Message::Topic, tr("No topic is set for %1.").arg(channel), QString(), channel);
724 void EventStringifier::processIrcEvent332(IrcEvent *e)
726 QString channel = e->params().first();
727 displayMsg(e, Message::Topic, tr("Topic for %1 is \"%2\"").arg(channel, e->params()[1]), QString(), channel);
731 /* Topic set by... */
732 void EventStringifier::processIrcEvent333(IrcEvent *e)
734 if (!checkParamCount(e, 3))
737 QString channel = e->params().first();
738 // Time in IRC protocol is defined as seconds. Convert from seconds instead.
739 // See https://doc.qt.io/qt-5/qdatetime.html#fromSecsSinceEpoch
740 #if QT_VERSION >= 0x050800
741 QDateTime topicSetTime = QDateTime::fromSecsSinceEpoch(e->params()[2].toLongLong()).toUTC();
743 // fromSecsSinceEpoch() was added in Qt 5.8. Manually downconvert to seconds for now.
744 // See https://doc.qt.io/qt-5/qdatetime.html#fromMSecsSinceEpoch
745 QDateTime topicSetTime = QDateTime::fromMSecsSinceEpoch(
746 (qint64)(e->params()[2].toLongLong() * 1000)).toUTC();
748 displayMsg(e, Message::Topic, tr("Topic set by %1 on %2")
750 topicSetTime.toString("yyyy-MM-dd hh:mm:ss UTC")), QString(), channel);
754 /* RPL_INVITING - "<nick> <channel>*/
755 void EventStringifier::processIrcEvent341(IrcEvent *e)
757 if (!checkParamCount(e, 2))
760 QString channel = e->params()[1];
761 displayMsg(e, Message::Server, tr("%1 has been invited to %2").arg(e->params().first(), channel), QString(), channel);
765 /* RPL_WHOREPLY: "<channel> <user> <host> <server> <nick>
766 ( "H" / "G" > ["*"] [ ( "@" / "+" ) ] :<hopcount> <real name>" */
767 void EventStringifier::processIrcEvent352(IrcEvent *e)
769 displayMsg(e, Message::Server, tr("[Who] %1").arg(e->params().join(" ")));
773 /* RPL_WHOSPCRPL: "<yournick> <num> #<channel> ~<ident> <host> <servname> <nick>
774 ("H"/ "G") <account> :<realname>"
775 Could be anything else, though. User-specified fields.
776 See http://faerion.sourceforge.net/doc/irc/whox.var */
777 void EventStringifier::processIrcEvent354(IrcEvent *e)
779 displayMsg(e, Message::Server, tr("[WhoX] %1").arg(e->params().join(" ")));
783 /* RPL_ENDOFWHOWAS - "<nick> :End of WHOWAS" */
784 void EventStringifier::processIrcEvent369(IrcEvent *e)
786 displayMsg(e, Message::Server, tr("End of /WHOWAS"));
790 /* ERR_ERRONEUSNICKNAME */
791 void EventStringifier::processIrcEvent432(IrcEvent *e)
793 if (!checkParamCount(e, 1))
796 displayMsg(e, Message::Error, tr("Nick %1 contains illegal characters").arg(e->params()[0]));
800 /* ERR_NICKNAMEINUSE */
801 void EventStringifier::processIrcEvent433(IrcEvent *e)
803 if (!checkParamCount(e, 1))
806 displayMsg(e, Message::Error, tr("Nick already in use: %1").arg(e->params()[0]));
810 /* ERR_UNAVAILRESOURCE */
811 void EventStringifier::processIrcEvent437(IrcEvent *e)
813 if (!checkParamCount(e, 1))
816 displayMsg(e, Message::Error, tr("Nick/channel is temporarily unavailable: %1").arg(e->params()[0]));
823 void EventStringifier::processIrcEvent(IrcEvent *e) {
829 /*******************************/
830 /******** CTCP HANDLING ********/
831 /*******************************/
833 void EventStringifier::processCtcpEvent(CtcpEvent *e)
835 if (e->type() != EventManager::CtcpEvent)
838 if (e->testFlag(EventManager::Self)) {
839 displayMsg(e, Message::Action,
840 tr("sending CTCP-%1 request to %2").arg(e->ctcpCmd(), e->target()),
841 e->network()->myNick(), QString(), Message::Flag::Self);
845 handle(e->ctcpCmd(), Q_ARG(CtcpEvent *, e));
849 void EventStringifier::defaultHandler(const QString &ctcpCmd, CtcpEvent *e)
852 if (e->ctcpType() == CtcpEvent::Query) {
854 if (e->reply().isNull()) // all known core-side handlers (except for ACTION) set a reply!
855 //: Optional "unknown" in "Received unknown CTCP-FOO request by bar"
856 unknown = tr("unknown") + ' ';
857 displayMsg(e, Message::Server, tr("Received %1CTCP-%2 request by %3").arg(unknown, e->ctcpCmd(), e->prefix()));
860 displayMsg(e, Message::Server, tr("Received CTCP-%1 answer from %2: %3").arg(e->ctcpCmd(), nickFromMask(e->prefix()), e->param()));
864 void EventStringifier::handleCtcpAction(CtcpEvent *e)
866 displayMsg(e, Message::Action, e->param(), e->prefix(), e->target());
870 void EventStringifier::handleCtcpPing(CtcpEvent *e)
872 if (e->ctcpType() == CtcpEvent::Query)
873 defaultHandler(e->ctcpCmd(), e);
875 displayMsg(e, Message::Server, tr("Received CTCP-PING answer from %1 with %2 milliseconds round trip time")
876 .arg(nickFromMask(e->prefix())).arg(QDateTime::fromMSecsSinceEpoch(e->param().toULongLong()).msecsTo(e->timestamp())));