Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue5 #36

Merged
18 commits merged into from
Jan 12, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Extensions/HelpSprocket/Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@

namespace HelpSprocket
{
public class Help : ISprocket
{
public bool Handle(ChatMessage message, Bot bot)
{
var acceptedCommands = new string[] {bot.Name + " help", "@" + bot.Name + " help"};
public class Help : ISprocket
{
public bool Handle(ChatMessage message, Bot bot)
{
var acceptedCommands = new string[] { bot.Name + " help", "@" + bot.Name + " help" };

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

return true;
}
return true;
}

return false;
}
}
return false;
}
}
}
60 changes: 60 additions & 0 deletions Extensions/IPityTheFoolSprocket/IPityTheFoolSprocket.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B1E7F2FE-7BC0-409A-9BE5-0A0E03553872}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IPityTheFoolSprocket</RootNamespace>
<AssemblyName>IPityTheFoolSprocket</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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.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="PityTheFoolSprocket.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Jabbot\Jabbot.csproj">
<Project>{478BFCF7-9397-49A7-AFD4-060B6B749E77}</Project>
<Name>Jabbot</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\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>
20 changes: 20 additions & 0 deletions Extensions/IPityTheFoolSprocket/PityTheFoolSprocket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Text.RegularExpressions;
using Jabbot;
using Jabbot.Models;
using Jabbot.Sprockets;

namespace IPityTheFoolSprocket
{
public class PityTheFoolSprocket : RegexSprocket
{
public override Regex Pattern
{
get { return new Regex(@".*(?:fool|pity)+.*", RegexOptions.IgnoreCase); }
}

protected override void ProcessMatch(Match match, ChatMessage message, Bot bot)
{
bot.Say("http://xamldev.dk/IPityTheFool.gif", message.Receiver);
}
}
}
36 changes: 36 additions & 0 deletions Extensions/IPityTheFoolSprocket/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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("IPityTheFoolSprocket")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IPityTheFoolSprocket")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[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("599b1c38-b34a-4c6b-a1eb-44c11af2297e")]

// 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:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
40 changes: 20 additions & 20 deletions Extensions/SampleAnnouncement/EchoAnnouncement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@

namespace SampleAnnouncement
{
public class EchoAnnouncement : IAnnounce
{
public TimeSpan Interval
{
public class EchoAnnouncement : IAnnounce
{
public TimeSpan Interval
{
get { return TimeSpan.FromMinutes(10); }
}
}

public void Execute(Bot bot)
{
var offset = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");
var startingPoint = DateTime.UtcNow;
var now = startingPoint.Add(offset.BaseUtcOffset);
public void Execute(Bot bot)
{
var offset = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");
var startingPoint = DateTime.UtcNow;
var now = startingPoint.Add(offset.BaseUtcOffset);

if (offset.IsDaylightSavingTime(startingPoint))
now = now.AddHours(1);
if (offset.IsDaylightSavingTime(startingPoint))
now = now.AddHours(1);

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

foreach (var room in bot.Rooms)
{
bot.Say(message, room);
}
}
}
}
foreach (var room in bot.Rooms)
{
bot.Say(message, room);
}
}
}
}
127 changes: 63 additions & 64 deletions Extensions/SampleAnnouncement/SampleAnnouncement.csproj
Original file line number Diff line number Diff line change
@@ -1,65 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{00F173A5-6E02-412A-A885-774DFAEB9612}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SampleAnnouncement</RootNamespace>
<AssemblyName>SampleAnnouncement</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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.ComponentModel.Composition" />
<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="EchoAnnouncement.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Jabbot.CommandSprockets\Jabbot.CommandSprockets.csproj">
<Project>{FB5CE3F1-1575-440B-A6E9-4E5AFED35D8B}</Project>
<Name>Jabbot.CommandSprockets</Name>
</ProjectReference>
<ProjectReference Include="..\..\Jabbot\Jabbot.csproj">
<Project>{478BFCF7-9397-49A7-AFD4-060B6B749E77}</Project>
<Name>Jabbot</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\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>
-->
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{00F173A5-6E02-412A-A885-774DFAEB9612}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SampleAnnouncement</RootNamespace>
<AssemblyName>SampleAnnouncement</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\jibbr\</SolutionDir>
<RestorePackages>true</RestorePackages>
</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.ComponentModel.Composition" />
<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="EchoAnnouncement.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Jabbot\Jabbot.csproj">
<Project>{478BFCF7-9397-49A7-AFD4-060B6B749E77}</Project>
<Name>Jabbot</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.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>
25 changes: 25 additions & 0 deletions Extensions/SampleSprocket/HelloSprocket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Collections.Generic;
using Jabbot.CommandSprockets;

namespace SampleSprocket
{
public class HelloSprocket : CommandSprocket
{
public override IEnumerable<string> SupportedInitiators
{
get { yield return "hello"; }
}

public override IEnumerable<string> SupportedCommands
{
get { yield return "you"; }
}

public override bool ExecuteCommand()
{
Bot.Say(string.Format("Hello {0}", Message.Sender), Message.Receiver);

return true;
}
}
}
Loading