Beispiel #1
0
void MyIrcSession::on_joined(IrcMessage *message) {
	IrcJoinMessage *m = (IrcJoinMessage *) message;
	bool flags = 0;
	std::string nickname = TO_UTF8(m->sender().name());
	flags = correctNickname(nickname);
	np->handleParticipantChanged(user, nickname, TO_UTF8(m->channel()), (int) flags, pbnetwork::STATUS_ONLINE);
	LOG4CXX_INFO(logger, user << ": Joined " << TO_UTF8(m->parameters()[0]));
}
Beispiel #2
0
void MyIrcSession::on_joined(IrcMessage *message) {
	IrcJoinMessage *m = (IrcJoinMessage *) message;
	std::string nickname = TO_UTF8(m->sender().name());
	bool op = correctNickname(nickname);
	getIRCBuddy(TO_UTF8(m->channel().toLower()), nickname).setOp(op);
	np->handleParticipantChanged(user, nickname, TO_UTF8(m->channel().toLower()) + suffix, op, pbnetwork::STATUS_ONLINE);
	LOG4CXX_INFO(logger, user << ": " << nickname << " joined " << TO_UTF8(m->channel().toLower()) + suffix);
}
Beispiel #3
0
void dlgIRC::onMessageReceived( IrcMessage* msg )
{
    switch( msg->type() )
    {
    case IrcMessage::Type::Join: {
        IrcJoinMessage *rmsg = static_cast<IrcJoinMessage*>(msg);
        slot_joined( rmsg->sender().name(), rmsg->channel() );
        break;
        }
    case IrcMessage::Type::Notice: {
        IrcNoticeMessage *rmsg = static_cast<IrcNoticeMessage*>(msg);
        irc_gotMsg( rmsg->sender().name(), rmsg->target(), rmsg->message() );
        break;
        }
    case IrcMessage::Type::Private: {
        IrcPrivateMessage *rmsg = static_cast<IrcPrivateMessage*>(msg);
        irc_gotMsg( rmsg->sender().name(), rmsg->target(), rmsg->message() );
        break;
        }
    case IrcMessage::Type::Numeric: {
        IrcNumericMessage *rmsg = static_cast<IrcNumericMessage*>(msg);
        irc_gotMsg3( rmsg->sender().name(), rmsg->code(), rmsg->parameters() );
        break;
        }
    case IrcMessage::Type::Part: {
        IrcPartMessage *rmsg = static_cast<IrcPartMessage*>(msg);
        slot_parted( rmsg->sender().name(), rmsg->channel(), rmsg->reason() );
        break;
        }
    case IrcMessage::Type::Unknown:
        irc_gotMsg2( msg->sender().name(), msg->parameters() );
        break;
    }
    /*
    Nick 	IrcNickMessage
    Quit 	IrcQuitMessage
    Topic 	IrcTopicMessage
    Invite 	IrcInviteMessage
    Kick 	IrcKickMessage
    Mode 	IrcModeMessage
    Ping 	IrcPingMessage
    Pong 	IrcPongMessage
    Error 	IrcErrorMessage
    */
}
void tst_IrcMessage::testJoinMessage()
{
    QFETCH(bool, valid);
    QFETCH(QByteArray, data);
    QFETCH(QString, channel);

    IrcConnection connection;
    IrcMessage* message = IrcMessage::fromData(data, &connection);
    QCOMPARE(message->type(), IrcMessage::Join);
    QCOMPARE(message->command(), QString("JOIN"));
    QCOMPARE(message->property("valid").toBool(), valid);
    QCOMPARE(message->property("channel").toString(), channel);

    IrcJoinMessage* joinMessage = qobject_cast<IrcJoinMessage*>(message);
    QVERIFY(joinMessage);
    QCOMPARE(joinMessage->isValid(), valid);
    QCOMPARE(joinMessage->channel(), channel);
}
Beispiel #5
0
void GreetModule::onMessageReceived(IrcMessage* message) {
	if (message->type() == IrcMessage::Join) {
			IrcJoinMessage* msg = static_cast<IrcJoinMessage*>(message);
			QString name = msg->sender().name();
			if (name != bot->nickName()) {
				QString greet = QString("Hi %1! Welcome in %2.").arg(name).arg(msg->channel());
				bot->sendCommand(IrcCommand::createMessage(msg->channel(), greet));
				out << "Greeted " << name << "." << endl;
			} else {
				QString enter = QString("enters %1 and fades to the background, immediatly available when somebody needs his services.").arg(msg->channel());
				bot->sendCommand(IrcCommand::createCtcpAction(msg->channel(), enter));
				out << "Joined " << msg->channel() << "." << endl;
			}
	} else if (message->type() == IrcMessage::Part) {
			IrcPartMessage* msg = static_cast<IrcPartMessage*>(message);
			QString name = msg->sender().name();
			QString bye = QString(" is shocked that %1 left %2 in favour of another channel.")
			.arg(name).arg(msg->channel());
			bot->sendCommand(IrcCommand::createCtcpAction(msg->channel(), bye));
			out << "Said good-bye to " << name << "." << endl;
			/*
	} else if (message->type() == IrcMessage::Quit) {
			IrcQuitMessage* msg = static_cast<IrcQuitMessage*>(message);
			QString name = msg->sender().name();
			QString bye = QString(" is a little sad that %1 left.").arg(name);
			bot->sendCommand(IrcCommand::createCtcpAction(bot->channel(), bye));
			out << "Said good-bye to " << name << "." << endl;
			*/
	}
}