mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +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="IRCServerHostPort" value="6667" />
|
||||||
<add key="IRCChannelNames" value="channel1;channel2" />
|
<add key="IRCChannelNames" value="channel1;channel2" />
|
||||||
<add key="IRCBotName" value="MyBot" />
|
<add key="IRCBotName" value="MyBot" />
|
||||||
|
<add key="IRCBotPassword" value="MyPassword" />
|
||||||
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
|
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
|
||||||
<add key="MainChm" value="kmarch.chm" />
|
<add key="MainChm" value="kmarch.chm" />
|
||||||
<add key="NtstatusXml" value="C:\IRC\TechBot\ntstatus.xml" />
|
<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
|
private static string ChmPath
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -176,6 +188,7 @@ namespace TechBot.Console
|
||||||
IRCServerHostPort,
|
IRCServerHostPort,
|
||||||
IRCChannelNames,
|
IRCChannelNames,
|
||||||
IRCBotName,
|
IRCBotName,
|
||||||
|
IRCBotPassword,
|
||||||
ChmPath,
|
ChmPath,
|
||||||
MainChm,
|
MainChm,
|
||||||
NtstatusXml,
|
NtstatusXml,
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace TechBot.IRCLibrary
|
||||||
public const string PONG = "PONG";
|
public const string PONG = "PONG";
|
||||||
public const string PRIVMSG = "PRIVMSG";
|
public const string PRIVMSG = "PRIVMSG";
|
||||||
public const string USER = "USER";
|
public const string USER = "USER";
|
||||||
|
public const string PASS = "PASS";
|
||||||
|
|
||||||
public const string RPL_NAMREPLY = "353";
|
public const string RPL_NAMREPLY = "353";
|
||||||
public const string RPL_ENDOFNAMES = "366";
|
public const string RPL_ENDOFNAMES = "366";
|
||||||
|
|
|
@ -556,26 +556,40 @@ namespace TechBot.IRCLibrary
|
||||||
public void ChangeNick(string nickname)
|
public void ChangeNick(string nickname)
|
||||||
{
|
{
|
||||||
if (nickname == null)
|
if (nickname == null)
|
||||||
{
|
|
||||||
throw new ArgumentNullException("nickname", "Nickname cannot be null.");
|
throw new ArgumentNullException("nickname", "Nickname cannot be null.");
|
||||||
}
|
|
||||||
|
|
||||||
/* NICK <nickname> [ <hopcount> ] */
|
/* NICK <nickname> [ <hopcount> ] */
|
||||||
SendMessage(new IrcMessage(IRC.NICK, nickname));
|
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>
|
/// <summary>
|
||||||
/// Register.
|
/// Register.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="nickname">New nickname.</param>
|
/// <param name="nickname">New nickname.</param>
|
||||||
|
/// <param name="password">Password. Can be null.</param>
|
||||||
/// <param name="realname">Real name. 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)
|
if (nickname == null)
|
||||||
{
|
|
||||||
throw new ArgumentNullException("nickname", "Nickname cannot be null.");
|
throw new ArgumentNullException("nickname", "Nickname cannot be null.");
|
||||||
}
|
|
||||||
firstPingReceived = false;
|
firstPingReceived = false;
|
||||||
|
if (password != null)
|
||||||
|
SubmitPassword(password);
|
||||||
ChangeNick(nickname);
|
ChangeNick(nickname);
|
||||||
/* OLD: USER <username> <hostname> <servername> <realname> */
|
/* OLD: USER <username> <hostname> <servername> <realname> */
|
||||||
/* NEW: USER <user> <mode> <unused> <realname> */
|
/* NEW: USER <user> <mode> <unused> <realname> */
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace TechBot.Library
|
||||||
private int port;
|
private int port;
|
||||||
private string channelnames;
|
private string channelnames;
|
||||||
private string botname;
|
private string botname;
|
||||||
|
private string password;
|
||||||
private string chmPath;
|
private string chmPath;
|
||||||
private string mainChm;
|
private string mainChm;
|
||||||
private string ntstatusXml;
|
private string ntstatusXml;
|
||||||
|
@ -28,6 +29,7 @@ namespace TechBot.Library
|
||||||
int port,
|
int port,
|
||||||
string channelnames,
|
string channelnames,
|
||||||
string botname,
|
string botname,
|
||||||
|
string password,
|
||||||
string chmPath,
|
string chmPath,
|
||||||
string mainChm,
|
string mainChm,
|
||||||
string ntstatusXml,
|
string ntstatusXml,
|
||||||
|
@ -41,6 +43,10 @@ namespace TechBot.Library
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.channelnames = channelnames;
|
this.channelnames = channelnames;
|
||||||
this.botname = botname;
|
this.botname = botname;
|
||||||
|
if (password == null || password.Trim() == "")
|
||||||
|
this.password = null;
|
||||||
|
else
|
||||||
|
this.password = password;
|
||||||
this.chmPath = chmPath;
|
this.chmPath = chmPath;
|
||||||
this.mainChm = mainChm;
|
this.mainChm = mainChm;
|
||||||
this.ntstatusXml = ntstatusXml;
|
this.ntstatusXml = ntstatusXml;
|
||||||
|
@ -72,7 +78,7 @@ namespace TechBot.Library
|
||||||
hostname, port));
|
hostname, port));
|
||||||
client.Connect(hostname, port);
|
client.Connect(hostname, port);
|
||||||
System.Console.WriteLine("Connected...");
|
System.Console.WriteLine("Connected...");
|
||||||
client.Register(botname, null);
|
client.Register(botname, password, null);
|
||||||
System.Console.WriteLine(String.Format("Registered as {0}...", botname));
|
System.Console.WriteLine(String.Format("Registered as {0}...", botname));
|
||||||
JoinChannels();
|
JoinChannels();
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<add key="IRCServerHostPort" value="6667" />
|
<add key="IRCServerHostPort" value="6667" />
|
||||||
<add key="IRCChannelNames" value="channel1;channel2" />
|
<add key="IRCChannelNames" value="channel1;channel2" />
|
||||||
<add key="IRCBotName" value="MyBot" />
|
<add key="IRCBotName" value="MyBot" />
|
||||||
|
<add key="IRCBotPassword" value="MyPassword" />
|
||||||
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
|
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
|
||||||
<add key="MainChm" value="kmarch.chm" />
|
<add key="MainChm" value="kmarch.chm" />
|
||||||
<add key="NtstatusXml" value="C:\IRC\TechBot\ntstatus.xml" />
|
<add key="NtstatusXml" value="C:\IRC\TechBot\ntstatus.xml" />
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace TechBot
|
||||||
private int IRCServerHostPort;
|
private int IRCServerHostPort;
|
||||||
private string IRCChannelNames;
|
private string IRCChannelNames;
|
||||||
private string IRCBotName;
|
private string IRCBotName;
|
||||||
|
private string IRCBotPassword;
|
||||||
private string ChmPath;
|
private string ChmPath;
|
||||||
private string MainChm;
|
private string MainChm;
|
||||||
private string NtstatusXml;
|
private string NtstatusXml;
|
||||||
|
@ -32,6 +33,7 @@ namespace TechBot
|
||||||
IRCServerHostPort = Int32.Parse(ConfigurationSettings.AppSettings["IRCServerHostPort"]);
|
IRCServerHostPort = Int32.Parse(ConfigurationSettings.AppSettings["IRCServerHostPort"]);
|
||||||
IRCChannelNames = ConfigurationSettings.AppSettings["IRCChannelNames"];
|
IRCChannelNames = ConfigurationSettings.AppSettings["IRCChannelNames"];
|
||||||
IRCBotName = ConfigurationSettings.AppSettings["IRCBotName"];
|
IRCBotName = ConfigurationSettings.AppSettings["IRCBotName"];
|
||||||
|
IRCBotPassword = ConfigurationSettings.AppSettings["IRCBotPassword"];
|
||||||
ChmPath = ConfigurationSettings.AppSettings["ChmPath"];
|
ChmPath = ConfigurationSettings.AppSettings["ChmPath"];
|
||||||
MainChm = ConfigurationSettings.AppSettings["MainChm"];
|
MainChm = ConfigurationSettings.AppSettings["MainChm"];
|
||||||
NtstatusXml = ConfigurationSettings.AppSettings["NtstatusXml"];
|
NtstatusXml = ConfigurationSettings.AppSettings["NtstatusXml"];
|
||||||
|
@ -51,6 +53,7 @@ namespace TechBot
|
||||||
IRCServerHostPort,
|
IRCServerHostPort,
|
||||||
IRCChannelNames,
|
IRCChannelNames,
|
||||||
IRCBotName,
|
IRCBotName,
|
||||||
|
IRCBotPassword,
|
||||||
ChmPath,
|
ChmPath,
|
||||||
MainChm,
|
MainChm,
|
||||||
NtstatusXml,
|
NtstatusXml,
|
||||||
|
|
Loading…
Reference in a new issue