Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

WormbotReporter.WIR_RegistrationQuakeNet


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
/******************************************************************************
Copyright (c) 2005-2007 by Wormbo <wormbo@online.de>
$Id$

Auths the client with Q.
******************************************************************************/


class WIR_RegistrationQuakeNet extends WIR_RegistrationHandler;


//=============================================================================
// Configured Variables
//=============================================================================

var bool bAuth;
var bool bChallengeAuth;
var bool bHideRealHost;
var string AuthNick;
var string AuthPassword;
var bool bDeaf;


//=============================================================================
// Variables
//=============================================================================

var bool bAuthed;
var bool bRealHostHidden;


//== Reset ====================================================================
/**
Resets the registration state. Should be subclasses.
*/
//=============================================================================

function Reset()
{
	bAuthed = False;
	bRealHostHidden = False;
}


//== Register =================================================================
/**
Starts the registration process. Should be subclasses.
*/
//=============================================================================

function Register()
{
	local string Network, Modes;

	if ( Outer.GetNetworkParameter("Network", Network) && Network ~= "QuakeNet") {
		Modes = "+iR";
		if (bHideRealHost) Modes $= "x";
		if (bDeaf)         Modes $= "d";
		Outer.SendCommand("MODE" @ UserNick @ Modes, True);
		if (bAuth ) {
			if ( bChallengeAuth )
				Outer.SendCommand("PRIVMSG Q@CServe.QuakeNet.org :CHALLENGE", True);
			else
				Outer.SendCommand("PRIVMSG Q@CServe.QuakeNet.org :AUTH" @ AuthNick @ AuthPassword, True);
		}
	}
	else {
		Super.Register();
	}
}


//== ReceivedString ============================================================
/**
Handles a string message received from the server.
*/
//=============================================================================

function ReceivedString(string Command, string Server, string Target, string Parameters)
{
	if ( !bAuthed && Command == "NOTICE" && Server ~= ":Q!TheQBot@CServe.quakenet.org" && Target ~= UserNick ) {
		if ( Left(Parameters, 11) == ":CHALLENGE " ) {
			Outer.SendCommand("PRIVMSG Q@CServe.QuakeNet.org :CHALLENGEAUTH" @ AuthNick
				@ class'WIR_Util'.static.HMACMD5String(class'WIR_Util'.static.MD5String(class'WIR_Util'.static.ToIRCLower(AuthNick) $ ":" $ class'WIR_Util'.static.MD5String(Left(AuthPassword, 10))), Mid(Parameters, 11, 32)) @ "HMAC-MD5", True);
		}
		else if ( Parameters ~= ":AUTH'd successfully." || Parameters ~= ":CHALLENGEAUTH'd successfully." ) {
			bAuthed = True;
			if ( !bHideRealHost ) {
				Outer.Registered();
				bRegistered = True;
			}
		}
		else {
			log("Response from Q:"@Parameters, Name);
		}
	}
}


//== ReceivedNumeric ============================================================
/**
Handles a numeric message received from the server.
*/
//=============================================================================

function ReceivedNumeric(int Command, string Server, string Target, string Parameters)
{
	if ( Command == 396 ) {
		bRealHostHidden = True;
		Outer.Registered();
		bRegistered = True;
	}
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Sa 16.7.2011 18:05:58.000 - Creation time: Do 14.8.2014 09:58:55.749 - Created with UnCodeX