forked from Uncled1023/Combot
15 changed files with 555 additions and 106 deletions
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> |
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/@KeyIndexDefined">True</s:Boolean> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Description/@EntryValue">Module</s:String> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Text/@EntryValue">namespace $namespace$
 |
||||
{
 |
||||
public class $filename$ : Module
 |
||||
{
 |
||||
public override void Initialize()
 |
||||
{
 |
||||
} 
 |
||||

 |
||||
public override void ParseCommand(CommandMessage command)
 |
||||
{
 |
||||
}
 |
||||
}
 |
||||
}</s:String> |
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Reformat/@EntryValue">True</s:Boolean> |
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/ShortenQualifiedReferences/@EntryValue">True</s:Boolean> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Categories/=Imported_00201_002F29_002F2015/@EntryIndexedValue">Imported 1/29/2015</s:String> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/CustomProperties/=FileName/@EntryIndexedValue">NewModule</s:String> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/CustomProperties/=Extension/@EntryIndexedValue">cs</s:String> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/CustomProperties/=ValidateFileName/@EntryIndexedValue">False</s:String> |
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Applicability/=File/@EntryIndexedValue">True</s:Boolean> |
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Scope/=E8F0594528C33E45BBFEC6CFE851095D/@KeyIndexDefined">True</s:Boolean> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Scope/=E8F0594528C33E45BBFEC6CFE851095D/Type/@EntryValue">InCSharpProjectFile</s:String> |
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=namespace/@KeyIndexDefined">True</s:Boolean> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=namespace/Expression/@EntryValue">getCurrentNamespace()</s:String> |
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=namespace/InitialRange/@EntryValue">-1</s:Int64> |
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=namespace/Order/@EntryValue">0</s:Int64> |
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=filename/@KeyIndexDefined">True</s:Boolean> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=filename/Expression/@EntryValue">fileDefaultNamespace()</s:String> |
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=filename/InitialRange/@EntryValue">-1</s:Int64> |
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=filename/Order/@EntryValue">1</s:Int64></wpf:ResourceDictionary> |
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
using Combot.IRCServices.Messaging; |
||||
|
||||
namespace Combot.Modules.ModuleClasses |
||||
{ |
||||
public class Invite : Module |
||||
{ |
||||
public override void Initialize() |
||||
{ |
||||
Bot.IRC.Message.InviteChannelEvent += HandleInvite; |
||||
} |
||||
|
||||
private void HandleInvite(object sender, InviteChannelInfo inviteInfo) |
||||
{ |
||||
if (!Bot.ServerConfig.ChannelBlacklist.Contains(inviteInfo.Channel)) |
||||
{ |
||||
Bot.IRC.SendJoin(inviteInfo.Channel); |
||||
string helpMessage = string.Empty; |
||||
if (Bot.Modules.Exists(module => module.Commands.Exists(cmd => cmd.Triggers.Contains("help") && cmd.Enabled))) |
||||
{ |
||||
helpMessage = string.Format(" For more information on what I can do, just type: {0}help", Bot.ServerConfig.CommandPrefix); |
||||
} |
||||
Bot.IRC.SendPrivateMessage(inviteInfo.Channel, string.Format("{0} has invited me to this channel. If you would like me to leave, just kick me.{1}", inviteInfo.Requester.Nickname, helpMessage)); |
||||
} |
||||
else |
||||
{ |
||||
Bot.IRC.SendNotice(inviteInfo.Requester.Nickname, "I am unable to join that channel."); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,92 @@
@@ -0,0 +1,92 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Reflection; |
||||
using System.Threading; |
||||
using Combot.IRCServices.Messaging; |
||||
|
||||
namespace Combot.Modules.ModuleClasses |
||||
{ |
||||
public class Version : Module |
||||
{ |
||||
private List<VersionItem> versionList; |
||||
private ReaderWriterLockSlim listLock; |
||||
|
||||
public override void Initialize() |
||||
{ |
||||
listLock = new ReaderWriterLockSlim(); |
||||
versionList = new List<VersionItem>(); |
||||
Bot.IRC.Message.CTCPMessageRecievedEvent += HandleVersionQuery; |
||||
Bot.IRC.Message.CTCPNoticeRecievedEvent += HandleVersionResponse; |
||||
Bot.CommandReceivedEvent += HandleCommandEvent; |
||||
} |
||||
|
||||
public override void ParseCommand(CommandMessage command) |
||||
{ |
||||
if (Commands.Find(cmd => cmd.Name == "Version Check").Triggers.Contains(command.Command)) |
||||
{ |
||||
VersionItem tmpItem = new VersionItem(); |
||||
tmpItem.Location = command.Location; |
||||
tmpItem.LocationType = command.LocationType; |
||||
tmpItem.Nick = command.Arguments["Nickname"]; |
||||
listLock.EnterWriteLock(); |
||||
if (versionList.Exists(item => item.Nick == command.Arguments["Nickname"])) |
||||
{ |
||||
versionList.RemoveAll(item => item.Nick == command.Arguments["Nickname"]); |
||||
} |
||||
versionList.Add(tmpItem); |
||||
listLock.ExitWriteLock(); |
||||
Bot.IRC.SendCTCPMessage(command.Arguments["Nickname"], "VERSION"); |
||||
} |
||||
} |
||||
|
||||
public void HandleVersionQuery(object sender, CTCPMessage message) |
||||
{ |
||||
if (message.Command.ToLower() == "version") |
||||
{ |
||||
Bot.IRC.SendCTCPNotice(message.Sender.Nickname, "VERSION", string.Format("Combot v{0} on {1}", Assembly.GetExecutingAssembly().GetName().Version, GetOptionValue("Machine Reply"))); |
||||
} |
||||
} |
||||
|
||||
public void HandleVersionResponse(object sender, CTCPMessage message) |
||||
{ |
||||
if (message.Command == "VERSION") |
||||
{ |
||||
listLock.EnterReadLock(); |
||||
VersionItem versionItem = versionList.Find(item => item.Nick == message.Sender.Nickname); |
||||
listLock.ExitReadLock(); |
||||
if (versionItem != null) |
||||
{ |
||||
switch (versionItem.LocationType) |
||||
{ |
||||
case LocationType.Channel: |
||||
Bot.IRC.SendPrivateMessage(versionItem.Location, string.Format("[{0}] Using version: {1}", versionItem.Nick, message.Arguments)); |
||||
break; |
||||
case LocationType.Query: |
||||
Bot.IRC.SendPrivateMessage(versionItem.Nick, string.Format("[{0}] Using version: {1}", versionItem.Nick, message.Arguments)); |
||||
break; |
||||
case LocationType.Notice: |
||||
Bot.IRC.SendNotice(versionItem.Nick, string.Format("[{0}] Using version: {1}", versionItem.Nick, message.Arguments)); |
||||
break; |
||||
} |
||||
listLock.EnterWriteLock(); |
||||
versionList.RemoveAll(item => item.Nick == versionItem.Nick); |
||||
listLock.ExitWriteLock(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
public class VersionItem |
||||
{ |
||||
public string Nick { get; set; } |
||||
public string Location { get; set; } |
||||
public LocationType LocationType { get; set; } |
||||
|
||||
public VersionItem() |
||||
{ |
||||
Nick = string.Empty; |
||||
Location = string.Empty; |
||||
LocationType = LocationType.Channel; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> |
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/@KeyIndexDefined">True</s:Boolean> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Description/@EntryValue">Module</s:String> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Text/@EntryValue">namespace $namespace$
 |
||||
{
 |
||||
public class $filename$ : Module
 |
||||
{
 |
||||
public override void Initialize()
 |
||||
{
 |
||||
} 
 |
||||

 |
||||
public override void ParseCommand(CommandMessage command)
 |
||||
{
 |
||||
}
 |
||||
}
 |
||||
}</s:String> |
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Reformat/@EntryValue">True</s:Boolean> |
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/ShortenQualifiedReferences/@EntryValue">True</s:Boolean> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/CustomProperties/=FileName/@EntryIndexedValue">NewModule</s:String> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/CustomProperties/=Extension/@EntryIndexedValue">cs</s:String> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/CustomProperties/=ValidateFileName/@EntryIndexedValue">False</s:String> |
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Applicability/=File/@EntryIndexedValue">True</s:Boolean> |
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Scope/=E8F0594528C33E45BBFEC6CFE851095D/@KeyIndexDefined">True</s:Boolean> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Scope/=E8F0594528C33E45BBFEC6CFE851095D/Type/@EntryValue">InCSharpProjectFile</s:String> |
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=namespace/@KeyIndexDefined">True</s:Boolean> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=namespace/Expression/@EntryValue">getCurrentNamespace()</s:String> |
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=namespace/InitialRange/@EntryValue">-1</s:Int64> |
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=namespace/Order/@EntryValue">0</s:Int64> |
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=filename/@KeyIndexDefined">True</s:Boolean> |
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=filename/Expression/@EntryValue">fileDefaultNamespace()</s:String> |
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=filename/InitialRange/@EntryValue">-1</s:Int64> |
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=25F1155BB4B75B4898E0DB901452883B/Field/=filename/Order/@EntryValue">1</s:Int64></wpf:ResourceDictionary> |
Loading…
Reference in new issue