Skip to content

Commit ae82029

Browse files
committed
Add module template
1 parent fb8dae1 commit ae82029

6 files changed

Lines changed: 191 additions & 0 deletions

File tree

CSChatBot/CSChatBot.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModuleFramework", "ModuleFr
1313
EndProject
1414
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeatherModule", "WeatherModule\WeatherModule.csproj", "{D5779AAB-E99A-4101-9E29-AAB0007EB2A1}"
1515
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModuleTemplate", "ModuleTemplate\ModuleTemplate.csproj", "{908C9B7F-5C1D-4EA4-8E31-25A53AFFDA5C}"
17+
EndProject
1618
Global
1719
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1820
Debug|Any CPU = Debug|Any CPU
@@ -39,6 +41,10 @@ Global
3941
{D5779AAB-E99A-4101-9E29-AAB0007EB2A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
4042
{D5779AAB-E99A-4101-9E29-AAB0007EB2A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
4143
{D5779AAB-E99A-4101-9E29-AAB0007EB2A1}.Release|Any CPU.Build.0 = Release|Any CPU
44+
{908C9B7F-5C1D-4EA4-8E31-25A53AFFDA5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45+
{908C9B7F-5C1D-4EA4-8E31-25A53AFFDA5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
46+
{908C9B7F-5C1D-4EA4-8E31-25A53AFFDA5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
47+
{908C9B7F-5C1D-4EA4-8E31-25A53AFFDA5C}.Release|Any CPU.Build.0 = Release|Any CPU
4248
EndGlobalSection
4349
GlobalSection(SolutionProperties) = preSolution
4450
HideSolutionNode = FALSE
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using DB;
7+
using DB.Models;
8+
using ModuleFramework;
9+
using Telegram.Bot;
10+
11+
namespace ModuleTemplate
12+
{
13+
/// <summary>
14+
/// A sample module for CSChatBot
15+
/// </summary>
16+
[ModuleFramework.Module(Author = "your name", Name = "Name of Module", Version = "1.0")]
17+
public class ModuleName
18+
{
19+
public ModuleName(Instance db, Setting settings, TelegramBotClient bot)
20+
{
21+
//do your initialization here. this is done before the bot begins receiving updates.
22+
//DO NOT run bot.StartReceiving();
23+
//This is run in the main bot already.
24+
25+
//You can subscribe to updates. This is a simple echo
26+
//bot.OnUpdate += (sender, args) =>
27+
//{
28+
// bot.SendTextMessageAsync(args.Update.Message.Chat.Id, args.Update.Message.Text);
29+
//};
30+
31+
//Or other things, like callback queries (inline buttons)
32+
//bot.OnCallbackQuery += (sender, args) =>
33+
//{
34+
// bot.SendTextMessageAsync(args.CallbackQuery.From.Id, args.CallbackQuery.Data);
35+
//};
36+
}
37+
38+
[ChatCommand(Triggers = new[] { "test" }, DontSearchInline = true, HelpText = "This is a sample command")]
39+
public static CommandResponse Test(CommandEventArgs args)
40+
{
41+
//do something
42+
var length = args.Message.Text.Length;
43+
//return message
44+
return new CommandResponse($"Message: {args.Message.Text}\nLength: {length}");
45+
}
46+
}
47+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{908C9B7F-5C1D-4EA4-8E31-25A53AFFDA5C}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>ModuleTemplate</RootNamespace>
11+
<AssemblyName>ModuleTemplate</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
34+
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
35+
<Private>True</Private>
36+
</Reference>
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
40+
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
41+
<Private>True</Private>
42+
</Reference>
43+
<Reference Include="System.Runtime.Serialization" />
44+
<Reference Include="System.Xml.Linq" />
45+
<Reference Include="System.Data.DataSetExtensions" />
46+
<Reference Include="Microsoft.CSharp" />
47+
<Reference Include="System.Data" />
48+
<Reference Include="System.Net.Http" />
49+
<Reference Include="System.Xml" />
50+
<Reference Include="Telegram.Bot, Version=11.1.0.0, Culture=neutral, processorArchitecture=MSIL">
51+
<HintPath>..\packages\Telegram.Bot.11.1.0-beta-3\lib\net45\Telegram.Bot.dll</HintPath>
52+
<Private>True</Private>
53+
</Reference>
54+
</ItemGroup>
55+
<ItemGroup>
56+
<Compile Include="ModuleName.cs" />
57+
<Compile Include="Properties\AssemblyInfo.cs" />
58+
</ItemGroup>
59+
<ItemGroup>
60+
<ProjectReference Include="..\DB\DB.csproj">
61+
<Project>{c266bbac-788e-4012-87f4-7b8302af14cb}</Project>
62+
<Name>DB</Name>
63+
</ProjectReference>
64+
<ProjectReference Include="..\Logger\Logger.csproj">
65+
<Project>{5b72e456-42bc-4834-bb15-65bbe0b76101}</Project>
66+
<Name>Logger</Name>
67+
</ProjectReference>
68+
<ProjectReference Include="..\ModuleFramework\ModuleFramework.csproj">
69+
<Project>{936a8668-df10-4add-8790-4e7c46ea81d5}</Project>
70+
<Name>ModuleFramework</Name>
71+
</ProjectReference>
72+
</ItemGroup>
73+
<ItemGroup>
74+
<None Include="app.config" />
75+
<None Include="packages.config" />
76+
</ItemGroup>
77+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
78+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
79+
Other similar extension points exist, see Microsoft.Common.targets.
80+
<Target Name="BeforeBuild">
81+
</Target>
82+
<Target Name="AfterBuild">
83+
</Target>
84+
-->
85+
</Project>
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("ModuleTemplate")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("ModuleTemplate")]
13+
[assembly: AssemblyCopyright("Copyright © 2017")]
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("908c9b7f-5c1d-4ea4-8e31-25a53affda5c")]
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")]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<runtime>
4+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
5+
<dependentAssembly>
6+
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
7+
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
8+
</dependentAssembly>
9+
</assemblyBinding>
10+
</runtime>
11+
</configuration>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
4+
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
5+
<package id="Telegram.Bot" version="11.1.0-beta-3" targetFramework="net452" />
6+
</packages>

0 commit comments

Comments
 (0)