summaryrefslogtreecommitdiffstats
path: root/src/crsm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/crsm.cpp')
-rw-r--r--src/crsm.cpp64
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)