How to auto-kick in UserConnection.cpp

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

Locked
smitty
Posts: 53
Joined: 2003-03-01 14:45

How to auto-kick in UserConnection.cpp

Post by smitty » 2003-05-21 15:16

In the $Lock section I've been able to Identify the user and lock string and also If I'm an OP, Can't figure out what code to use to auto-kick the user for clients not allowed that are detectable from lock string

Code: Select all

				if (getUser()->isClientOp()) {
                    string usrname = getUser()->getNick();
                    string usrhub = getUser()->getLastHubName();
                    string usrhubip = getUser()->getLastHubIp();
                    string myname = getUser()->getClientNick();
			        string::size_type iP = Util::findSubString(param.c_str(), "AuMi4x");
			        if (iP != string::npos) {
                        //CODE TO SEND PM TO USER AND KICK HIM
			        }
			        string::size_type iP2 = Util::findSubString(param.c_str(), "DCGUI");
			        if (iP2 != string::npos) {
                        //CODE TO SEND PM TO USER AND KICK HIM
			        }
			        string::size_type iP3 = Util::findSubString(param.c_str(), ";QfQy(F6j//qw5g9Ohv+jriJ^v5x*,Xgdy;wGHG_0Onso0bFiT8;Ec=ZXo2qa*^F5C6[Kq*u3aWSqxdtPBe]>IgqPB[ Pk=r¦ss⾁T/%DCN000%/Ã¥/%DCN096%//%DCN036%/%Ã¥gráÕ?±2A‚4Ãâ€
Knowledge is Earned BUT Wisdom is Free

smitty
Posts: 53
Joined: 2003-03-01 14:45

Post by smitty » 2003-05-27 08:33

Guess I'll stick to Client detection in Visual Basic since there seems to be no help on this subject here.
Knowledge is Earned BUT Wisdom is Free

sarf
Posts: 382
Joined: 2003-01-24 05:43
Location: Sweden
Contact:

Post by sarf » 2003-05-27 12:06

Well, if you specified what, exactly, you wanted help with it would help us help you, as GargoyleMT put it in another thread.

Do you want to know where you should put your code so that you can access the lock/pk of a user, or what?

Sarf
---
It's not that life is too short, it's that death is too long.

smitty
Posts: 53
Joined: 2003-03-01 14:45

Post by smitty » 2003-05-27 12:38

The code above I have put In UserConnection.cpp In the $Lock section. I've been able to Identify the user and lock string and also If I'm an OP, Can't figure out what code to use to auto-kick the user for clients not allowed that are detectable from lock string . I have used the MessageBox command and it will send me a message box when a certain client is detected so I know the detection works BUT don't know what references and commands to use to kick that user automatically when detected.
Knowledge is Earned BUT Wisdom is Free

sarf
Posts: 382
Joined: 2003-01-24 05:43
Location: Sweden
Contact:

Post by sarf » 2003-05-27 13:16

Sorry - I forgot to check the topic name. :blush:

some code follows:

Code: Select all

		// check if we're an OP
		if(aSource->getUser()->getClient()->getOp())
		{
			bool kickUser = false;
			
			string kickReason = "Using a modified client which is forbidden";
			
			// do your lock detection stuff here 
			//  set kickUser to true if we should kick
			//  set kickReason to whatever you want if you want to insult people stupid enough to use client XYZ
			
			// ...
			
			if(kickUser)
			{
				aSource->getUser()->getClient()->kick(aSource->getUser(), kickReason);
			}
		}
Hope this works (and helps). The code should be put at the end of the method, but it should work anywhere within the method.

Sarf
---
If your face were a tree, it would be different.

smitty
Posts: 53
Joined: 2003-03-01 14:45

Post by smitty » 2003-05-27 23:19

cool I'll try that tomorrow and let you know how it goes
Knowledge is Earned BUT Wisdom is Free

ender
Posts: 224
Joined: 2003-01-03 17:47

Re: How to auto-kick in UserConnection.cpp

Post by ender » 2003-05-28 02:30

Can you tell me a good reason for this:
smitty wrote: string::size_type iP2 = Util::findSubString(param.c_str(), "DCGUI");
if (iP2 != string::npos) {
//CODE TO SEND PM TO USER AND KICK HIM
}

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Re: How to auto-kick in UserConnection.cpp

Post by GargoyleMT » 2003-05-28 18:41

ender wrote:Can you tell me a good reason for this:
Presumably to treat DCGUI as a second class citizen for no good reason, just like DC++ used to be treated like a second class citizen? :roll:

Locked