mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
Identify TechBot to allow private messages
svn path=/trunk/; revision=20578
This commit is contained in:
parent
6f136848b2
commit
f881f51fdf
7 changed files with 45 additions and 6 deletions
|
@ -5,6 +5,7 @@
|
|||
<add key="IRCServerHostPort" value="6667" />
|
||||
<add key="IRCChannelNames" value="channel1;channel2" />
|
||||
<add key="IRCBotName" value="MyBot" />
|
||||
<add key="IRCBotPassword" value="MyPassword" />
|
||||
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
|
||||
<add key="MainChm" value="kmarch.chm" />
|
||||
<add key="NtstatusXml" value="C:\IRC\TechBot\ntstatus.xml" />
|
||||
|
|
|
@ -74,6 +74,18 @@ namespace TechBot.Console
|
|||
}
|
||||
}
|
||||
|
||||
private static string IRCBotPassword
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "IRCBotPassword";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private static string ChmPath
|
||||
{
|
||||
get
|
||||
|
@ -176,6 +188,7 @@ namespace TechBot.Console
|
|||
IRCServerHostPort,
|
||||
IRCChannelNames,
|
||||
IRCBotName,
|
||||
IRCBotPassword,
|
||||
ChmPath,
|
||||
MainChm,
|
||||
NtstatusXml,
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace TechBot.IRCLibrary
|
|||
public const string PONG = "PONG";
|
||||
public const string PRIVMSG = "PRIVMSG";
|
||||
public const string USER = "USER";
|
||||
public const string PASS = "PASS";
|
||||
|
||||
public const string RPL_NAMREPLY = "353";
|
||||
public const string RPL_ENDOFNAMES = "366";
|
||||
|
|
|
@ -556,26 +556,40 @@ namespace TechBot.IRCLibrary
|
|||
public void ChangeNick(string nickname)
|
||||
{
|
||||
if (nickname == null)
|
||||
{
|
||||
throw new ArgumentNullException("nickname", "Nickname cannot be null.");
|
||||
}
|
||||
|
||||
/* NICK <nickname> [ <hopcount> ] */
|
||||
SendMessage(new IrcMessage(IRC.NICK, nickname));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Submit password to identify user.
|
||||
/// </summary>
|
||||
/// <param name="password">Password of registered nick.</param>
|
||||
private void SubmitPassword(string password)
|
||||
{
|
||||
if (password == null)
|
||||
throw new ArgumentNullException("password", "Password cannot be null.");
|
||||
|
||||
/* PASS <password> */
|
||||
SendMessage(new IrcMessage(IRC.PASS, password));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register.
|
||||
/// </summary>
|
||||
/// <param name="nickname">New nickname.</param>
|
||||
/// <param name="password">Password. Can be null.</param>
|
||||
/// <param name="realname">Real name. Can be null.</param>
|
||||
public void Register(string nickname, string realname)
|
||||
public void Register(string nickname,
|
||||
string password,
|
||||
string realname)
|
||||
{
|
||||
if (nickname == null)
|
||||
{
|
||||
throw new ArgumentNullException("nickname", "Nickname cannot be null.");
|
||||
}
|
||||
firstPingReceived = false;
|
||||
if (password != null)
|
||||
SubmitPassword(password);
|
||||
ChangeNick(nickname);
|
||||
/* OLD: USER <username> <hostname> <servername> <realname> */
|
||||
/* NEW: USER <user> <mode> <unused> <realname> */
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace TechBot.Library
|
|||
private int port;
|
||||
private string channelnames;
|
||||
private string botname;
|
||||
private string password;
|
||||
private string chmPath;
|
||||
private string mainChm;
|
||||
private string ntstatusXml;
|
||||
|
@ -28,6 +29,7 @@ namespace TechBot.Library
|
|||
int port,
|
||||
string channelnames,
|
||||
string botname,
|
||||
string password,
|
||||
string chmPath,
|
||||
string mainChm,
|
||||
string ntstatusXml,
|
||||
|
@ -41,6 +43,10 @@ namespace TechBot.Library
|
|||
this.port = port;
|
||||
this.channelnames = channelnames;
|
||||
this.botname = botname;
|
||||
if (password == null || password.Trim() == "")
|
||||
this.password = null;
|
||||
else
|
||||
this.password = password;
|
||||
this.chmPath = chmPath;
|
||||
this.mainChm = mainChm;
|
||||
this.ntstatusXml = ntstatusXml;
|
||||
|
@ -72,7 +78,7 @@ namespace TechBot.Library
|
|||
hostname, port));
|
||||
client.Connect(hostname, port);
|
||||
System.Console.WriteLine("Connected...");
|
||||
client.Register(botname, null);
|
||||
client.Register(botname, password, null);
|
||||
System.Console.WriteLine(String.Format("Registered as {0}...", botname));
|
||||
JoinChannels();
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<add key="IRCServerHostPort" value="6667" />
|
||||
<add key="IRCChannelNames" value="channel1;channel2" />
|
||||
<add key="IRCBotName" value="MyBot" />
|
||||
<add key="IRCBotPassword" value="MyPassword" />
|
||||
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
|
||||
<add key="MainChm" value="kmarch.chm" />
|
||||
<add key="NtstatusXml" value="C:\IRC\TechBot\ntstatus.xml" />
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace TechBot
|
|||
private int IRCServerHostPort;
|
||||
private string IRCChannelNames;
|
||||
private string IRCBotName;
|
||||
private string IRCBotPassword;
|
||||
private string ChmPath;
|
||||
private string MainChm;
|
||||
private string NtstatusXml;
|
||||
|
@ -32,6 +33,7 @@ namespace TechBot
|
|||
IRCServerHostPort = Int32.Parse(ConfigurationSettings.AppSettings["IRCServerHostPort"]);
|
||||
IRCChannelNames = ConfigurationSettings.AppSettings["IRCChannelNames"];
|
||||
IRCBotName = ConfigurationSettings.AppSettings["IRCBotName"];
|
||||
IRCBotPassword = ConfigurationSettings.AppSettings["IRCBotPassword"];
|
||||
ChmPath = ConfigurationSettings.AppSettings["ChmPath"];
|
||||
MainChm = ConfigurationSettings.AppSettings["MainChm"];
|
||||
NtstatusXml = ConfigurationSettings.AppSettings["NtstatusXml"];
|
||||
|
@ -51,6 +53,7 @@ namespace TechBot
|
|||
IRCServerHostPort,
|
||||
IRCChannelNames,
|
||||
IRCBotName,
|
||||
IRCBotPassword,
|
||||
ChmPath,
|
||||
MainChm,
|
||||
NtstatusXml,
|
||||
|
|
Loading…
Reference in a new issue