Skip to content

Commit 4c7034f

Browse files
author
Paul Jenkins
committed
Merge pull request #36 from cyberzed/Issue5
Issue5
2 parents 5f0eeba + 12812ac commit 4c7034f

File tree

20 files changed

+1106
-726
lines changed

20 files changed

+1106
-726
lines changed

Extensions/HelpSprocket/Help.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88

99
namespace HelpSprocket
1010
{
11-
public class Help : ISprocket
12-
{
13-
public bool Handle(ChatMessage message, Bot bot)
14-
{
15-
var acceptedCommands = new string[] {bot.Name + " help", "@" + bot.Name + " help"};
11+
public class Help : ISprocket
12+
{
13+
public bool Handle(ChatMessage message, Bot bot)
14+
{
15+
var acceptedCommands = new string[] { bot.Name + " help", "@" + bot.Name + " help" };
1616

17-
if (acceptedCommands.Contains(message.Content.Trim()))
18-
{
19-
bot.PrivateReply(message.FromUser, "A list of commands this bot currently supports:\n\thelp");
17+
if (acceptedCommands.Contains(message.Content.Trim()))
18+
{
19+
bot.PrivateReply(message.Sender, "A list of commands this bot currently supports:\n\thelp");
2020

21-
return true;
22-
}
21+
return true;
22+
}
2323

24-
return false;
25-
}
26-
}
24+
return false;
25+
}
26+
}
2727
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{B1E7F2FE-7BC0-409A-9BE5-0A0E03553872}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>IPityTheFoolSprocket</RootNamespace>
12+
<AssemblyName>IPityTheFoolSprocket</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="System" />
35+
<Reference Include="System.Core" />
36+
<Reference Include="System.Xml.Linq" />
37+
<Reference Include="System.Data.DataSetExtensions" />
38+
<Reference Include="Microsoft.CSharp" />
39+
<Reference Include="System.Data" />
40+
<Reference Include="System.Xml" />
41+
</ItemGroup>
42+
<ItemGroup>
43+
<Compile Include="PityTheFoolSprocket.cs" />
44+
<Compile Include="Properties\AssemblyInfo.cs" />
45+
</ItemGroup>
46+
<ItemGroup>
47+
<ProjectReference Include="..\..\Jabbot\Jabbot.csproj">
48+
<Project>{478BFCF7-9397-49A7-AFD4-060B6B749E77}</Project>
49+
<Name>Jabbot</Name>
50+
</ProjectReference>
51+
</ItemGroup>
52+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
53+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
54+
Other similar extension points exist, see Microsoft.Common.targets.
55+
<Target Name="BeforeBuild">
56+
</Target>
57+
<Target Name="AfterBuild">
58+
</Target>
59+
-->
60+
</Project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Text.RegularExpressions;
2+
using Jabbot;
3+
using Jabbot.Models;
4+
using Jabbot.Sprockets;
5+
6+
namespace IPityTheFoolSprocket
7+
{
8+
public class PityTheFoolSprocket : RegexSprocket
9+
{
10+
public override Regex Pattern
11+
{
12+
get { return new Regex(@".*(?:fool|pity)+.*", RegexOptions.IgnoreCase); }
13+
}
14+
15+
protected override void ProcessMatch(Match match, ChatMessage message, Bot bot)
16+
{
17+
bot.Say("http://xamldev.dk/IPityTheFool.gif", message.Receiver);
18+
}
19+
}
20+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("IPityTheFoolSprocket")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("IPityTheFoolSprocket")]
13+
[assembly: AssemblyCopyright("Copyright © 2012")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("599b1c38-b34a-4c6b-a1eb-44c11af2297e")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

Extensions/SampleAnnouncement/EchoAnnouncement.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44

55
namespace SampleAnnouncement
66
{
7-
public class EchoAnnouncement : IAnnounce
8-
{
9-
public TimeSpan Interval
10-
{
7+
public class EchoAnnouncement : IAnnounce
8+
{
9+
public TimeSpan Interval
10+
{
1111
get { return TimeSpan.FromMinutes(10); }
12-
}
12+
}
1313

14-
public void Execute(Bot bot)
15-
{
16-
var offset = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");
17-
var startingPoint = DateTime.UtcNow;
18-
var now = startingPoint.Add(offset.BaseUtcOffset);
14+
public void Execute(Bot bot)
15+
{
16+
var offset = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");
17+
var startingPoint = DateTime.UtcNow;
18+
var now = startingPoint.Add(offset.BaseUtcOffset);
1919

20-
if (offset.IsDaylightSavingTime(startingPoint))
21-
now = now.AddHours(1);
20+
if (offset.IsDaylightSavingTime(startingPoint))
21+
now = now.AddHours(1);
2222

23-
var message = string.Format("The time in AEDST (Sydney time) is now {0}", now.ToString("hh:mm:ss tt, dd MMMM yyyy"));
23+
var message = string.Format("The time in AEDST (Sydney time) is now {0}", now.ToString("hh:mm:ss tt, dd MMMM yyyy"));
2424

25-
foreach (var room in bot.Rooms)
26-
{
27-
bot.Say(message, room);
28-
}
29-
}
30-
}
31-
}
25+
foreach (var room in bot.Rooms)
26+
{
27+
bot.Say(message, room);
28+
}
29+
}
30+
}
31+
}
Lines changed: 63 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,64 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>8.0.30703</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{00F173A5-6E02-412A-A885-774DFAEB9612}</ProjectGuid>
9-
<OutputType>Library</OutputType>
10-
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace>SampleAnnouncement</RootNamespace>
12-
<AssemblyName>SampleAnnouncement</AssemblyName>
13-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14-
<FileAlignment>512</FileAlignment>
15-
</PropertyGroup>
16-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17-
<DebugSymbols>true</DebugSymbols>
18-
<DebugType>full</DebugType>
19-
<Optimize>false</Optimize>
20-
<OutputPath>bin\Debug\</OutputPath>
21-
<DefineConstants>DEBUG;TRACE</DefineConstants>
22-
<ErrorReport>prompt</ErrorReport>
23-
<WarningLevel>4</WarningLevel>
24-
</PropertyGroup>
25-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26-
<DebugType>pdbonly</DebugType>
27-
<Optimize>true</Optimize>
28-
<OutputPath>bin\Release\</OutputPath>
29-
<DefineConstants>TRACE</DefineConstants>
30-
<ErrorReport>prompt</ErrorReport>
31-
<WarningLevel>4</WarningLevel>
32-
</PropertyGroup>
33-
<ItemGroup>
34-
<Reference Include="System" />
35-
<Reference Include="System.ComponentModel.Composition" />
36-
<Reference Include="System.Core" />
37-
<Reference Include="System.Xml.Linq" />
38-
<Reference Include="System.Data.DataSetExtensions" />
39-
<Reference Include="Microsoft.CSharp" />
40-
<Reference Include="System.Data" />
41-
<Reference Include="System.Xml" />
42-
</ItemGroup>
43-
<ItemGroup>
44-
<Compile Include="EchoAnnouncement.cs" />
45-
<Compile Include="Properties\AssemblyInfo.cs" />
46-
</ItemGroup>
47-
<ItemGroup>
48-
<ProjectReference Include="..\..\Jabbot.CommandSprockets\Jabbot.CommandSprockets.csproj">
49-
<Project>{FB5CE3F1-1575-440B-A6E9-4E5AFED35D8B}</Project>
50-
<Name>Jabbot.CommandSprockets</Name>
51-
</ProjectReference>
52-
<ProjectReference Include="..\..\Jabbot\Jabbot.csproj">
53-
<Project>{478BFCF7-9397-49A7-AFD4-060B6B749E77}</Project>
54-
<Name>Jabbot</Name>
55-
</ProjectReference>
56-
</ItemGroup>
57-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
58-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
59-
Other similar extension points exist, see Microsoft.Common.targets.
60-
<Target Name="BeforeBuild">
61-
</Target>
62-
<Target Name="AfterBuild">
63-
</Target>
64-
-->
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{00F173A5-6E02-412A-A885-774DFAEB9612}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>SampleAnnouncement</RootNamespace>
12+
<AssemblyName>SampleAnnouncement</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\jibbr\</SolutionDir>
16+
<RestorePackages>true</RestorePackages>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.ComponentModel.Composition" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Xml.Linq" />
40+
<Reference Include="System.Data.DataSetExtensions" />
41+
<Reference Include="Microsoft.CSharp" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="EchoAnnouncement.cs" />
47+
<Compile Include="Properties\AssemblyInfo.cs" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<ProjectReference Include="..\..\Jabbot\Jabbot.csproj">
51+
<Project>{478BFCF7-9397-49A7-AFD4-060B6B749E77}</Project>
52+
<Name>Jabbot</Name>
53+
</ProjectReference>
54+
</ItemGroup>
55+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
56+
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
57+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
58+
Other similar extension points exist, see Microsoft.Common.targets.
59+
<Target Name="BeforeBuild">
60+
</Target>
61+
<Target Name="AfterBuild">
62+
</Target>
63+
-->
6564
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Collections.Generic;
2+
using Jabbot.CommandSprockets;
3+
4+
namespace SampleSprocket
5+
{
6+
public class HelloSprocket : CommandSprocket
7+
{
8+
public override IEnumerable<string> SupportedInitiators
9+
{
10+
get { yield return "hello"; }
11+
}
12+
13+
public override IEnumerable<string> SupportedCommands
14+
{
15+
get { yield return "you"; }
16+
}
17+
18+
public override bool ExecuteCommand()
19+
{
20+
Bot.Say(string.Format("Hello {0}", Message.Sender), Message.Receiver);
21+
22+
return true;
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)