forked from Uncled1023/Combot
35 changed files with 362 additions and 163 deletions
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?> |
||||
<configuration> |
||||
<startup> |
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" /> |
||||
</startup> |
||||
</configuration> |
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
||||
<PropertyGroup> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProjectGuid>{F67D7423-812D-4B8E-A041-B82C448D8A7F}</ProjectGuid> |
||||
<OutputType>Exe</OutputType> |
||||
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||
<RootNamespace>Console</RootNamespace> |
||||
<AssemblyName>Combot-CLI</AssemblyName> |
||||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> |
||||
<FileAlignment>512</FileAlignment> |
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<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' "> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<DebugType>pdbonly</DebugType> |
||||
<Optimize>true</Optimize> |
||||
<OutputPath>..\Bin\Console Interface\Release\</OutputPath> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
</PropertyGroup> |
||||
<PropertyGroup> |
||||
<ApplicationIcon>Bot.ico</ApplicationIcon> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core" /> |
||||
<Reference Include="System.Xml.Linq" /> |
||||
<Reference Include="System.Data.DataSetExtensions" /> |
||||
<Reference Include="Microsoft.CSharp" /> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Xml" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="Console_Interface.cs" /> |
||||
<Compile Include="Properties\AssemblyInfo.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<None Include="App.config" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\Combot\Combot.csproj"> |
||||
<Project>{23e4c371-16e4-4fac-8b11-44288399bb55}</Project> |
||||
<Name>Combot</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\IRCServices\IRCServices.csproj"> |
||||
<Project>{65fcbf1c-8c9e-4688-becc-185d9030899f}</Project> |
||||
<Name>IRCServices</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Content Include="Bot.ico" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
||||
<PropertyGroup> |
||||
<PostBuildEvent>copy "$(TargetDir)Combot-CLI.exe" "$(SolutionDir)$(ConfigurationName)\" /y</PostBuildEvent> |
||||
</PropertyGroup> |
||||
<!-- 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> |
@ -0,0 +1,103 @@
@@ -0,0 +1,103 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Threading; |
||||
using System.Threading.Tasks; |
||||
|
||||
using Combot; |
||||
using Combot.IRCServices.Messaging; |
||||
using Combot.Configurations; |
||||
using Combot.IRCServices; |
||||
using Combot.IRCServices.Commanding; |
||||
|
||||
namespace Console_Interface |
||||
{ |
||||
public class Console_Interface |
||||
{ |
||||
public static List<Bot> CombotSessions = new List<Bot>(); |
||||
public static Config Config = new Config(); |
||||
|
||||
public static void Main(string[] args) |
||||
{ |
||||
Config.LoadServers(); |
||||
|
||||
foreach (ServerConfig server in Config.Servers) |
||||
{ |
||||
Bot Combot = new Bot(server); |
||||
|
||||
Combot.ErrorEvent += e => BotErrorHandler(e, Combot.ServerConfig.Name); |
||||
|
||||
// Incoming Messages
|
||||
Combot.IRC.Message.RawMessageEvent += (sender, e) => RawMessageHandler(sender, e, Combot.ServerConfig.Name); |
||||
|
||||
// Outgoing Messages
|
||||
Combot.IRC.Command.PrivateMessageCommandEvent += (sender, e) => PrivateMessageCommandHandler(sender, e, Combot.ServerConfig.Name); |
||||
Combot.IRC.Command.PrivateNoticeCommandEvent += (sender, e) => PrivateNoticeCommandHandler(sender, e, Combot.ServerConfig.Name); |
||||
|
||||
Combot.IRC.ConnectEvent += () => ConnectHandler(Combot.ServerConfig.Name); |
||||
Combot.IRC.DisconnectEvent += () => DisconnectHandler(Combot.ServerConfig.Name); |
||||
Combot.IRC.TCPErrorEvent += e => TCPErrorHandler(e, Combot.ServerConfig.Name); |
||||
|
||||
CombotSessions.Add(Combot); |
||||
|
||||
if (server.AutoConnect) |
||||
{ |
||||
Combot.Connect(); |
||||
} |
||||
} |
||||
|
||||
bool run = true; |
||||
while (run) |
||||
{ |
||||
ConsoleKeyInfo info = Console.ReadKey(); |
||||
if (info.Key == ConsoleKey.Escape) |
||||
{ |
||||
Console.WriteLine("Exiting..."); |
||||
run = false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static void RawMessageHandler(object sender, string message, string server) |
||||
{ |
||||
string msg = string.Format("[{0}] [{1}] {2}", DateTime.Now.ToString("HH:mm:ss"), server, message); |
||||
Console.WriteLine(msg); |
||||
} |
||||
|
||||
private static void BotErrorHandler(BotError error, string server) |
||||
{ |
||||
string message = string.Format("[{0}] [{1}] \u0002{2} Error\u0002: {3}", DateTime.Now.ToString("HH:mm:ss"), server, error.Type, error.Message); |
||||
Console.WriteLine(message); |
||||
} |
||||
|
||||
private static void TCPErrorHandler(Combot.IRCServices.TCP.TCPError error, string server) |
||||
{ |
||||
string message = string.Format("[{0}] [{1}] \u0002TCP Error {2}\u0002: {3}", DateTime.Now.ToString("HH:mm:ss"), server, error.Code, error.Message); |
||||
Console.WriteLine(message); |
||||
} |
||||
|
||||
private static void PrivateMessageCommandHandler(object sender, PrivateMessageCommand message, string server) |
||||
{ |
||||
string msg = string.Format("[{0}] [{1}] \u0002{2}\u0002: {3}", message.TimeStamp.ToString("HH:mm:ss"), server, " --Combot-- ", message.Message); |
||||
Console.WriteLine(msg); |
||||
} |
||||
|
||||
private static void PrivateNoticeCommandHandler(object sender, PrivateNoticeCommand message, string server) |
||||
{ |
||||
string msg = string.Format("[{0}] [{1}] \u0002{2}\u0002 -NOTICE-: {3}", message.TimeStamp.ToString("HH:mm:ss"), server, " --Combot-- ", message.Message); |
||||
Console.WriteLine(msg); |
||||
} |
||||
|
||||
private static void ConnectHandler(string server) |
||||
{ |
||||
Console.WriteLine("-- {0} Connected --", server); |
||||
} |
||||
|
||||
private static void DisconnectHandler(string server) |
||||
{ |
||||
Console.WriteLine("-- {0} Disconnected --", server); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
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("Console Interface")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("Teknik")] |
||||
[assembly: AssemblyProduct("Combot")] |
||||
[assembly: AssemblyCopyright("Copyright © 2015")] |
||||
[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("edb6a383-8c78-42f7-b6a8-d1e63753acc1")] |
||||
|
||||
// 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 Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
Binary file not shown.
Loading…
Reference in new issue