--- /dev/null
+using System;
+
+using TechBot.Library;
+
+namespace TechBot.Commands.Common
+{
+ public abstract class BugCommand : Command
+ {
+ private string m_BugID = null;
+
+ public BugCommand()
+ {
+ }
+
+ public string BugID
+ {
+ get { return Parameters; }
+ set { Parameters = value; }
+ }
+
+ public override void ExecuteCommand()
+ {
+ if (Parameters == null)
+ {
+ Say("Please provide a valid bug number.");
+ }
+ else
+ {
+ try
+ {
+ Say(BugUrl, Int32.Parse(BugID));
+ }
+ catch (Exception)
+ {
+ Say("{0} is not a valid bug number.", BugID);
+ }
+ }
+ }
+
+ protected abstract string BugUrl { get; }
+ }
+}
--- /dev/null
+using System;
+using System.Xml;
+
+using TechBot.Library;
+
+namespace TechBot.Commands.Common
+{
+ [Command("hresult", Help = "!hresult <value>")]
+ public class HResultCommand : XmlLookupCommand
+ {
+ public HResultCommand()
+ {
+ }
+
+ public override string XmlFile
+ {
+ get { return Settings.Default.HResultXml; }
+ }
+
+ public override void ExecuteCommand()
+ {
+ if (Text == null)
+ {
+ Say("Please provide a valid HRESULT value.");
+ }
+ else
+ {
+ NumberParser np = new NumberParser();
+ long hresult = np.Parse(Text);
+ if (np.Error)
+ {
+ Say("{0} is not a valid HRESULT value.", Text);
+ return;
+ }
+
+ string description = GetHresultDescription(hresult);
+ if (description != null)
+ {
+ Say("{0} is {1}.",
+ Text,
+ description);
+ }
+ else
+ {
+ Say("I don't know about HRESULT {0}.", Text);
+ }
+ }
+ }
+
+ public string GetHresultDescription(long hresult)
+ {
+ XmlElement root = base.m_XmlDocument.DocumentElement;
+ XmlNode node = root.SelectSingleNode(String.Format("Hresult[@value='{0}']",
+ hresult.ToString("X8")));
+ if (node != null)
+ {
+ XmlAttribute text = node.Attributes["text"];
+ if (text == null)
+ throw new Exception("Node has no text attribute.");
+ return text.Value;
+ }
+ else
+ return null;
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Xml;
+
+using TechBot.Library;
+
+namespace TechBot.Commands.Common
+{
+ [Command("ntstatus", Help = "!ntstatus <value>")]
+ public class NtStatusCommand : XmlLookupCommand
+ {
+ public NtStatusCommand()
+ {
+ }
+
+ public override string XmlFile
+ {
+ get { return Settings.Default.NtStatusXml; }
+ }
+
+ public override void ExecuteCommand()
+ {
+ if (Text == null)
+ {
+ Say("Please provide a valid NTSTATUS value.");
+ }
+ else
+ {
+ NumberParser np = new NumberParser();
+ long ntstatus = np.Parse(Text);
+ if (np.Error)
+ {
+ Say("{0} is not a valid NTSTATUS value.", Text);
+ return;
+ }
+
+ string description = GetNtstatusDescription(ntstatus);
+ if (description != null)
+ {
+ Say("{0} is {1}.",
+ Text,
+ description);
+ }
+ else
+ {
+ Say("I don't know about NTSTATUS {0}.", Text);
+ }
+ }
+ }
+
+ public string GetNtstatusDescription(long ntstatus)
+ {
+ XmlElement root = base.m_XmlDocument.DocumentElement;
+ XmlNode node = root.SelectSingleNode(String.Format("Ntstatus[@value='{0}']",
+ ntstatus.ToString("X8")));
+ if (node != null)
+ {
+ XmlAttribute text = node.Attributes["text"];
+ if (text == null)
+ throw new Exception("Node has no text attribute.");
+ return text.Value;
+ }
+ else
+ return null;
+ }
+ }
+}
--- /dev/null
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("TechBot.Commands.Common")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Sand")]
+[assembly: AssemblyProduct("TechBot.Commands.Common")]
+[assembly: AssemblyCopyright("Copyright © Sand 2008")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("5d39d6f8-37fb-423b-ba88-1d5d8e5a1317")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using TechBot.Library;
+
+namespace TechBot.Commands.Common
+{
+ [Command("rosbug", Help = "!rosbug <number>", Description = "Will give you a link to the reqested ReactOS bug")]
+ class ReactOSBugUrl : BugCommand
+ {
+ public ReactOSBugUrl()
+ {
+ }
+
+ protected override string BugUrl
+ {
+ get { return "http://www.reactos.org/bugzilla/show_bug.cgi?id={0}"; }
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using TechBot.Library;
+
+namespace TechBot.Commands.Common
+{
+ [Command("sambabug", Help = "!sambabug <number>", Description = "Will give you a link to the reqested Samba bug")]
+ class SambaBugUrl : BugCommand
+ {
+ public SambaBugUrl()
+ {
+ }
+
+ protected override string BugUrl
+ {
+ get { return "https://bugzilla.samba.org/show_bug.cgi?id={0}"; }
+ }
+ }
+}
--- /dev/null
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace TechBot.Commands.Common {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\ntstatus.xml")]
+ public string NtStatusXml {
+ get {
+ return ((string)(this["NtStatusXml"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\winerror.xml")]
+ public string WinErrorXml {
+ get {
+ return ((string)(this["WinErrorXml"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\hresult.xml")]
+ public string HResultXml {
+ get {
+ return ((string)(this["HResultXml"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\wm.xml")]
+ public string WMXml {
+ get {
+ return ((string)(this["WMXml"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("svn://svn.reactos.org/trunk/reactos")]
+ public string SVNRoot {
+ get {
+ return ((string)(this["SVNRoot"]));
+ }
+ }
+ }
+}
--- /dev/null
+namespace TechBot.Commands.Common {
+
+
+ // This class allows you to handle specific events on the settings class:
+ // The SettingChanging event is raised before a setting's value is changed.
+ // The PropertyChanged event is raised after a setting's value is changed.
+ // The SettingsLoaded event is raised after the setting values are loaded.
+ // The SettingsSaving event is raised before the setting values are saved.
+ internal sealed partial class Settings {
+
+ public Settings() {
+ // // To add event handlers for saving and changing settings, uncomment the lines below:
+ //
+ // this.SettingChanging += this.SettingChangingEventHandler;
+ //
+ // this.SettingsSaving += this.SettingsSavingEventHandler;
+ //
+ }
+
+ private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
+ // Add code to handle the SettingChangingEvent event here.
+ }
+
+ private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
+ // Add code to handle the SettingsSaving event here.
+ }
+ }
+}
--- /dev/null
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot.Commands.Common" GeneratedClassName="Settings">
+ <Profiles />
+ <Settings>
+ <Setting Name="NtStatusXml" Type="System.String" Scope="Application">
+ <Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\ntstatus.xml</Value>
+ </Setting>
+ <Setting Name="WinErrorXml" Type="System.String" Scope="Application">
+ <Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\winerror.xml</Value>
+ </Setting>
+ <Setting Name="HResultXml" Type="System.String" Scope="Application">
+ <Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\hresult.xml</Value>
+ </Setting>
+ <Setting Name="WMXml" Type="System.String" Scope="Application">
+ <Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\wm.xml</Value>
+ </Setting>
+ <Setting Name="SVNRoot" Type="System.String" Scope="Application">
+ <Value Profile="(Default)">svn://svn.reactos.org/trunk/reactos</Value>
+ </Setting>
+ </Settings>
+</SettingsFile>
\ No newline at end of file
--- /dev/null
+using System;
+
+using TechBot.Library;
+
+namespace TechBot.Commands.Common
+{
+ [Command("svn", Help = "!svn" , Description="Where the ROS SVN repository is located")]
+ public class SvnCommand : Command
+ {
+ private string m_SvnRoot;
+
+ public SvnCommand()
+ {
+ m_SvnRoot = Settings.Default.SVNRoot;
+ }
+
+ public override void ExecuteCommand()
+ {
+ Say("svn co {0}", m_SvnRoot);
+ }
+ }
+}
--- /dev/null
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>TechBot.Commands.Common</RootNamespace>
+ <AssemblyName>TechBot.Commands.Common</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Base\BugCommand.cs" />
+ <Compile Include="HResultCommand.cs" />
+ <Compile Include="NtStatusCommand.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="ReactOSBugUrl.cs" />
+ <Compile Include="SambaBugUrl.cs" />
+ <Compile Include="Settings.cs" />
+ <Compile Include="Settings.Designer.cs">
+ <DependentUpon>Settings.settings</DependentUpon>
+ <AutoGen>True</AutoGen>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ <Compile Include="SvnCommand.cs" />
+ <Compile Include="WineBugUrl.cs" />
+ <Compile Include="WinerrorCommand.cs" />
+ <Compile Include="WMCommand.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\TechBot.Library\TechBot.Library.csproj">
+ <Project>{1114F34D-F388-4F38-AE27-C0EE1B10B777}</Project>
+ <Name>TechBot.Library</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
--- /dev/null
+using System;
+using System.Xml;
+
+using TechBot.Library;
+
+namespace TechBot.Commands.Common
+{
+ [Command("wm" , Help = "!wm <value> or !wm <name>")]
+ public class WMCommand : XmlCommand
+ {
+ public WMCommand()
+ {
+ }
+
+ public override string XmlFile
+ {
+ get { return Settings.Default.WMXml; }
+ }
+
+ [CommandParameter("wm", "The windows message to check" , DefaultParameter = true)]
+ public string WMText
+ {
+ get { return Parameters; }
+ set { Parameters = value; }
+ }
+
+ public override void ExecuteCommand()
+ {
+ if (WMText == null)
+ {
+ Say("Please provide a valid window message value or name.");
+
+ }
+ else
+ {
+ NumberParser np = new NumberParser();
+ long wm = np.Parse(WMText);
+ string output;
+ if (np.Error)
+ {
+ // Assume "!wm <name>" form.
+ output = GetWmNumber(WMText);
+ }
+ else
+ {
+ output = GetWmDescription(wm);
+ }
+
+ if (output != null)
+ {
+ Say("{0} is {1}.",
+ WMText,
+ output);
+ }
+ else
+ {
+ Say("I don't know about window message {0}.", WMText);
+ }
+ }
+ }
+
+ private string GetWmDescription(long wm)
+ {
+ XmlElement root = base.m_XmlDocument.DocumentElement;
+ XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@value='{0}']",
+ wm));
+ if (node != null)
+ {
+ XmlAttribute text = node.Attributes["text"];
+ if (text == null)
+ throw new Exception("Node has no text attribute.");
+ return text.Value;
+ }
+ else
+ return null;
+ }
+
+ private string GetWmNumber(string wmName)
+ {
+ XmlElement root = base.m_XmlDocument.DocumentElement;
+ XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@text='{0}']",
+ wmName));
+ if (node != null)
+ {
+ XmlAttribute value = node.Attributes["value"];
+ if (value == null)
+ throw new Exception("Node has no value attribute.");
+ return value.Value;
+ }
+ else
+ return null;
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using TechBot.Library;
+
+namespace TechBot.Commands.Common
+{
+ [Command("winebug", Help = "!winebug <number>" , Description="Will give you a link to the reqested Wine bug")]
+ class WineBugUrl : BugCommand
+ {
+ public WineBugUrl()
+ {
+ }
+
+ protected override string BugUrl
+ {
+ get { return "http://bugs.winehq.org/show_bug.cgi?id={0}"; }
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Xml;
+
+using TechBot.Library;
+
+namespace TechBot.Commands.Common
+{
+ [Command("winerror", Help = "!winerror <value>")]
+ public class WinErrorCommand : XmlLookupCommand
+ {
+ public WinErrorCommand()
+ {
+ }
+
+ public override string XmlFile
+ {
+ get { return Settings.Default.WinErrorXml; }
+ }
+
+ public override void ExecuteCommand()
+ {
+ if (Text == null)
+ {
+ Say("Please provide a valid System Error Code value.");
+ }
+ else
+ {
+ NumberParser np = new NumberParser();
+ long winerror = np.Parse(Text);
+ if (np.Error)
+ {
+ Say("{0} is not a valid System Error Code value.", Text);
+ return;
+ }
+
+ string description = GetWinerrorDescription(winerror);
+ if (description != null)
+ {
+ Say("{0} is {1}.",
+ Text,
+ description);
+ }
+ else
+ {
+ Say("I don't know about System Error Code {0}.", Text);
+ }
+ }
+ }
+
+ public string GetWinerrorDescription(long winerror)
+ {
+ XmlElement root = base.m_XmlDocument.DocumentElement;
+ XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']",
+ Text));
+ if (node != null)
+ {
+ XmlAttribute text = node.Attributes["text"];
+ if (text == null)
+ throw new Exception("Node has no text attribute.");
+ return text.Value;
+ }
+ else
+ return null;
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configSections>
+ <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
+ <section name="TechBot.Commands.Common.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+ </sectionGroup>
+ </configSections>
+ <applicationSettings>
+ <TechBot.Commands.Common.Settings>
+ <setting name="NtStatusXml" serializeAs="String">
+ <value>C:\Ros\current\irc\TechBot\Resources\ntstatus.xml</value>
+ </setting>
+ <setting name="WinErrorXml" serializeAs="String">
+ <value>C:\Ros\current\irc\TechBot\Resources\winerror.xml</value>
+ </setting>
+ <setting name="HResultXml" serializeAs="String">
+ <value>C:\Ros\current\irc\TechBot\Resources\hresult.xml</value>
+ </setting>
+ <setting name="WMXml" serializeAs="String">
+ <value>C:\Ros\current\irc\TechBot\Resources\wm.xml</value>
+ </setting>
+ <setting name="SVNRoot" serializeAs="String">
+ <value>svn://svn.reactos.org/trunk/reactos</value>
+ </setting>
+ </TechBot.Commands.Common.Settings>
+ </applicationSettings>
+</configuration>
\ No newline at end of file
--- /dev/null
+using System;
+using System.IO;
+using System.Data;
+using System.Text.RegularExpressions;
+
+using HtmlHelp;
+using HtmlHelp.ChmDecoding;
+
+using TechBot.Library;
+
+namespace TechBot.Commands.MSDN
+{
+ [Command("api", Help = "!api <apiname>")]
+ public class ApiCommand : Command
+ {
+ private bool IsVerbose = false;
+
+ private HtmlHelpSystem chm;
+ private string name;
+
+ public ApiCommand()
+ {
+ Run();
+ }
+
+ [CommandParameter("api", "The API name")]
+ public string API
+ {
+ get { return Parameters; }
+ set { Parameters = value; }
+ }
+
+ private void WriteIfVerbose(string message)
+ {
+ if (IsVerbose)
+ Say(message);
+ }
+
+ private void Run()
+ {
+ string CHMFilename = Path.Combine(Settings.Default.ChmPath, Settings.Default.MainChm);
+ chm = new HtmlHelpSystem();
+ chm.OpenFile(CHMFilename, null);
+
+ Console.WriteLine(String.Format("Loaded main CHM: {0}",
+ Path.GetFileName(CHMFilename)));
+ foreach (string filename in Directory.GetFiles(Settings.Default.ChmPath))
+ {
+ if (!Path.GetExtension(filename).ToLower().Equals(".chm"))
+ continue;
+ if (Path.GetFileName(filename).ToLower().Equals(Settings.Default.MainChm))
+ continue;
+
+ Console.WriteLine(String.Format("Loading CHM: {0}",
+ Path.GetFileName(filename)));
+ try
+ {
+ chm.MergeFile(filename);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(String.Format("Could not load CHM: {0}. Exception {1}",
+ Path.GetFileName(filename),
+ ex));
+ }
+ }
+ Console.WriteLine(String.Format("Loaded {0} CHMs",
+ chm.FileList.Length));
+ }
+
+ public override void ExecuteCommand()
+ {
+ if (Name.Trim().Equals(String.Empty))
+ {
+ Say("Please give me a keyword.");
+ }
+ else
+ {
+ Search(Name);
+ }
+ }
+
+ private bool SearchIndex(
+ string keyword)
+ {
+ if (chm.HasIndex)
+ {
+ IndexItem item = chm.Index.SearchIndex(keyword,
+ IndexType.KeywordLinks);
+ if (item != null && item.Topics.Count > 0)
+ {
+ WriteIfVerbose(String.Format("Keyword {0} found in index",
+ item.KeyWord));
+ IndexTopic indexTopic = item.Topics[0] as IndexTopic;
+ return DisplayResult( keyword,
+ indexTopic);
+ }
+ else
+ {
+ WriteIfVerbose(String.Format("Keyword {0} not found in index",
+ keyword));
+ return false;
+ }
+ }
+ else
+ return false;
+ }
+
+ private void SearchFullText(string keyword)
+ {
+ string sort = "Rating ASC";
+ WriteIfVerbose(String.Format("Searching fulltext database for {0}",
+ keyword));
+
+ bool partialMatches = false;
+ bool titlesOnly = true;
+ int maxResults = 100;
+ DataTable results = chm.PerformSearch(keyword,
+ maxResults,
+ partialMatches,
+ titlesOnly);
+ WriteIfVerbose(String.Format("results.Rows.Count = {0}",
+ results != null ?
+ results.Rows.Count.ToString() : "(none)"));
+ if (results != null && results.Rows.Count > 0)
+ {
+ results.DefaultView.Sort = sort;
+ if (!DisplayResult(keyword,
+ results))
+ {
+ Say("No result");
+ }
+ }
+ else
+ {
+ Say("No result");
+ }
+ }
+
+ private void Search(string keyword)
+ {
+ if (!SearchIndex(keyword))
+ SearchFullText(keyword);
+ }
+
+ private bool DisplayResult(string keyword,
+ IndexTopic indexTopic)
+ {
+ keyword = keyword.Trim().ToLower();
+ string url = indexTopic.URL;
+ WriteIfVerbose(String.Format("URL from index search {0}",
+ url));
+ string prototype = ExtractPrototype(url);
+ if (prototype == null || prototype.Trim().Equals(String.Empty))
+ return false;
+ string formattedPrototype = FormatPrototype(prototype);
+ Say(formattedPrototype);
+ return true;
+ }
+
+ private bool DisplayResult(string keyword,
+ DataTable results)
+ {
+ keyword = keyword.Trim().ToLower();
+ for (int i = 0; i < results.DefaultView.Count; i++)
+ {
+ DataRowView row = results.DefaultView[i];
+ string title = row["Title"].ToString();
+ WriteIfVerbose(String.Format("Examining {0}", title));
+ if (title.Trim().ToLower().Equals(keyword))
+ {
+ string location = row["Location"].ToString();
+ string rating = row["Rating"].ToString();
+ string url = row["Url"].ToString();
+ string prototype = ExtractPrototype(url);
+ if (prototype == null || prototype.Trim().Equals(String.Empty))
+ continue;
+ string formattedPrototype = FormatPrototype(prototype);
+ Say(formattedPrototype);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void DisplayNoResult(MessageContext context,
+ string keyword)
+ {
+ TechBot.ServiceOutput.WriteLine(context,
+ String.Format("I don't know about keyword {0}",
+ keyword));
+ }
+
+ private string ReplaceComments(string s)
+ {
+ return Regex.Replace(s, "//(.+)\r\n", "");
+ }
+
+ private string ReplaceLineEndings(string s)
+ {
+ return Regex.Replace(s, "(\r\n)+", " ");
+ }
+
+ private string ReplaceSpaces(string s)
+ {
+ return Regex.Replace(s, @" +", " ");
+ }
+
+ private string ReplaceSpacesBeforeLeftParenthesis(string s)
+ {
+ return Regex.Replace(s, @"\( ", @"(");
+ }
+
+ private string ReplaceSpacesBeforeRightParenthesis(string s)
+ {
+ return Regex.Replace(s, @" \)", @")");
+ }
+
+ private string ReplaceSemicolon(string s)
+ {
+ return Regex.Replace(s, @";", @"");
+ }
+
+ private string FormatPrototype(string prototype)
+ {
+ string s = ReplaceComments(prototype);
+ s = ReplaceLineEndings(s);
+ s = ReplaceSpaces(s);
+ s = ReplaceSpacesBeforeLeftParenthesis(s);
+ s = ReplaceSpacesBeforeRightParenthesis(s);
+ s = ReplaceSemicolon(s);
+ return s;
+ }
+
+ private string ExtractPrototype(string url)
+ {
+ string page = GetPage(url);
+ Match match = Regex.Match(page,
+ "<PRE class=\"?syntax\"?>(.+)</PRE>",
+ RegexOptions.Multiline |
+ RegexOptions.Singleline);
+ if (match.Groups.Count > 1)
+ {
+ string prototype = match.Groups[1].ToString();
+ return StripHtml(StripAfterSlashPre(prototype));
+ }
+
+ return "";
+ }
+
+ private string StripAfterSlashPre(string html)
+ {
+ int index = html.IndexOf("</PRE>");
+ if (index != -1)
+ {
+ return html.Substring(0, index);
+ }
+ else
+ return html;
+ }
+
+ private string StripHtml(string html)
+ {
+ return Regex.Replace(html, @"<(.|\n)*?>", String.Empty);
+ }
+
+ private string GetPage(string url)
+ {
+ string CHMFileName = "";
+ string topicName = "";
+ string anchor = "";
+ CHMStream.CHMStream baseStream;
+ if (!chm.BaseStream.GetCHMParts(url, ref CHMFileName, ref topicName, ref anchor))
+ {
+ baseStream = chm.BaseStream;
+ CHMFileName = baseStream.CHMFileName;
+ topicName = url;
+ anchor = "";
+ }
+ else
+ {
+ baseStream = GetBaseStreamFromCHMFileName(CHMFileName);
+ }
+
+ if ((topicName == "") || (CHMFileName == "") || (baseStream == null))
+ {
+ return "";
+ }
+
+ return baseStream.ExtractTextFile(topicName);
+ }
+
+ private CHMStream.CHMStream GetBaseStreamFromCHMFileName(string CHMFileName)
+ {
+ foreach (CHMFile file in chm.FileList)
+ {
+ WriteIfVerbose(String.Format("Compare: {0} <> {1}",
+ file.ChmFilePath,
+ CHMFileName));
+ if (file.ChmFilePath.ToLower().Equals(CHMFileName.ToLower()))
+ {
+ return file.BaseStream;
+ }
+ }
+ WriteIfVerbose(String.Format("Could not find loaded CHM file in list: {0}",
+ CHMFileName));
+ return null;
+ }
+ }
+}
--- /dev/null
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("TechBot.Commands.MSDN")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Sand")]
+[assembly: AssemblyProduct("TechBot.Commands.MSDN")]
+[assembly: AssemblyCopyright("Copyright © Sand 2008")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("8a6332ce-82e3-4fbd-a799-8f4b8d025955")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
--- /dev/null
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace TechBot.Commands.MSDN {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("C:\\IRC\\TechBot\\CHM")]
+ public string ChmPath {
+ get {
+ return ((string)(this["ChmPath"]));
+ }
+ set {
+ this["ChmPath"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("kmarch.chm")]
+ public string MainChm {
+ get {
+ return ((string)(this["MainChm"]));
+ }
+ set {
+ this["MainChm"] = value;
+ }
+ }
+ }
+}
--- /dev/null
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot.Commands.MSDN" GeneratedClassName="Settings">
+ <Profiles />
+ <Settings>
+ <Setting Name="ChmPath" Type="System.String" Scope="User">
+ <Value Profile="(Default)">C:\IRC\TechBot\CHM</Value>
+ </Setting>
+ <Setting Name="MainChm" Type="System.String" Scope="User">
+ <Value Profile="(Default)">kmarch.chm</Value>
+ </Setting>
+ </Settings>
+</SettingsFile>
\ No newline at end of file
--- /dev/null
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>TechBot.Commands.MSDN</RootNamespace>
+ <AssemblyName>TechBot.Commands.MSDN</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ApiCommand.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ <DependentUpon>Settings.settings</DependentUpon>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\CHMLibrary\CHMLibrary.csproj">
+ <Project>{72E5CCA1-6318-4D62-964D-CB23A5C743B5}</Project>
+ <Name>CHMLibrary</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\TechBot.Library\TechBot.Library.csproj">
+ <Project>{1114F34D-F388-4F38-AE27-C0EE1B10B777}</Project>
+ <Name>TechBot.Library</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
--- /dev/null
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ProjectView>ProjectFiles</ProjectView>
+ </PropertyGroup>
+</Project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configSections>
+ <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
+ <section name="TechBot.Commands.MSDN.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
+ </sectionGroup>
+ </configSections>
+ <userSettings>
+ <TechBot.Commands.MSDN.Settings>
+ <setting name="ChmPath" serializeAs="String">
+ <value>C:\IRC\TechBot\CHM</value>
+ </setting>
+ <setting name="MainChm" serializeAs="String">
+ <value>kmarch.chm</value>
+ </setting>
+ </TechBot.Commands.MSDN.Settings>
+ </userSettings>
+</configuration>
\ No newline at end of file
-<?xml version="1.0" encoding="utf-8" ?>\r
-<configuration>\r
- <appSettings>\r
- <add key="IRCServerHostName" value="irc.eu.freenode.net" />\r
- <add key="IRCServerHostPort" value="6667" />\r
- <add key="IRCChannelNames" value="channel1;channel2" />\r
- <add key="IRCBotName" value="MyBot" />\r
- <add key="IRCBotPassword" value="MyPassword" />\r
- <add key="ChmPath" value="C:\IRC\TechBot\CHM" />\r
- <add key="MainChm" value="kmarch.chm" />\r
- <add key="BugUrl" value="http://www.reactos.org/bugzilla/show_bug.cgi?id={0}" />\r
- <add key="WineBugUrl" value="http://bugs.winehq.org/show_bug.cgi?id={0}" />\r
- <add key="SambaBugUrl" value="https://bugzilla.samba.org/show_bug.cgi?id={0}" />\r
- </appSettings>\r
-</configuration>\r
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configSections>
+ <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
+ <section name="TechBot.Console.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
+ </sectionGroup>
+ </configSections>
+ <userSettings>
+ <TechBot.Console.Settings>
+ <setting name="IRCServerHostName" serializeAs="String">
+ <value>irc.eu.freenode.net</value>
+ </setting>
+ <setting name="IRCChannelNames" serializeAs="String">
+ <value>rbuildbottest2</value>
+ </setting>
+ <setting name="IRCBotName" serializeAs="String">
+ <value>RBuildBot2</value>
+ </setting>
+ <setting name="IRCBotPassword" serializeAs="String">
+ <value>qwerty</value>
+ </setting>
+ <setting name="IRCServerHostPort" serializeAs="String">
+ <value>6667</value>
+ </setting>
+ </TechBot.Console.Settings>
+ </userSettings>
+</configuration>
\ No newline at end of file
public class ConsoleTechBotService : TechBotService
{
- public ConsoleTechBotService(
- string chmPath,
- string mainChm)
- : base(new ConsoleServiceOutput(), chmPath, mainChm)
+ public ConsoleTechBotService()
+ : base(new ConsoleServiceOutput())
{
+ System.Console.WriteLine("TechBot running console service...");
}
public override void Run()
while (true)
{
- string s = System.Console.ReadLine();
- InjectMessage(null, s);
+ InjectMessage(System.Console.ReadLine());
}
}
}
-using System;\r
-using System.Configuration;\r
-using TechBot.Library;\r
-\r
-namespace TechBot.Console\r
-{\r
- class MainClass\r
- {\r
- private static void VerifyRequiredOption(string optionName,\r
- string optionValue)\r
- {\r
- if (optionValue == null)\r
- {\r
- throw new Exception(String.Format("Option '{0}' not set.",\r
- optionName));\r
- }\r
- }\r
- \r
- private static string IRCServerHostName\r
- {\r
- get\r
- {\r
- string optionName = "IRCServerHostName";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return s;\r
- }\r
- }\r
-\r
- private static int IRCServerHostPort\r
- {\r
- get\r
- {\r
- string optionName = "IRCServerHostPort";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return Int32.Parse(s);\r
- }\r
- }\r
-\r
- private static string IRCChannelNames\r
- {\r
- get\r
- {\r
- string optionName = "IRCChannelNames";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return s;\r
- }\r
- }\r
-\r
- private static string IRCBotName\r
- {\r
- get\r
- {\r
- string optionName = "IRCBotName";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return s;\r
- }\r
- }\r
-\r
- private static string IRCBotPassword\r
- {\r
- get\r
- {\r
- string optionName = "IRCBotPassword";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return s;\r
- }\r
- }\r
-\r
- private static string ChmPath\r
- {\r
- get\r
- {\r
- string optionName = "ChmPath";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return s;\r
- }\r
- }\r
- \r
- private static string MainChm\r
- {\r
- get\r
- {\r
- string optionName = "MainChm";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return s;\r
- }\r
- }\r
-\r
- private static string NtstatusXml\r
- {\r
- get\r
- {\r
- string optionName = "NtstatusXml";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return s;\r
- }\r
- }\r
-\r
- private static string WinerrorXml\r
- {\r
- get\r
- {\r
- string optionName = "WinerrorXml";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return s;\r
- }\r
- }\r
-\r
- private static string HresultXml\r
- {\r
- get\r
- {\r
- string optionName = "HresultXml";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return s;\r
- }\r
- }\r
-\r
- private static string WmXml\r
- {\r
- get\r
- {\r
- string optionName = "WmXml";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return s;\r
- }\r
- }\r
-\r
- private static string SvnCommand\r
- {\r
- get\r
- {\r
- string optionName = "SvnCommand";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return s;\r
- }\r
- }\r
-\r
- private static string BugUrl\r
- {\r
- get\r
- {\r
- string optionName = "BugUrl";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return s;\r
- }\r
- }\r
-\r
- private static string WineBugUrl\r
- {\r
- get\r
- {\r
- string optionName = "WineBugUrl";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return s;\r
- }\r
- }\r
-\r
-\r
- private static string SambaBugUrl\r
- {\r
- get\r
- {\r
- string optionName = "SambaBugUrl";\r
- string s = ConfigurationSettings.AppSettings[optionName];\r
- VerifyRequiredOption(optionName,\r
- s);\r
- return s;\r
- }\r
- }\r
-\r
-\r
- //private static void RunIrcService()\r
- //{\r
- // IrcTechBotService ircService = new IrcTechBotService(IRCServerHostName,\r
- // IRCServerHostPort,\r
- // IRCChannelNames,\r
- // IRCBotName,\r
- // IRCBotPassword,\r
- // ChmPath,\r
- // MainChm);\r
- // ircService.Run();\r
- //}\r
-\r
- public static void Main(string[] args)\r
- {\r
- TechBotService m_TechBot = null;\r
-\r
- if (args.Length > 0 && args[0].ToLower().Equals("irc"))\r
- {\r
- m_TechBot = new IrcTechBotService(IRCServerHostName,\r
- IRCServerHostPort,\r
- IRCChannelNames,\r
- IRCBotName,\r
- IRCBotPassword,\r
- ChmPath,\r
- MainChm);\r
- }\r
- else\r
- {\r
- System.Console.WriteLine("TechBot running console service...");\r
- m_TechBot = new ConsoleTechBotService(\r
- ChmPath,\r
- MainChm);\r
-\r
-\r
- }\r
-\r
- m_TechBot.Run();\r
- }\r
- }\r
+using System;
+using System.Configuration;
+using TechBot.Library;
+
+namespace TechBot.Console
+{
+ class MainClass
+ {
+ public static void Main(string[] args)
+ {
+ TechBotService m_TechBot = null;
+
+ if (args.Length > 0 && args[0].ToLower().Equals("irc"))
+ {
+ m_TechBot = new IrcTechBotService(Settings.Default.IRCServerHostName,
+ Settings.Default.IRCServerHostPort,
+ Settings.Default.IRCChannelNames,
+ Settings.Default.IRCBotName,
+ Settings.Default.IRCBotPassword);
+ }
+ else
+ {
+ m_TechBot = new ConsoleTechBotService();
+ }
+
+ m_TechBot.Run();
+ }
+ }
}
\ No newline at end of file
--- /dev/null
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace TechBot.Console {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("irc.eu.freenode.net")]
+ public string IRCServerHostName {
+ get {
+ return ((string)(this["IRCServerHostName"]));
+ }
+ set {
+ this["IRCServerHostName"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("rbuildbottest2")]
+ public string IRCChannelNames {
+ get {
+ return ((string)(this["IRCChannelNames"]));
+ }
+ set {
+ this["IRCChannelNames"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("RBuildBot2")]
+ public string IRCBotName {
+ get {
+ return ((string)(this["IRCBotName"]));
+ }
+ set {
+ this["IRCBotName"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("qwerty")]
+ public string IRCBotPassword {
+ get {
+ return ((string)(this["IRCBotPassword"]));
+ }
+ set {
+ this["IRCBotPassword"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("6667")]
+ public int IRCServerHostPort {
+ get {
+ return ((int)(this["IRCServerHostPort"]));
+ }
+ set {
+ this["IRCServerHostPort"] = value;
+ }
+ }
+ }
+}
--- /dev/null
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot.Console" GeneratedClassName="Settings">
+ <Profiles />
+ <Settings>
+ <Setting Name="IRCServerHostName" Type="System.String" Scope="User">
+ <Value Profile="(Default)">irc.eu.freenode.net</Value>
+ </Setting>
+ <Setting Name="IRCChannelNames" Type="System.String" Scope="User">
+ <Value Profile="(Default)">rbuildbottest2</Value>
+ </Setting>
+ <Setting Name="IRCBotName" Type="System.String" Scope="User">
+ <Value Profile="(Default)">RBuildBot2</Value>
+ </Setting>
+ <Setting Name="IRCBotPassword" Type="System.String" Scope="User">
+ <Value Profile="(Default)">qwerty</Value>
+ </Setting>
+ <Setting Name="IRCServerHostPort" Type="System.Int32" Scope="User">
+ <Value Profile="(Default)">6667</Value>
+ </Setting>
+ </Settings>
+</SettingsFile>
\ No newline at end of file
<Compile Include="AssemblyInfo.cs" />
<Compile Include="ConsoleTechBotService.cs" />
<Compile Include="Main.cs" />
+ <Compile Include="Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ <DependentUpon>Settings.settings</DependentUpon>
+ </Compile>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\TechBot.Commands.Common\TechBot.Commands.Common.csproj">
+ <Project>{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}</Project>
+ <Name>TechBot.Commands.Common</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\TechBot.Commands.RBuild\TechBot.Commands.RBuild.csproj">
+ <Project>{D676FEDE-62DD-4B4D-94C6-308598E827F9}</Project>
+ <Name>TechBot.Commands.RBuild</Name>
+ </ProjectReference>
<ProjectReference Include="..\TechBot.IRCLibrary\TechBot.IRCLibrary.csproj">
<Project>{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}</Project>
<Name>TechBot.IRCLibrary</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <None Include="App.config" />
+ <None Include="app.config" />
+ <None Include="Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configSections>
+ <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
+ <section name="TechBot.IRCLibrary.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
+ </sectionGroup>
+ </configSections>
+ <userSettings>
+ <TechBot.IRCLibrary.Settings>
+ <setting name="CommandPrefix" serializeAs="String">
+ <value>@</value>
+ </setting>
+ </TechBot.IRCLibrary.Settings>
+ </userSettings>
+</configuration>
\ No newline at end of file
private string m_name = "";
private string m_description = "";
private bool m_Required = true;
+ private bool m_Default = false;
#endregion
#region Public Properties
public bool Required { get { return m_Required; } }
+ public bool DefaultParameter
+ {
+ get { return m_Default; }
+ set { m_Default = value; }
+ }
+
#endregion
#region Constructors
using System;
+using System.Text.RegularExpressions;
namespace TechBot.Library
{
{
protected TechBotService m_TechBotService = null;
protected MessageContext m_Context = null;
+ protected string m_Params = null;
public TechBotService TechBot
{
}
}
- public void ParseParameters(string paramaters)
+ public string Parameters
{
- ParametersParser parser = new ParametersParser(paramaters, this);
- parser.Parse();
+ get { return m_Params; }
+ set { m_Params = value; }
+ }
+
+ protected virtual void Say()
+ {
+ TechBot.ServiceOutput.WriteLine(Context, string.Empty);
}
protected virtual void Say(string message)
}
public abstract void ExecuteCommand();
+
+ public virtual void Initialize()
+ {
+ }
+
+ public virtual void DeInitialize()
+ {
+ }
}
}
{
public abstract class XmlLookupCommand : XmlCommand
{
- private string m_Text = null;
+ protected string m_Text = null;
- [CommandParameter("text", "The value to check")]
- public string Text
+ public virtual string Text
{
- get { return m_Text; }
- set { m_Text = value; }
+ get { return Parameters; }
+ set { Parameters = value; }
}
}
}
using System;
+using System.Reflection;
using System.Collections;
namespace TechBot.Library
{
- [Command("help", Help = "!help")]
+ [Command("help", Help = "!help or !help -name:[CommandName]", Description = "Shows this help , type 'help -name:[CommandName]'")]
public class HelpCommand : Command
{
private string m_CommandName = null;
[CommandParameter("Name", "The command name to show help")]
public string CommandName
{
- get { return m_CommandName; }
- set { m_CommandName = value; }
+ get { return Parameters; }
+ set { Parameters = value; }
}
public override void ExecuteCommand()
foreach (CommandBuilder command in TechBot.Commands)
{
- Say("!{0} - {1}",
+ Say("{0}{1} - {2}",
+ Settings.Default.CommandPrefix,
command.Name,
command.Description);
}
else
{
Say("Command '{0}' help:", CommandName);
- Say("");
+ Say();
+ Say(cmdBuilder.Description);
+ Say();
+ Say(cmdBuilder.Help);
+ Say();
+ Say("Parameters :");
+ Say();
+
+ PropertyInfo[] propertyInfoArray = cmdBuilder.Type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
+ foreach (PropertyInfo propertyInfo in propertyInfoArray)
+ {
+ CommandParameterAttribute[] commandAttributes = (CommandParameterAttribute[])
+ Attribute.GetCustomAttributes(propertyInfo, typeof(CommandParameterAttribute));
+
+ foreach (CommandParameterAttribute parameter in commandAttributes)
+ {
+ Say("\t-{0}: [{1}]",
+ parameter.Name,
+ parameter.Description);
+ }
+ }
+
+ Say();
}
}
}
{
Assembly assPlugin = Assembly.LoadFile(sFile);
+ Console.WriteLine("Loading plugins from : {0}", assPlugin.Location);
+
if (assPlugin != null)
{
foreach (Type pluginType in assPlugin.GetTypes())
{
if (pluginType.IsAbstract == false)
{
+ CommandBuilder cmdBuilder = new CommandBuilder(pluginType);
+
+ Console.WriteLine("{0}:{1}",
+ cmdBuilder.Name,
+ cmdBuilder.Description);
+
//Add it to the list.
Commands.Add(new CommandBuilder(pluginType));
}
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.832
+// Runtime Version:2.0.50727.1433
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
return ((string)(this["SVNRoot"]));
}
}
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("@")]
+ public string CommandPrefix {
+ get {
+ return ((string)(this["CommandPrefix"]));
+ }
+ }
}
}
<Setting Name="SVNRoot" Type="System.String" Scope="Application">
<Value Profile="(Default)">svn://svn.reactos.org/trunk/reactos</Value>
</Setting>
+ <Setting Name="CommandPrefix" Type="System.String" Scope="Application">
+ <Value Profile="(Default)">@</Value>
+ </Setting>
</Settings>
</SettingsFile>
\ No newline at end of file
<Compile Include="Factory\CommandFactory.cs" />
<Compile Include="Commands\Base\Command.cs" />
<Compile Include="Commands\Base\XmlCommand.cs" />
- <Compile Include="Commands\BugCommand.cs" />
<Compile Include="Commands\HelpCommand.cs" />
- <Compile Include="Commands\HResultCommand.cs" />
- <Compile Include="Commands\NtStatusCommand.cs" />
- <Compile Include="Commands\ReactOSBugUrl.cs" />
- <Compile Include="Commands\SambaBugUrl.cs" />
- <Compile Include="Commands\SvnCommand.cs" />
- <Compile Include="Commands\WineBugUrl.cs" />
- <Compile Include="Commands\WinerrorCommand.cs" />
- <Compile Include="Commands\WMCommand.cs" />
<Compile Include="MessageContext.cs" />
<Compile Include="NumberParser.cs" />
- <Compile Include="ParametersParser.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ServiceOutput.cs" />
<Compile Include="Settings.cs" />
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\CHMLibrary\CHMLibrary.csproj">
- <Project>{72E5CCA1-6318-4D62-964D-CB23A5C743B5}</Project>
- <Name>CHMLibrary</Name>
- </ProjectReference>
<ProjectReference Include="..\TechBot.IRCLibrary\TechBot.IRCLibrary.csproj">
<Project>{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}</Project>
<Name>TechBot.IRCLibrary</Name>
{
if (context is ChannelMessageContext)
{
+ Thread.Sleep (500);
ChannelMessageContext channelContext = context as ChannelMessageContext;
channelContext.Channel.Talk(message);
}
private string channelnames;
private string botname;
private string password;
- private string chmPath;
- private string mainChm;
private IrcClient m_IrcClient;
private ArrayList channels = new ArrayList();
private bool isStopped = false;
int port,
string channelnames,
string botname,
- string password,
- string chmPath,
- string mainChm)
- : base (new IrcServiceOutput() , chmPath , mainChm)
+ string password)
+ : base (new IrcServiceOutput())
{
this.hostname = hostname;
this.port = port;
this.password = null;
else
this.password = password;
- this.chmPath = chmPath;
- this.mainChm = mainChm;
}
public override void Run()
-using System;\r
-using System.Collections;\r
-using System.Collections.Generic;\r
-using System.IO;\r
-using System.Data;\r
-using System.Threading;\r
-\r
-using TechBot.IRCLibrary;\r
-\r
-namespace TechBot.Library\r
-{\r
- public abstract class TechBotService\r
- {\r
- protected IServiceOutput serviceOutput;\r
- private string chmPath;\r
- private string mainChm;\r
- \r
- public TechBotService(IServiceOutput serviceOutput,\r
- string chmPath,\r
- string mainChm)\r
- {\r
- this.serviceOutput = serviceOutput;\r
- this.chmPath = chmPath;\r
- this.mainChm = mainChm;\r
- }\r
-\r
- public virtual void Run()\r
- {\r
- CommandFactory.LoadPlugins();\r
- }\r
-\r
- public IServiceOutput ServiceOutput\r
- {\r
- get { return serviceOutput; }\r
- }\r
-\r
- public CommandBuilderCollection Commands\r
- {\r
- get { return CommandFactory.Commands; }\r
- }\r
-\r
- public void InjectMessage(MessageContext context, string message)\r
- {\r
- ParseCommandMessage(context,\r
- message);\r
- }\r
- \r
- private bool IsCommandMessage(string message)\r
- {\r
- return message.StartsWith("!");\r
- }\r
-\r
- public void ParseCommandMessage(MessageContext context,\r
- string message)\r
- {\r
- if (!IsCommandMessage(message))\r
- return;\r
-\r
- message = message.Substring(1).Trim();\r
- int index = message.IndexOf(' ');\r
- string commandName;\r
- string commandParams = "";\r
- if (index != -1)\r
- {\r
- commandName = message.Substring(0, index).Trim();\r
- commandParams = message.Substring(index).Trim();\r
- }\r
- else\r
- commandName = message.Trim();\r
-\r
- foreach (CommandBuilder command in Commands)\r
- {\r
- if (command.Name == commandName)\r
- {\r
- //Create a new instance of the required command type\r
- Command cmd = command.CreateCommand();\r
-\r
- cmd.TechBot = this;\r
- cmd.Context = context;\r
- cmd.ParseParameters(message);\r
- cmd.ExecuteCommand();\r
-\r
- return;\r
- }\r
- }\r
- }\r
- }\r
-}\r
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Data;
+using System.Threading;
+
+using TechBot.IRCLibrary;
+
+namespace TechBot.Library
+{
+ public abstract class TechBotService
+ {
+ protected IServiceOutput m_ServiceOutput;
+
+ public TechBotService(IServiceOutput serviceOutput)
+ {
+ m_ServiceOutput = serviceOutput;
+ }
+
+ public virtual void Run()
+ {
+ CommandFactory.LoadPlugins();
+ }
+
+ public IServiceOutput ServiceOutput
+ {
+ get { return m_ServiceOutput; }
+ }
+
+ public CommandBuilderCollection Commands
+ {
+ get { return CommandFactory.Commands; }
+ }
+
+ public void InjectMessage(MessageContext context, string message)
+ {
+ ParseCommandMessage(context,
+ message);
+ }
+
+ private bool IsCommandMessage(string message)
+ {
+ return message.StartsWith(Settings.Default.CommandPrefix);
+ }
+
+ public void InjectMessage(string message)
+ {
+ ParseCommandMessage(null, message);
+ }
+
+ public void ParseCommandMessage(MessageContext context,
+ string message)
+ {
+ if (!IsCommandMessage(message))
+ return;
+
+ message = message.Substring(1).Trim();
+ int index = message.IndexOf(' ');
+ string commandName;
+ string commandParams = "";
+ if (index != -1)
+ {
+ commandName = message.Substring(0, index).Trim();
+ commandParams = message.Substring(index).Trim();
+ }
+ else
+ commandName = message.Trim();
+
+ foreach (CommandBuilder command in Commands)
+ {
+ if (command.Name == commandName)
+ {
+ //Create a new instance of the required command type
+ Command cmd = command.CreateCommand();
+
+ cmd.TechBot = this;
+ cmd.Context = context;
+ cmd.Parameters = commandParams;
+
+ try
+ {
+ cmd.Initialize();
+ cmd.ExecuteCommand();
+ cmd.DeInitialize();
+ }
+ catch (Exception e)
+ {
+ ServiceOutput.WriteLine(context, string.Format("Uops! Just crashed with exception '{0}' at {1}",
+ e.Message,
+ e.Source));
+
+ ServiceOutput.WriteLine(context, e.StackTrace);
+ }
+
+ return;
+ }
+ }
+ }
+ }
+}
<setting name="SVNRoot" serializeAs="String">
<value>svn://svn.reactos.org/trunk/reactos</value>
</setting>
+ <setting name="CommandPrefix" serializeAs="String">
+ <value>@</value>
+ </setting>
</TechBot.Library.Settings>
</applicationSettings>
</configuration>
\ No newline at end of file
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Library", "TechBot.Library\TechBot.Library.csproj", "{1114F34D-F388-4F38-AE27-C0EE1B10B777}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Commands.Common", "TechBot.Commands.Common\TechBot.Commands.Common.csproj", "{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Commands.MSDN", "TechBot.Commands.MSDN\TechBot.Commands.MSDN.csproj", "{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Commands.RBuild", "TechBot.Commands.RBuild\TechBot.Commands.RBuild.csproj", "{D676FEDE-62DD-4B4D-94C6-308598E827F9}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
{1114F34D-F388-4F38-AE27-C0EE1B10B777}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1114F34D-F388-4F38-AE27-C0EE1B10B777}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1114F34D-F388-4F38-AE27-C0EE1B10B777}.Release|Any CPU.Build.0 = Release|Any CPU
+ {041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D676FEDE-62DD-4B4D-94C6-308598E827F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D676FEDE-62DD-4B4D-94C6-308598E827F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D676FEDE-62DD-4B4D-94C6-308598E827F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D676FEDE-62DD-4B4D-94C6-308598E827F9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
-<?xml version="1.0" encoding="utf-8" ?>\r
-<configuration>\r
- <appSettings>\r
- <add key="IRCServerHostName" value="irc.eu.freenode.net" />\r
- <add key="IRCServerHostPort" value="6667" />\r
- <add key="IRCChannelNames" value="channel1;channel2" />\r
- <add key="IRCBotName" value="MyBot" />\r
- <add key="IRCBotPassword" value="MyPassword" />\r
- <add key="ChmPath" value="C:\IRC\TechBot\CHM" />\r
- <add key="MainChm" value="kmarch.chm" />\r
- <add key="NtstatusXml" value="C:\IRC\TechBot\ntstatus.xml" />\r
- <add key="WinerrorXml" value="C:\IRC\TechBot\winerror.xml" />\r
- <add key="HresultXml" value="C:\IRC\TechBot\hresult.xml" />\r
- <add key="WmXml" value="C:\IRC\TechBot\wm.xml" />\r
- <add key="SvnCommand" value="svn co svn://svn.reactos.org/trunk/reactos" />\r
- <add key="BugUrl" value="http://www.reactos.org/bugzilla/show_bug.cgi?id={0}" />\r
- <add key="WineBugUrl" value="http://bugs.winehq.org/show_bug.cgi?id={0}" />\r
- <add key="SambaBugUrl" value="https://bugzilla.samba.org/show_bug.cgi?id={0}" />\r
- </appSettings>\r
-</configuration>\r
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configSections>
+ <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
+ <section name="TechBot.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
+ </sectionGroup>
+ </configSections>
+ <appSettings>
+ <add key="IRCServerHostName" value="irc.eu.freenode.net" />
+ <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" />
+ <add key="WinerrorXml" value="C:\IRC\TechBot\winerror.xml" />
+ <add key="HresultXml" value="C:\IRC\TechBot\hresult.xml" />
+ <add key="WmXml" value="C:\IRC\TechBot\wm.xml" />
+ <add key="SvnCommand" value="svn co svn://svn.reactos.org/trunk/reactos" />
+ <add key="BugUrl" value="http://www.reactos.org/bugzilla/show_bug.cgi?id={0}" />
+ <add key="WineBugUrl" value="http://bugs.winehq.org/show_bug.cgi?id={0}" />
+ <add key="SambaBugUrl" value="https://bugzilla.samba.org/show_bug.cgi?id={0}" />
+ </appSettings>
+ <userSettings>
+ <TechBot.Settings>
+ <setting name="IRCServerHostName" serializeAs="String">
+ <value>irc.eu.freenode.net</value>
+ </setting>
+ <setting name="IRCChannelNames" serializeAs="String">
+ <value>rbuildbottest</value>
+ </setting>
+ <setting name="IRCBotName" serializeAs="String">
+ <value>RBuildBot</value>
+ </setting>
+ <setting name="IRCBotPassword" serializeAs="String">
+ <value>qwerty</value>
+ </setting>
+ <setting name="IRCServerHostPort" serializeAs="String">
+ <value>6667</value>
+ </setting>
+ </TechBot.Settings>
+ </userSettings>
+</configuration>
-using System;\r
-using System.Configuration;\r
-using System.Diagnostics;\r
-using TechBot.Library;\r
-\r
-namespace TechBot\r
-{\r
- public class ServiceThread\r
- {\r
- private string IRCServerHostName;\r
- private int IRCServerHostPort;\r
- private string IRCChannelNames;\r
- private string IRCBotName;\r
- private string IRCBotPassword;\r
- private string ChmPath;\r
- private string MainChm;\r
- private string NtstatusXml;\r
- private string HresultXml;\r
- private string WmXml;\r
- private string WinerrorXml;\r
- private string SvnCommand;\r
- private string BugUrl, WineBugUrl, SambaBugUrl;\r
- private EventLog eventLog;\r
- \r
- public ServiceThread(EventLog eventLog)\r
- {\r
- this.eventLog = eventLog;\r
- }\r
- \r
- private void SetupConfiguration()\r
- {\r
- IRCServerHostName = ConfigurationSettings.AppSettings["IRCServerHostName"];\r
- IRCServerHostPort = Int32.Parse(ConfigurationSettings.AppSettings["IRCServerHostPort"]);\r
- IRCChannelNames = ConfigurationSettings.AppSettings["IRCChannelNames"];\r
- IRCBotName = ConfigurationSettings.AppSettings["IRCBotName"];\r
- IRCBotPassword = ConfigurationSettings.AppSettings["IRCBotPassword"];\r
- ChmPath = ConfigurationSettings.AppSettings["ChmPath"];\r
- MainChm = ConfigurationSettings.AppSettings["MainChm"];\r
- NtstatusXml = ConfigurationSettings.AppSettings["NtstatusXml"];\r
- HresultXml = ConfigurationSettings.AppSettings["HresultXml"];\r
- WmXml = ConfigurationSettings.AppSettings["WmXml"];\r
- WinerrorXml = ConfigurationSettings.AppSettings["WinerrorXml"];\r
- SvnCommand = ConfigurationSettings.AppSettings["SvnCommand"];\r
- BugUrl = ConfigurationSettings.AppSettings["BugUrl"];\r
- WineBugUrl = ConfigurationSettings.AppSettings["WineBugUrl"];\r
- SambaBugUrl = ConfigurationSettings.AppSettings["SambaBugUrl"];\r
- }\r
- \r
- public void Run()\r
- {\r
- SetupConfiguration();\r
- System.Console.WriteLine("TechBot irc service...");\r
- \r
- IrcTechBotService ircService = new IrcTechBotService(IRCServerHostName,\r
- IRCServerHostPort,\r
- IRCChannelNames,\r
- IRCBotName,\r
- IRCBotPassword,\r
- ChmPath,\r
- MainChm);\r
- //NtstatusXml,\r
- //WinerrorXml,\r
- //HresultXml,\r
- //WmXml,\r
- //SvnCommand,\r
- //BugUrl,\r
- //WineBugUrl,\r
- //SambaBugUrl);\r
- ircService.Run();\r
- }\r
- \r
- public void Start()\r
- {\r
- try\r
- {\r
- Run();\r
- }\r
- catch (Exception ex)\r
- {\r
- eventLog.WriteEntry(String.Format("Ex. {0}", ex));\r
- }\r
- }\r
- }\r
-}\r
+using System;
+using System.Configuration;
+using System.Diagnostics;
+using TechBot.Library;
+
+namespace TechBot
+{
+ public class ServiceThread
+ {
+ private EventLog m_EventLog;
+
+ public ServiceThread(EventLog eventLog)
+ {
+ m_EventLog = eventLog;
+ }
+
+ public void Run()
+ {
+ System.Console.WriteLine("TechBot irc service...");
+
+ IrcTechBotService ircService = new IrcTechBotService(
+ Settings.Default.IRCServerHostName,
+ Settings.Default.IRCServerHostPort,
+ Settings.Default.IRCChannelNames,
+ Settings.Default.IRCBotName,
+ Settings.Default.IRCBotPassword);
+
+ ircService.Run();
+ }
+
+ public void Start()
+ {
+ try
+ {
+ Run();
+ }
+ catch (Exception ex)
+ {
+ m_EventLog.WriteEntry(String.Format("Ex. {0}", ex));
+ }
+ }
+ }
+}
--- /dev/null
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace TechBot {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("irc.eu.freenode.net")]
+ public string IRCServerHostName {
+ get {
+ return ((string)(this["IRCServerHostName"]));
+ }
+ set {
+ this["IRCServerHostName"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("rbuildbottest")]
+ public string IRCChannelNames {
+ get {
+ return ((string)(this["IRCChannelNames"]));
+ }
+ set {
+ this["IRCChannelNames"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("RBuildBot")]
+ public string IRCBotName {
+ get {
+ return ((string)(this["IRCBotName"]));
+ }
+ set {
+ this["IRCBotName"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("qwerty")]
+ public string IRCBotPassword {
+ get {
+ return ((string)(this["IRCBotPassword"]));
+ }
+ set {
+ this["IRCBotPassword"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("6667")]
+ public int IRCServerHostPort {
+ get {
+ return ((int)(this["IRCServerHostPort"]));
+ }
+ set {
+ this["IRCServerHostPort"] = value;
+ }
+ }
+ }
+}
--- /dev/null
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot" GeneratedClassName="Settings">
+ <Profiles />
+ <Settings>
+ <Setting Name="IRCServerHostName" Type="System.String" Scope="User">
+ <Value Profile="(Default)">irc.eu.freenode.net</Value>
+ </Setting>
+ <Setting Name="IRCChannelNames" Type="System.String" Scope="User">
+ <Value Profile="(Default)">rbuildbottest</Value>
+ </Setting>
+ <Setting Name="IRCBotName" Type="System.String" Scope="User">
+ <Value Profile="(Default)">RBuildBot</Value>
+ </Setting>
+ <Setting Name="IRCBotPassword" Type="System.String" Scope="User">
+ <Value Profile="(Default)">qwerty</Value>
+ </Setting>
+ <Setting Name="IRCServerHostPort" Type="System.Int32" Scope="User">
+ <Value Profile="(Default)">6667</Value>
+ </Setting>
+ </Settings>
+</SettingsFile>
\ No newline at end of file
-->
<ItemGroup>
<None Include="App.config" />
+ <None Include="Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<SubType>Component</SubType>
</Compile>
<Compile Include="ServiceThread.cs" />
+ <Compile Include="Settings.Designer.cs">
+ <DependentUpon>Settings.settings</DependentUpon>
+ <AutoGen>True</AutoGen>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
<Compile Include="TechBotService.cs">
<SubType>Component</SubType>
</Compile>