diff options
| author | Markus Mittendrein <git@maxmitti.tk> | 2015-11-15 01:44:05 +0100 |
|---|---|---|
| committer | Markus Mittendrein <git@maxmitti.tk> | 2015-11-15 02:03:23 +0100 |
| commit | db9734adda107e1b417a77311f2194471274a223 (patch) | |
| tree | 41c8e6307036305ff08578be729ad129261d404c /src/crsm.cpp | |
| parent | b871ac2c887da8993316e48d2090b334248fc97d (diff) | |
| download | manager-db9734adda107e1b417a77311f2194471274a223.tar.gz manager-db9734adda107e1b417a77311f2194471274a223.zip | |
Allow enabling/disabling greeting for Clonk, IRC, IRC-User and IRC-
Channels
Diffstat (limited to 'src/crsm.cpp')
| -rw-r--r-- | src/crsm.cpp | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/src/crsm.cpp b/src/crsm.cpp index 5a7f0e4..894c9bb 100644 --- a/src/crsm.cpp +++ b/src/crsm.cpp @@ -477,7 +477,12 @@ void CRSM::ircMessageReceived(IrcMessage *message) { IrcJoinMessage* joinMessage = (IrcJoinMessage*) message; QString joinChannel = joinMessage->channel(); - sendIrcMessage("Hallo, " + message->nick() + "!", joinChannel, false, false); + + if(greetAllowed(ClientInfo::ircClient(joinMessage->nick(), joinMessage->channel()))) + { + sendIrcMessage("Hallo, " + message->nick() + "!", joinChannel, false, false); + } + if(joinChannel == Config.IRC.IngameChannel && Session.IRC.UseIngameChat) { writeToServer("[IRC] " + message->nick() + " hat den Channel betreten." + "\n"); @@ -548,8 +553,17 @@ void CRSM::ircConnected() void CRSM::greet(QString pcName) { if(!Session.Clonk.Clients.contains(pcName)) + { return; + } + const ClientInfo &info = Session.Clonk.Clients.value(pcName); + + if(!greetAllowed(info)) + { + return; + } + writeToServer(QString("Hallo, " + info.nick + "!\n")); if(Session.Clonk.LeaveAdmins.contains(info)) { @@ -1930,6 +1944,54 @@ void CRSM::sendIrcMessage(const QString& message, const QString& target, bool ac } } +bool CRSM::greetAllowed(const ClientInfo &client) +{ + if(client.interface == Clonk && Config.CRSM.Greeting.contains(GreetingSetting::clonk()) && !Config.CRSM.Greeting.contains(GreetingSetting::clonk().invert())) + { + return true; + } + else if(client.interface == IRC) + { + int nickSetting = -1; + int chanSetting = -1; + int ircSetting = -1; + foreach(const GreetingSetting& setting, Config.CRSM.Greeting) + { + if(setting.interface == IRC) + { + if(setting.target == client.nick) + { + nickSetting = !setting.negative; + } + else if(setting.target == client.target) + { + chanSetting = !setting.negative; + } + else if(setting.target.isEmpty()) + { + ircSetting = !setting.negative; + } + } + } + + if(nickSetting != -1) + { + return nickSetting != 0; + } + + if(chanSetting != -1) + { + return chanSetting != 0; + } + + if(ircSetting != -1) + { + return ircSetting != 0; + } + } + return false; +} + CMD_FUNCTION_IMPL(help) bool longHelp = (args == "long"); if(args.isEmpty() || longHelp) |
