Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7be0f15ca4 | ||
|
|
e29be4f1f4 | ||
|
|
176107300b | ||
|
|
0ceab58059 | ||
|
|
6ebdd9f208 | ||
|
|
595efd2276 | ||
|
|
85a479d826 | ||
|
|
150e9f731d | ||
|
|
0eab45bdbb | ||
|
|
a33cf5b841 | ||
|
|
1f9539a23d | ||
|
|
9cbde4830e | ||
|
|
3bea2783b1 | ||
|
|
038a941d33 | ||
|
|
48c62e57f8 | ||
|
|
b0e6a8b981 | ||
|
|
2e0656dc06 | ||
|
|
d1456d5bd1 | ||
|
|
058539777f | ||
|
|
5c69289198 | ||
|
|
4c8b085655 | ||
|
|
94d22318f8 | ||
|
|
2028e2f9e6 | ||
|
|
394209b303 | ||
|
|
f0fa953819 | ||
|
|
1d44b50883 | ||
|
|
3c21af8f68 | ||
|
|
1b811e1786 | ||
|
|
94195ec5bf | ||
|
|
256cac825f | ||
|
|
69e5a6717b | ||
|
|
a6d22cdd82 | ||
|
|
ee4a3d765c | ||
|
|
703c99eb8d | ||
|
|
138fee9772 | ||
|
|
d60399514f | ||
|
|
ae0fa3b0e3 | ||
|
|
6a2ac7a309 | ||
|
|
1a76b2b3f8 |
@@ -0,0 +1,17 @@
|
||||
name: .NET Core
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: 2.2.108
|
||||
- name: Build with dotnet
|
||||
run: dotnet build --configuration Release
|
||||
@@ -17,6 +17,23 @@ Download a release: [Releases](https://github.com/MajMcCloud/TelegramBotFramewor
|
||||
|
||||
---
|
||||
|
||||
Donations
|
||||
|
||||
Bitcoin: 1NqyGWmZg8HLp9qQELbf6bChEoba3mxaFc
|
||||
|
||||
ETH: 0x795B70CFC27C69603ce115F2b450cbAC5a5460D0
|
||||
|
||||
Litecoin: LM5iCN6Nz22wAi8LSFnKgdGGWEtxWfJZXv
|
||||
|
||||
DASH: Xb2qyVefvbKTXusHoxZ4Soja2S6R4vLsSr
|
||||
|
||||
Paypal: https://paypal.me/majmccloud
|
||||
|
||||
|
||||
Thanks !
|
||||
|
||||
---
|
||||
|
||||
## Index
|
||||
- [Introduction](#introduction)
|
||||
- [How to Start](#how-to-start)
|
||||
@@ -39,6 +56,8 @@ Download a release: [Releases](https://github.com/MajMcCloud/TelegramBotFramewor
|
||||
|
||||
* [PromptDialog](#prompt-dialog)
|
||||
|
||||
* [ConfirmDialog](#confirm-dialog)
|
||||
|
||||
- [Controls](#controls)
|
||||
* [ProgressBar](#progress-bar)
|
||||
|
||||
@@ -50,6 +69,14 @@ Download a release: [Releases](https://github.com/MajMcCloud/TelegramBotFramewor
|
||||
|
||||
* [ToggleButton](#toggle-button)
|
||||
|
||||
* [ButtonGrid](#button-grid)
|
||||
|
||||
- [Groups](#groups)
|
||||
* [SplitterForm](#splitter-form)
|
||||
|
||||
* [GroupForm](#group-form)
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Introduction
|
||||
@@ -644,6 +671,9 @@ For now we have the following:
|
||||
Makes sense to create a "feeling" of a clean environment for the user. For instance if you have a multilevel menu. This will remove the previously shown menu, and renders the new sub/top level.
|
||||
|
||||
- [PromptDialog](#prompt-dialog)
|
||||
A simple dialog which will show a message and then waits for a text input (response).
|
||||
|
||||
- [ConfirmDialog](#confirm-dialog)
|
||||
A simple dialog which is able to show multiple buttons and a Text message. The user could select one option and will get redirected to a different form, depending on the click.
|
||||
|
||||
### Alert Dialog
|
||||
@@ -652,9 +682,13 @@ For now we have the following:
|
||||
|
||||
```
|
||||
|
||||
var fto = new TestForm2();
|
||||
AlertDialog ad = new AlertDialog("This is a message", "Ok");
|
||||
|
||||
AlertDialog ad = new AlertDialog("This is a message", "Ok", fto);
|
||||
ad.ButtonClicked += async (s, en) =>
|
||||
{
|
||||
var fto = new TestForm2();
|
||||
await this.NavigateTo(fto);
|
||||
};
|
||||
|
||||
await this.NavigateTo(ad);
|
||||
|
||||
@@ -669,45 +703,44 @@ No example yet
|
||||
|
||||
<img src="images/promptdialog.PNG" />
|
||||
|
||||
#### Without Eventhandler (pre-init of form necessary)
|
||||
|
||||
|
||||
```
|
||||
|
||||
PromptDialog pd = new PromptDialog("Please confirm");
|
||||
PromptDialog pd = new PromptDialog("Please tell me your name ?");
|
||||
|
||||
pd.AddButton(new ButtonBase("Ok", "ok"));
|
||||
pd.AddButton(new ButtonBase("Cancel", "cancel"));
|
||||
pd.Completed += async (s, en) =>
|
||||
{
|
||||
await this.Device.Send("Hello " + pd.Value);
|
||||
};
|
||||
|
||||
var tf = new TestForm2();
|
||||
|
||||
pd.ButtonForms.Add("ok", tf);
|
||||
pd.ButtonForms.Add("cancel", tf);
|
||||
|
||||
await this.NavigateTo(pd);
|
||||
await this.OpenModal(pd);
|
||||
|
||||
```
|
||||
|
||||
### Confirm Dialog
|
||||
|
||||
<img src="images/confirmdialog.PNG" />
|
||||
|
||||
|
||||
#### With Eventhandler (no pre-init of form necessary)
|
||||
|
||||
```
|
||||
|
||||
PromptDialog pd = new PromptDialog("Please confirm", new ButtonBase("Ok", "ok"), new ButtonBase("Cancel", "cancel"));
|
||||
ConfirmDialog cd = new ConfirmDialog("Please confirm", new ButtonBase("Ok", "ok"), new ButtonBase("Cancel", "cancel"));
|
||||
|
||||
pd.ButtonClicked += async (s, en) =>
|
||||
cd.ButtonClicked += async (s, en) =>
|
||||
{
|
||||
var tf = new TestForm2();
|
||||
|
||||
//Remember only to navigate from the current running form. (here it is the prompt dialog, cause we have left the above already)
|
||||
await pd.NavigateTo(tf);
|
||||
await cd.NavigateTo(tf);
|
||||
};
|
||||
|
||||
await this.NavigateTo(pd);
|
||||
await this.NavigateTo(cd);
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Controls
|
||||
|
||||
### Progress Bar
|
||||
@@ -734,6 +767,129 @@ await this.NavigateTo(pd);
|
||||
### Toggle Button
|
||||
<img src="images/togglebutton.gif?raw=true" />
|
||||
|
||||
### Button Grid
|
||||
<img src="images/buttongrid.gif?raw=true" />
|
||||
|
||||
|
||||
## Groups
|
||||
|
||||
For working with groups, there are multiple different tools which helps to work with and allows bot also to manage "Single-User" chats and group chats.
|
||||
|
||||
### Splitter Form
|
||||
|
||||
|
||||
An easy way to switch between a "Single-User" form and one for managing a group is the SplitterForm base class.
|
||||
It calls special methods which you can override and then move from there to the form you need.
|
||||
|
||||
The OpenGroup method is the "backup" if OpenChannel or OpenSupergroup is not overridden. Same for Open, it is "backup" if none of the previous methods has been overridden.
|
||||
|
||||
|
||||
```
|
||||
|
||||
public class Start : SplitterForm
|
||||
{
|
||||
public override async Task<bool> Open(MessageResult e)
|
||||
{
|
||||
var st = new Menu();
|
||||
await this.NavigateTo(st);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override async Task<bool> OpenGroup(MessageResult e)
|
||||
{
|
||||
var st = new Groups.LinkReplaceTest();
|
||||
await this.NavigateTo(st);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override Task<bool> OpenChannel(MessageResult e)
|
||||
{
|
||||
return base.OpenChannel(e);
|
||||
}
|
||||
|
||||
public override Task<bool> OpenSupergroup(MessageResult e)
|
||||
{
|
||||
return base.OpenSupergroup(e);
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Group Form
|
||||
|
||||
For managing groups im introducing a new base class called "GroupForm". This one has special events which should make it easier to work with groups and channels.
|
||||
In the Example project is a simple example for deleting a url written by a user and incrementing an internal counter. At every url he writes he got blocked for a small amount of time and the messages gots deleted. At 3 "failes" the user gets kicked of the group and blocked.
|
||||
|
||||
```
|
||||
public class GroupForm : FormBase
|
||||
{
|
||||
|
||||
|
||||
public override async Task Load(MessageResult message)
|
||||
{
|
||||
switch (message.MessageType)
|
||||
{
|
||||
case Telegram.Bot.Types.Enums.MessageType.ChatMembersAdded:
|
||||
|
||||
await OnMemberChanges(new MemberChangeEventArgs(Telegram.Bot.Types.Enums.MessageType.ChatMembersAdded, message, message.RawMessageData.Message.NewChatMembers));
|
||||
|
||||
break;
|
||||
case Telegram.Bot.Types.Enums.MessageType.ChatMemberLeft:
|
||||
|
||||
await OnMemberChanges(new MemberChangeEventArgs(Telegram.Bot.Types.Enums.MessageType.ChatMemberLeft, message, message.RawMessageData.Message.LeftChatMember));
|
||||
|
||||
break;
|
||||
|
||||
case Telegram.Bot.Types.Enums.MessageType.ChatPhotoChanged:
|
||||
case Telegram.Bot.Types.Enums.MessageType.ChatPhotoDeleted:
|
||||
case Telegram.Bot.Types.Enums.MessageType.ChatTitleChanged:
|
||||
case Telegram.Bot.Types.Enums.MessageType.MigratedFromGroup:
|
||||
case Telegram.Bot.Types.Enums.MessageType.MigratedToSupergroup:
|
||||
case Telegram.Bot.Types.Enums.MessageType.MessagePinned:
|
||||
case Telegram.Bot.Types.Enums.MessageType.GroupCreated:
|
||||
case Telegram.Bot.Types.Enums.MessageType.SupergroupCreated:
|
||||
|
||||
await OnGroupChanged(new GroupChangedEventArgs(message.MessageType, message));
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
OnMessage(message);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public virtual async Task OnMemberChanges(MemberChangeEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public virtual async Task OnGroupChanged(GroupChangedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public virtual async Task OnMessage(MessageResult e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
I will add more notes to it soon, so stay tuned.
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TelegramBotBase;
|
||||
using TelegramBotBase.Form;
|
||||
using TelegramBaseTest.Tests;
|
||||
|
||||
namespace TelegramBaseTest
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
||||
String APIKey = "{YOUR API KEY}";
|
||||
|
||||
BotBase<Start> bb = new BotBase<Start>(APIKey);
|
||||
|
||||
bb.SystemCalls.Add("/start");
|
||||
bb.SystemCalls.Add("/form1");
|
||||
bb.SystemCalls.Add("/form2");
|
||||
bb.SystemCalls.Add("/params");
|
||||
|
||||
bb.SystemCall += async (s, en) =>
|
||||
{
|
||||
switch (en.Command)
|
||||
{
|
||||
case "/start":
|
||||
|
||||
var start = new Start();
|
||||
|
||||
await en.Device.ActiveForm.NavigateTo(start);
|
||||
|
||||
break;
|
||||
case "/form1":
|
||||
|
||||
var form1 = new TestForm();
|
||||
|
||||
await en.Device.ActiveForm.NavigateTo(form1);
|
||||
|
||||
break;
|
||||
|
||||
case "/form2":
|
||||
|
||||
var form2 = new TestForm2();
|
||||
|
||||
await en.Device.ActiveForm.NavigateTo(form2);
|
||||
|
||||
break;
|
||||
|
||||
case "/params":
|
||||
|
||||
String m = en.Parameters.DefaultIfEmpty("").Aggregate((a, b) => a + " and " + b);
|
||||
|
||||
await en.Device.Send("Your parameters are: " + m, replyTo: en.Device.LastMessageId);
|
||||
|
||||
en.Handled = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
bb.Start();
|
||||
|
||||
|
||||
|
||||
Console.WriteLine("Telegram Bot started...");
|
||||
|
||||
Console.WriteLine("Press q to quit application.");
|
||||
|
||||
|
||||
Console.ReadLine();
|
||||
|
||||
bb.Stop();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.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>{5817184C-0D59-4924-AC6C-6B943967811C}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TelegramBaseTest</RootNamespace>
|
||||
<AssemblyName>TelegramBaseTest</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</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\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Telegram.Bot, Version=14.10.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Telegram.Bot.14.10.0\lib\net45\Telegram.Bot.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Tests\ButtonTestForm.cs" />
|
||||
<Compile Include="Tests\DataForm.cs" />
|
||||
<Compile Include="Tests\ProgressTest.cs" />
|
||||
<Compile Include="Tests\Register\PerForm.cs" />
|
||||
<Compile Include="Tests\Register\PerStep.cs" />
|
||||
<Compile Include="Tests\Register\Start.cs" />
|
||||
<Compile Include="Tests\Register\Steps\Data.cs" />
|
||||
<Compile Include="Tests\Register\Steps\Step3.cs" />
|
||||
<Compile Include="Tests\Register\Steps\Step2.cs" />
|
||||
<Compile Include="Tests\Register\Steps\Step1.cs" />
|
||||
<Compile Include="Tests\SimpleForm.cs" />
|
||||
<Compile Include="Tests\Start.cs" />
|
||||
<Compile Include="Tests\TestForm.cs" />
|
||||
<Compile Include="Tests\TestForm2.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="packages.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TelegramBotBase\TelegramBotBase.csproj">
|
||||
<Project>{a61eda27-cfdf-4bcb-b2d6-184f94904f2d}</Project>
|
||||
<Name>TelegramBotBase</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<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>
|
||||
@@ -28,6 +28,14 @@ namespace TelegramBotBase.Base
|
||||
/// </summary>
|
||||
public bool Enabled { get; set; } = true;
|
||||
|
||||
|
||||
public virtual async Task Load(MessageResult result)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public virtual async Task Action(MessageResult result, String value = null)
|
||||
{
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace TelegramBotBase.Form
|
||||
public List<ControlBase> Controls { get; set; }
|
||||
|
||||
|
||||
private EventHandlerList Events = new EventHandlerList();
|
||||
public EventHandlerList Events = new EventHandlerList();
|
||||
|
||||
|
||||
private static object __evInit = new object();
|
||||
@@ -118,6 +118,7 @@ namespace TelegramBotBase.Form
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Form has been closed (left)
|
||||
/// </summary>
|
||||
@@ -152,6 +153,33 @@ namespace TelegramBotBase.Form
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets invoked if a message was sent or an action triggered
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
public async Task LoadControls(MessageResult message)
|
||||
{
|
||||
//Looking for the control by id, if not listened, raise event for all
|
||||
if (message.RawData?.StartsWith("#c") ?? false)
|
||||
{
|
||||
var c = this.Controls.FirstOrDefault(a => a.ControlID == message.RawData.Split('_')[0]);
|
||||
if (c != null)
|
||||
{
|
||||
await c.Load(message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var b in this.Controls)
|
||||
{
|
||||
if (!b.Enabled)
|
||||
continue;
|
||||
|
||||
await b.Load(message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets invoked if the form gets loaded and on every message belongs to this context
|
||||
/// </summary>
|
||||
@@ -162,6 +190,8 @@ namespace TelegramBotBase.Form
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets invoked if the user clicked a button.
|
||||
/// </summary>
|
||||
@@ -186,6 +216,9 @@ namespace TelegramBotBase.Form
|
||||
continue;
|
||||
|
||||
await b.Action(message);
|
||||
|
||||
if (message.Handled)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +298,57 @@ namespace TelegramBotBase.Form
|
||||
await newForm.OnOpened(new EventArgs());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens this form modal, but don't closes the original ones
|
||||
/// </summary>
|
||||
/// <param name="newForm"></param>
|
||||
/// <returns></returns>
|
||||
public async Task OpenModal(ModalDialog newForm, params object[] args)
|
||||
{
|
||||
DeviceSession ds = this.Device;
|
||||
if (ds == null)
|
||||
return;
|
||||
|
||||
var parentForm = this;
|
||||
|
||||
ds.FormSwitched = true;
|
||||
|
||||
ds.PreviousForm = ds.ActiveForm;
|
||||
|
||||
ds.ActiveForm = newForm;
|
||||
newForm.Client = parentForm.Client;
|
||||
newForm.Device = ds;
|
||||
|
||||
newForm.Closed += async (s, en) =>
|
||||
{
|
||||
await CloseModal(newForm, parentForm);
|
||||
};
|
||||
|
||||
await newForm.OnInit(new InitEventArgs(args));
|
||||
|
||||
await newForm.OnOpened(new EventArgs());
|
||||
}
|
||||
|
||||
public async Task CloseModal(ModalDialog modalForm, FormBase oldForm)
|
||||
{
|
||||
DeviceSession ds = this.Device;
|
||||
if (ds == null)
|
||||
return;
|
||||
|
||||
if (modalForm == null)
|
||||
throw new Exception("No modal form");
|
||||
|
||||
ds.FormSwitched = true;
|
||||
|
||||
ds.PreviousForm = ds.ActiveForm;
|
||||
|
||||
ds.ActiveForm = oldForm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a control to the formular and sets its ID and Device.
|
||||
/// </summary>
|
||||
/// <param name="control"></param>
|
||||
public void AddControl(ControlBase control)
|
||||
{
|
||||
control.ID = this.Controls.Count + 1;
|
||||
@@ -272,6 +356,20 @@ namespace TelegramBotBase.Form
|
||||
this.Controls.Add(control);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes control from the formular and runs a cleanup on it.
|
||||
/// </summary>
|
||||
/// <param name="control"></param>
|
||||
public void RemoveControl(ControlBase control)
|
||||
{
|
||||
if (!this.Controls.Contains(control))
|
||||
return;
|
||||
|
||||
control.Cleanup().Wait();
|
||||
|
||||
this.Controls.Remove(control);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleanup
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
|
||||
namespace TelegramBotBase.Base
|
||||
{
|
||||
public class GroupChangedEventArgs : EventArgs
|
||||
{
|
||||
public MessageType Type { get; set; }
|
||||
|
||||
public MessageResult OriginalMessage { get; set; }
|
||||
|
||||
public GroupChangedEventArgs(MessageType type, MessageResult message)
|
||||
{
|
||||
this.Type = type;
|
||||
this.OriginalMessage = message;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
|
||||
namespace TelegramBotBase.Base
|
||||
{
|
||||
public class MemberChangeEventArgs : EventArgs
|
||||
{
|
||||
public List<User> Members { get; set; }
|
||||
|
||||
public MessageType Type { get; set; }
|
||||
|
||||
public MessageResult Result { get; set; }
|
||||
|
||||
public MemberChangeEventArgs()
|
||||
{
|
||||
this.Members = new List<User>();
|
||||
|
||||
}
|
||||
|
||||
public MemberChangeEventArgs(MessageType type, MessageResult result, params User[] members)
|
||||
{
|
||||
this.Type = type;
|
||||
this.Result = result;
|
||||
this.Members = members.ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,14 @@ namespace TelegramBotBase.Base
|
||||
}
|
||||
}
|
||||
|
||||
public Telegram.Bot.Types.Enums.MessageType MessageType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.RawMessageData?.Message?.Type ?? Telegram.Bot.Types.Enums.MessageType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is this an action ? (i.e. button click)
|
||||
/// </summary>
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Base
|
||||
{
|
||||
public class ResultBase
|
||||
public class ResultBase : EventArgs
|
||||
{
|
||||
public MessageClient Client { get; set; }
|
||||
|
||||
|
||||
@@ -175,6 +175,9 @@ namespace TelegramBotBase
|
||||
if (this.Client == null)
|
||||
return;
|
||||
|
||||
this.Client.Message -= Client_Message;
|
||||
this.Client.Action -= Client_Action;
|
||||
|
||||
this.Client.TelegramClient.StopReceiving();
|
||||
}
|
||||
|
||||
@@ -267,6 +270,9 @@ namespace TelegramBotBase
|
||||
//Pre Loading Event
|
||||
await activeForm.PreLoad(e);
|
||||
|
||||
//Send Load event to controls
|
||||
await activeForm.LoadControls(e);
|
||||
|
||||
//Loading Event
|
||||
await activeForm.Load(e);
|
||||
|
||||
@@ -279,7 +285,13 @@ namespace TelegramBotBase
|
||||
|
||||
//Render Event
|
||||
if (!ds.FormSwitched)
|
||||
{
|
||||
|
||||
await activeForm.RenderControls(e);
|
||||
|
||||
await activeForm.Render(e);
|
||||
}
|
||||
|
||||
|
||||
} while (ds.FormSwitched && i < NavigationMaximum);
|
||||
|
||||
@@ -336,6 +348,9 @@ namespace TelegramBotBase
|
||||
//Pre Loading Event
|
||||
await activeForm.PreLoad(e);
|
||||
|
||||
//Send Load event to controls
|
||||
await activeForm.LoadControls(e);
|
||||
|
||||
//Loading Event
|
||||
await activeForm.Load(e);
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Constants
|
||||
{
|
||||
public static class Telegram
|
||||
{
|
||||
/// <summary>
|
||||
/// The maximum length of message text before the API throws an exception. (We will catch it before)
|
||||
/// </summary>
|
||||
public const int MaxMessageLength = 4096;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.ReplyMarkups;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Enums;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBotBase.Controls
|
||||
{
|
||||
public class ButtonGrid : Base.ControlBase
|
||||
{
|
||||
|
||||
public String Title { get; set; } = "Toggle";
|
||||
|
||||
private bool RenderNecessary = true;
|
||||
|
||||
private static readonly object __evButtonClicked = new object();
|
||||
|
||||
private readonly EventHandlerList Events = new EventHandlerList();
|
||||
|
||||
public ButtonForm ButtonsForm { get; set; }
|
||||
|
||||
public int? MessageId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines which type of Button Keyboard should be rendered.
|
||||
/// </summary>
|
||||
public eKeyboardType KeyboardType
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return m_eKeyboardType;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(m_eKeyboardType != value)
|
||||
{
|
||||
this.RenderNecessary = true;
|
||||
|
||||
Cleanup().Wait();
|
||||
|
||||
m_eKeyboardType = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private eKeyboardType m_eKeyboardType = eKeyboardType.ReplyKeyboard;
|
||||
|
||||
private bool m_bVisible = true;
|
||||
|
||||
public ButtonGrid()
|
||||
{
|
||||
this.ButtonsForm = new ButtonForm();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ButtonGrid(ButtonForm form)
|
||||
{
|
||||
this.ButtonsForm = form;
|
||||
}
|
||||
|
||||
|
||||
public event EventHandler<ButtonClickedEventArgs> ButtonClicked
|
||||
{
|
||||
add
|
||||
{
|
||||
this.Events.AddHandler(__evButtonClicked, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
this.Events.RemoveHandler(__evButtonClicked, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnButtonClicked(ButtonClickedEventArgs e)
|
||||
{
|
||||
(this.Events[__evButtonClicked] as EventHandler<ButtonClickedEventArgs>)?.Invoke(this, e);
|
||||
}
|
||||
|
||||
public async override Task Load(MessageResult result)
|
||||
{
|
||||
if (this.KeyboardType != eKeyboardType.ReplyKeyboard)
|
||||
return;
|
||||
|
||||
|
||||
var button = ButtonsForm.ToList().FirstOrDefault(a => a.Text == result.MessageText);
|
||||
|
||||
if (button == null)
|
||||
return;
|
||||
|
||||
OnButtonClicked(new ButtonClickedEventArgs(button));
|
||||
|
||||
result.Handled = true;
|
||||
|
||||
}
|
||||
|
||||
public async override Task Action(MessageResult result, string value = null)
|
||||
{
|
||||
if (result.Handled)
|
||||
return;
|
||||
|
||||
await result.ConfirmAction();
|
||||
|
||||
//Find clicked button depending on Text or Value (depending on markup type)
|
||||
switch (this.KeyboardType)
|
||||
{
|
||||
case eKeyboardType.InlineKeyBoard:
|
||||
|
||||
var button = ButtonsForm.ToList().FirstOrDefault(a => a.Value == result.RawData);
|
||||
|
||||
if (button == null)
|
||||
return;
|
||||
|
||||
OnButtonClicked(new ButtonClickedEventArgs(button));
|
||||
|
||||
result.Handled = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async override Task Render(MessageResult result)
|
||||
{
|
||||
if (!this.RenderNecessary)
|
||||
return;
|
||||
|
||||
Message m = null;
|
||||
if (this.MessageId != null)
|
||||
{
|
||||
switch (this.KeyboardType)
|
||||
{
|
||||
//Reply Keyboard could only be updated with a new keyboard.
|
||||
case eKeyboardType.ReplyKeyboard:
|
||||
if (this.ButtonsForm.Count == 0)
|
||||
{
|
||||
await this.Device.Send("", new ReplyKeyboardRemove());
|
||||
this.MessageId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
m = await this.Device.Send(this.Title, (ReplyKeyboardMarkup)this.ButtonsForm, disableNotification: true);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case eKeyboardType.InlineKeyBoard:
|
||||
m = await this.Device.Edit(this.MessageId.Value, this.Title, (InlineKeyboardMarkup)this.ButtonsForm);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (this.KeyboardType)
|
||||
{
|
||||
case eKeyboardType.ReplyKeyboard:
|
||||
m = await this.Device.Send(this.Title, (ReplyKeyboardMarkup)this.ButtonsForm, disableNotification: true);
|
||||
break;
|
||||
|
||||
case eKeyboardType.InlineKeyBoard:
|
||||
m = await this.Device.Send(this.Title, (InlineKeyboardMarkup)this.ButtonsForm, disableNotification: true);
|
||||
break;
|
||||
}
|
||||
|
||||
if (m != null)
|
||||
{
|
||||
this.MessageId = m.MessageId;
|
||||
}
|
||||
}
|
||||
|
||||
this.RenderNecessary = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async override Task Cleanup()
|
||||
{
|
||||
if (this.MessageId == null)
|
||||
return;
|
||||
|
||||
await this.Device.DeleteMessage(this.MessageId.Value);
|
||||
|
||||
this.MessageId = null;
|
||||
|
||||
if (this.KeyboardType == eKeyboardType.ReplyKeyboard)
|
||||
{
|
||||
await this.Device.Send("", new ReplyKeyboardRemove());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Enums
|
||||
{
|
||||
public enum eDeleteMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Don't delete any message.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Delete messages on every callback/action.
|
||||
/// </summary>
|
||||
OnEveryCall = 1,
|
||||
/// <summary>
|
||||
/// Delete on leaving this form.
|
||||
/// </summary>
|
||||
OnLeavingForm = 2
|
||||
}
|
||||
|
||||
public enum eSide
|
||||
{
|
||||
/// <summary>
|
||||
/// Delete only messages from this bot.
|
||||
/// </summary>
|
||||
BotOnly = 0,
|
||||
/// <summary>
|
||||
/// Delete only user messages.
|
||||
/// </summary>
|
||||
UserOnly = 1,
|
||||
/// <summary>
|
||||
/// Delete all messages in this context.
|
||||
/// </summary>
|
||||
Both = 2
|
||||
}
|
||||
|
||||
public enum eMonthPickerMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Shows the calendar with day picker mode
|
||||
/// </summary>
|
||||
day = 0,
|
||||
/// <summary>
|
||||
/// Shows the calendar with month overview
|
||||
/// </summary>
|
||||
month = 1,
|
||||
/// <summary>
|
||||
/// Shows the calendar with year overview
|
||||
/// </summary>
|
||||
year = 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Enums
|
||||
{
|
||||
public enum eDeleteMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Don't delete any message.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Delete messages on every callback/action.
|
||||
/// </summary>
|
||||
OnEveryCall = 1,
|
||||
/// <summary>
|
||||
/// Delete on leaving this form.
|
||||
/// </summary>
|
||||
OnLeavingForm = 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Enums
|
||||
{
|
||||
public enum eDeleteSide
|
||||
{
|
||||
/// <summary>
|
||||
/// Delete only messages from this bot.
|
||||
/// </summary>
|
||||
BotOnly = 0,
|
||||
/// <summary>
|
||||
/// Delete only user messages.
|
||||
/// </summary>
|
||||
UserOnly = 1,
|
||||
/// <summary>
|
||||
/// Delete all messages in this context.
|
||||
/// </summary>
|
||||
Both = 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Enums
|
||||
{
|
||||
public enum eKeyboardType
|
||||
{
|
||||
/// <summary>
|
||||
/// Uses a ReplyKeyboardMarkup
|
||||
/// </summary>
|
||||
ReplyKeyboard = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Uses a InlineKeyboardMakup
|
||||
/// </summary>
|
||||
InlineKeyBoard = 1
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Enums
|
||||
{
|
||||
public enum eMonthPickerMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Shows the calendar with day picker mode
|
||||
/// </summary>
|
||||
day = 0,
|
||||
/// <summary>
|
||||
/// Shows the calendar with month overview
|
||||
/// </summary>
|
||||
month = 1,
|
||||
/// <summary>
|
||||
/// Shows the calendar with year overview
|
||||
/// </summary>
|
||||
year = 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Exceptions
|
||||
{
|
||||
public class MaxLengthException : Exception
|
||||
{
|
||||
public MaxLengthException(int length) : base($"Your messages with a length of {length} is too long for telegram. Actually is {Constants.Telegram.MaxMessageLength} characters allowed. Please split it.")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,17 +11,15 @@ namespace TelegramBotBase.Form
|
||||
/// <summary>
|
||||
/// A simple prompt dialog with one ok Button
|
||||
/// </summary>
|
||||
public class AlertDialog : PromptDialog
|
||||
public class AlertDialog : ConfirmDialog
|
||||
{
|
||||
public String ButtonText { get; set; }
|
||||
|
||||
public AlertDialog(String Message, String ButtonText, FormBase FormToOpen = null) : base(Message)
|
||||
public AlertDialog(String Message, String ButtonText) : base(Message)
|
||||
{
|
||||
this.Buttons.Add(new ButtonBase(ButtonText, "ok"));
|
||||
this.ButtonText = ButtonText;
|
||||
|
||||
if (FormToOpen != null)
|
||||
this.ButtonForms.Add("ok", FormToOpen);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace TelegramBotBase.Form
|
||||
|
||||
public ButtonBase[][] Buttons { get; set; }
|
||||
|
||||
[Obsolete]
|
||||
public Dictionary<String, FormBase> ButtonForms { get; set; } = new Dictionary<string, FormBase>();
|
||||
|
||||
private EventHandlerList __Events { get; set; } = new EventHandlerList();
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace TelegramBotBase.Form
|
||||
|
||||
public eDeleteMode DeleteMode { get; set; }
|
||||
|
||||
public eSide DeleteSide { get; set; }
|
||||
public eDeleteSide DeleteSide { get; set; }
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace TelegramBotBase.Form
|
||||
{
|
||||
this.OldMessages = new List<Message>();
|
||||
this.DeleteMode = eDeleteMode.OnEveryCall;
|
||||
this.DeleteSide = eSide.BotOnly;
|
||||
this.DeleteSide = eDeleteSide.BotOnly;
|
||||
|
||||
this.Init += AutoCleanForm_Init;
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace TelegramBotBase.Form
|
||||
|
||||
private void Device_MessageReceived(object sender, MessageReceivedEventArgs e)
|
||||
{
|
||||
if (this.DeleteSide == eSide.BotOnly)
|
||||
if (this.DeleteSide == eDeleteSide.BotOnly)
|
||||
return;
|
||||
|
||||
this.OldMessages.Add(e.Message);
|
||||
@@ -56,7 +56,7 @@ namespace TelegramBotBase.Form
|
||||
|
||||
private void Device_MessageSent(object sender, MessageSentEventArgs e)
|
||||
{
|
||||
if (this.DeleteSide == eSide.UserOnly)
|
||||
if (this.DeleteSide == eDeleteSide.UserOnly)
|
||||
return;
|
||||
|
||||
this.OldMessages.Add(e.Message);
|
||||
|
||||
@@ -31,6 +31,11 @@ namespace TelegramBotBase.Form
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns an inline Button
|
||||
/// </summary>
|
||||
/// <param name="form"></param>
|
||||
/// <returns></returns>
|
||||
public InlineKeyboardButton ToInlineButton(ButtonForm form)
|
||||
{
|
||||
String id = (form.DependencyControl != null ? form.DependencyControl.ControlID + "_" : "");
|
||||
@@ -48,5 +53,16 @@ namespace TelegramBotBase.Form
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a KeyBoardButton
|
||||
/// </summary>
|
||||
/// <param name="form"></param>
|
||||
/// <returns></returns>
|
||||
public KeyboardButton ToKeyboardButton(ButtonForm form)
|
||||
{
|
||||
return new KeyboardButton(this.Text);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,14 @@ namespace TelegramBotBase.Form
|
||||
return splitted;
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Buttons.Select(a => a.ToArray()).Aggregate((a, b) => a.Union(b).ToArray()).Length;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add buttons splitted in the amount of columns (i.e. 2 per row...)
|
||||
/// </summary>
|
||||
@@ -75,19 +83,41 @@ namespace TelegramBotBase.Form
|
||||
}
|
||||
}
|
||||
|
||||
public InlineKeyboardButton[][] ToArray()
|
||||
public List<ButtonBase> ToList()
|
||||
{
|
||||
return this.Buttons.Aggregate((a, b) => a.Union(b).ToList());
|
||||
}
|
||||
|
||||
public InlineKeyboardButton[][] ToInlineButtonArray()
|
||||
{
|
||||
var ikb = this.Buttons.Select(a => a.Select(b => b.ToInlineButton(this)).ToArray()).ToArray();
|
||||
|
||||
return ikb;
|
||||
}
|
||||
|
||||
public KeyboardButton[][] ToReplyButtonArray()
|
||||
{
|
||||
var ikb = this.Buttons.Select(a => a.Select(b => b.ToKeyboardButton(this)).ToArray()).ToArray();
|
||||
|
||||
return ikb;
|
||||
}
|
||||
|
||||
public static implicit operator InlineKeyboardMarkup(ButtonForm form)
|
||||
{
|
||||
if (form == null)
|
||||
return null;
|
||||
|
||||
InlineKeyboardMarkup ikm = new InlineKeyboardMarkup(form.ToArray());
|
||||
InlineKeyboardMarkup ikm = new InlineKeyboardMarkup(form.ToInlineButtonArray());
|
||||
|
||||
return ikm;
|
||||
}
|
||||
|
||||
public static implicit operator ReplyKeyboardMarkup(ButtonForm form)
|
||||
{
|
||||
if (form == null)
|
||||
return null;
|
||||
|
||||
ReplyKeyboardMarkup ikm = new ReplyKeyboardMarkup(form.ToReplyButtonArray());
|
||||
|
||||
return ikm;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
|
||||
namespace TelegramBotBase.Form
|
||||
{
|
||||
public class ConfirmDialog : ModalDialog
|
||||
{
|
||||
public String Message { get; set; }
|
||||
|
||||
|
||||
public List<ButtonBase> Buttons { get; set; }
|
||||
|
||||
private EventHandlerList __Events { get; set; } = new EventHandlerList();
|
||||
|
||||
private static object __evButtonClicked { get; } = new object();
|
||||
|
||||
public ConfirmDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ConfirmDialog(String Message)
|
||||
{
|
||||
this.Message = Message;
|
||||
this.Buttons = new List<Form.ButtonBase>();
|
||||
}
|
||||
|
||||
public ConfirmDialog(String Message, params ButtonBase[] Buttons)
|
||||
{
|
||||
this.Message = Message;
|
||||
this.Buttons = Buttons.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds one Button
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
public void AddButton(ButtonBase button)
|
||||
{
|
||||
this.Buttons.Add(button);
|
||||
}
|
||||
|
||||
public override async Task Action(MessageResult message)
|
||||
{
|
||||
var call = message.GetData<CallbackData>();
|
||||
if (call == null)
|
||||
return;
|
||||
|
||||
message.Handled = true;
|
||||
|
||||
await message.ConfirmAction();
|
||||
|
||||
await message.DeleteMessage();
|
||||
|
||||
ButtonBase button = this.Buttons.FirstOrDefault(a => a.Value == call.Value);
|
||||
|
||||
if (button == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
OnButtonClicked(new ButtonClickedEventArgs(button));
|
||||
}
|
||||
|
||||
|
||||
public override async Task Render(MessageResult message)
|
||||
{
|
||||
ButtonForm btn = new ButtonForm();
|
||||
|
||||
var buttons = this.Buttons.Select(a => new ButtonBase(a.Text, CallbackData.Create("action", a.Value))).ToList();
|
||||
btn.AddButtonRow(buttons);
|
||||
|
||||
await this.Device.Send(this.Message, btn);
|
||||
}
|
||||
|
||||
|
||||
public event EventHandler<ButtonClickedEventArgs> ButtonClicked
|
||||
{
|
||||
add
|
||||
{
|
||||
this.__Events.AddHandler(__evButtonClicked, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
this.__Events.RemoveHandler(__evButtonClicked, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnButtonClicked(ButtonClickedEventArgs e)
|
||||
{
|
||||
(this.__Events[__evButtonClicked] as EventHandler<ButtonClickedEventArgs>)?.Invoke(this, e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using static TelegramBotBase.Base.Async;
|
||||
|
||||
namespace TelegramBotBase.Form
|
||||
{
|
||||
public class GroupForm : FormBase
|
||||
{
|
||||
|
||||
|
||||
public GroupForm()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override async Task Load(MessageResult message)
|
||||
{
|
||||
switch (message.MessageType)
|
||||
{
|
||||
case Telegram.Bot.Types.Enums.MessageType.ChatMembersAdded:
|
||||
|
||||
await OnMemberChanges(new MemberChangeEventArgs(Telegram.Bot.Types.Enums.MessageType.ChatMembersAdded, message, message.RawMessageData.Message.NewChatMembers));
|
||||
|
||||
break;
|
||||
case Telegram.Bot.Types.Enums.MessageType.ChatMemberLeft:
|
||||
|
||||
await OnMemberChanges(new MemberChangeEventArgs(Telegram.Bot.Types.Enums.MessageType.ChatMemberLeft, message, message.RawMessageData.Message.LeftChatMember));
|
||||
|
||||
break;
|
||||
|
||||
case Telegram.Bot.Types.Enums.MessageType.ChatPhotoChanged:
|
||||
case Telegram.Bot.Types.Enums.MessageType.ChatPhotoDeleted:
|
||||
case Telegram.Bot.Types.Enums.MessageType.ChatTitleChanged:
|
||||
case Telegram.Bot.Types.Enums.MessageType.MigratedFromGroup:
|
||||
case Telegram.Bot.Types.Enums.MessageType.MigratedToSupergroup:
|
||||
case Telegram.Bot.Types.Enums.MessageType.MessagePinned:
|
||||
case Telegram.Bot.Types.Enums.MessageType.GroupCreated:
|
||||
case Telegram.Bot.Types.Enums.MessageType.SupergroupCreated:
|
||||
|
||||
await OnGroupChanged(new GroupChangedEventArgs(message.MessageType, message));
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
OnMessage(message);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public virtual async Task OnMemberChanges(MemberChangeEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public virtual async Task OnGroupChanged(GroupChangedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public virtual async Task OnMessage(MessageResult e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Form
|
||||
{
|
||||
public class ModalDialog : FormBase
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This is a modal only function and does everything to close this form.
|
||||
/// </summary>
|
||||
public async Task CloseForm()
|
||||
{
|
||||
|
||||
await this.CloseControls();
|
||||
|
||||
await this.OnClosed(new EventArgs());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,18 +8,16 @@ using TelegramBotBase.Base;
|
||||
|
||||
namespace TelegramBotBase.Form
|
||||
{
|
||||
public class PromptDialog : FormBase
|
||||
public class PromptDialog : ModalDialog
|
||||
{
|
||||
public String Message { get; set; }
|
||||
|
||||
|
||||
public List<ButtonBase> Buttons { get; set; }
|
||||
|
||||
public Dictionary<String, FormBase> ButtonForms { get; set; } = new Dictionary<string, FormBase>();
|
||||
public String Value { get; set; }
|
||||
|
||||
private EventHandlerList __Events { get; set; } = new EventHandlerList();
|
||||
|
||||
private static object __evButtonClicked { get; } = new object();
|
||||
private static object __evCompleted { get; } = new object();
|
||||
|
||||
|
||||
public PromptDialog()
|
||||
{
|
||||
@@ -29,80 +27,52 @@ namespace TelegramBotBase.Form
|
||||
public PromptDialog(String Message)
|
||||
{
|
||||
this.Message = Message;
|
||||
this.Buttons = new List<Form.ButtonBase>();
|
||||
}
|
||||
|
||||
public PromptDialog(String Message, params ButtonBase[] Buttons)
|
||||
public async override Task Load(MessageResult message)
|
||||
{
|
||||
this.Message = Message;
|
||||
this.Buttons = Buttons.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds one Button
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
public void AddButton(ButtonBase button)
|
||||
{
|
||||
this.Buttons.Add(button);
|
||||
}
|
||||
|
||||
public override async Task Action(MessageResult message)
|
||||
{
|
||||
var call = message.GetData<CallbackData>();
|
||||
if (call == null)
|
||||
if (message.Handled)
|
||||
return;
|
||||
|
||||
message.Handled = true;
|
||||
|
||||
await message.ConfirmAction();
|
||||
|
||||
await message.DeleteMessage();
|
||||
|
||||
ButtonBase button = this.Buttons.FirstOrDefault(a => a.Value == call.Value);
|
||||
|
||||
if (button == null)
|
||||
if (this.Value == null)
|
||||
{
|
||||
return;
|
||||
this.Value = message.MessageText;
|
||||
}
|
||||
|
||||
OnButtonClicked(new ButtonClickedEventArgs(button));
|
||||
|
||||
FormBase fb = ButtonForms.ContainsKey(call.Value) ? ButtonForms[call.Value] : null;
|
||||
|
||||
if (fb != null)
|
||||
{
|
||||
await this.NavigateTo(fb);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override async Task Render(MessageResult message)
|
||||
{
|
||||
ButtonForm btn = new ButtonForm();
|
||||
|
||||
var buttons = this.Buttons.Select(a => new ButtonBase(a.Text, CallbackData.Create("action", a.Value))).ToList();
|
||||
btn.AddButtonRow(buttons);
|
||||
if (this.Value == null)
|
||||
{
|
||||
await this.Device.Send(this.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
await this.Device.Send(this.Message, btn);
|
||||
|
||||
OnCompleted(new EventArgs());
|
||||
|
||||
await this.CloseForm();
|
||||
}
|
||||
|
||||
|
||||
public event EventHandler<ButtonClickedEventArgs> ButtonClicked
|
||||
public event EventHandler<EventArgs> Completed
|
||||
{
|
||||
add
|
||||
{
|
||||
this.__Events.AddHandler(__evButtonClicked, value);
|
||||
this.__Events.AddHandler(__evCompleted, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
this.__Events.RemoveHandler(__evButtonClicked, value);
|
||||
this.__Events.RemoveHandler(__evCompleted, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnButtonClicked(ButtonClickedEventArgs e)
|
||||
public void OnCompleted(EventArgs e)
|
||||
{
|
||||
(this.__Events[__evButtonClicked] as EventHandler<ButtonClickedEventArgs>)?.Invoke(this, e);
|
||||
(this.__Events[__evCompleted] as EventHandler<EventArgs>)?.Invoke(this, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using static TelegramBotBase.Base.Async;
|
||||
|
||||
namespace TelegramBotBase.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// This is used to split incomming requests depending on the chat type.
|
||||
/// </summary>
|
||||
public class SplitterForm : FormBase
|
||||
{
|
||||
|
||||
private static object __evOpenSupergroup = new object();
|
||||
private static object __evOpenGroup = new object();
|
||||
private static object __evOpenChannel = new object();
|
||||
private static object __evOpen = new object();
|
||||
|
||||
|
||||
public override async Task Load(MessageResult message)
|
||||
{
|
||||
|
||||
if (message.Message.Chat.Type == Telegram.Bot.Types.Enums.ChatType.Channel)
|
||||
{
|
||||
if (await OpenChannel(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (message.Message.Chat.Type == Telegram.Bot.Types.Enums.ChatType.Supergroup)
|
||||
{
|
||||
if (await OpenSupergroup(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (await OpenGroup(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (message.Message.Chat.Type == Telegram.Bot.Types.Enums.ChatType.Group)
|
||||
{
|
||||
if (await OpenGroup(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await Open(message);
|
||||
}
|
||||
|
||||
|
||||
public virtual async Task<bool> OpenSupergroup(MessageResult e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual async Task<bool> OpenChannel(MessageResult e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual async Task<bool> Open(MessageResult e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual async Task<bool> OpenGroup(MessageResult e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public override Task Action(MessageResult message)
|
||||
{
|
||||
return base.Action(message);
|
||||
}
|
||||
|
||||
public override Task PreLoad(MessageResult message)
|
||||
{
|
||||
return base.PreLoad(message);
|
||||
}
|
||||
|
||||
public override Task Render(MessageResult message)
|
||||
{
|
||||
return base.Render(message);
|
||||
}
|
||||
|
||||
public override Task SentData(DataResult message)
|
||||
{
|
||||
return base.SentData(message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
|
||||
namespace TelegramBotBase.Markdown
|
||||
{
|
||||
public static class Generator
|
||||
{
|
||||
public static ParseMode OutputMode { get; set; } = ParseMode.Markdown;
|
||||
|
||||
/// <summary>
|
||||
/// Generates a link with title in Markdown or HTML
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="tooltip"></param>
|
||||
/// <returns></returns>
|
||||
public static String Link(this String url, String title = null, String tooltip = null)
|
||||
{
|
||||
switch (OutputMode)
|
||||
{
|
||||
case ParseMode.Markdown:
|
||||
return "[" + (title ?? url) + "](" + url + " " + (tooltip ?? "") + ")";
|
||||
case ParseMode.Html:
|
||||
return $"<a href=\"{url}\" title=\"{tooltip ?? ""}\">{title ?? ""}</b>";
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a Link to the User, title is optional.
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <returns></returns>
|
||||
public static String MentionUser(this long userId, String title = null)
|
||||
{
|
||||
return Link("tg://user?id=" + userId.ToString(), title);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a bold link in Markdown or HTML
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
public static String Bold(this String text)
|
||||
{
|
||||
switch (OutputMode)
|
||||
{
|
||||
case ParseMode.Markdown:
|
||||
return "**" + text + "**";
|
||||
case ParseMode.Html:
|
||||
return "<b>" + text + "</b>";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a italic link in Markdown or HTML
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
public static String Italic(this String text)
|
||||
{
|
||||
switch (OutputMode)
|
||||
{
|
||||
case ParseMode.Markdown:
|
||||
return "__" + text + "__";
|
||||
case ParseMode.Html:
|
||||
return "<i>" + text + "</i>";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a monospace link in Markdown or HTML
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
public static String Monospace(this String text)
|
||||
{
|
||||
switch (OutputMode)
|
||||
{
|
||||
case ParseMode.Markdown:
|
||||
return "`" + text + "`";
|
||||
case ParseMode.Html:
|
||||
return "<code>" + text + "</code>";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a multi monospace link in Markdown or HTML
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
public static String MultiMonospace(this String text)
|
||||
{
|
||||
switch (OutputMode)
|
||||
{
|
||||
case ParseMode.Markdown:
|
||||
return "```" + text + "```";
|
||||
case ParseMode.Html:
|
||||
return "<pre>" + text + "</pre>";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||
// übernehmen, indem Sie "*" eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.5.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.5.0.0")]
|
||||
[assembly: AssemblyVersion("2.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.0.0.0")]
|
||||
|
||||
@@ -13,6 +13,7 @@ using Telegram.Bot.Types.Enums;
|
||||
using Telegram.Bot.Types.InputFiles;
|
||||
using Telegram.Bot.Types.ReplyMarkups;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Exceptions;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBotBase.Sessions
|
||||
@@ -129,6 +130,43 @@ namespace TelegramBotBase.Sessions
|
||||
|
||||
InlineKeyboardMarkup markup = buttons;
|
||||
|
||||
if (text.Length > Constants.Telegram.MaxMessageLength)
|
||||
{
|
||||
throw new MaxLengthException(text.Length);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var m = await this.Client.TelegramClient.EditMessageTextAsync(this.DeviceId, messageId, text, replyMarkup: markup);
|
||||
|
||||
return m;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Edits the text message
|
||||
/// </summary>
|
||||
/// <param name="messageId"></param>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="buttons"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Message> Edit(int messageId, String text, InlineKeyboardMarkup markup)
|
||||
{
|
||||
if (this.ActiveForm == null)
|
||||
return null;
|
||||
|
||||
if (text.Length > Constants.Telegram.MaxMessageLength)
|
||||
{
|
||||
throw new MaxLengthException(text.Length);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var m = await this.Client.TelegramClient.EditMessageTextAsync(this.DeviceId, messageId, text, replyMarkup: markup);
|
||||
@@ -158,6 +196,11 @@ namespace TelegramBotBase.Sessions
|
||||
|
||||
InlineKeyboardMarkup markup = buttons;
|
||||
|
||||
if (message.Text.Length > Constants.Telegram.MaxMessageLength)
|
||||
{
|
||||
throw new MaxLengthException(message.Text.Length);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var m = await this.Client.TelegramClient.EditMessageTextAsync(this.DeviceId, message.MessageId, message.Text, replyMarkup: markup);
|
||||
@@ -181,7 +224,7 @@ namespace TelegramBotBase.Sessions
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Message> Send(String text, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false)
|
||||
public async Task<Message> Send(String text, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false, ParseMode parseMode = ParseMode.Default)
|
||||
{
|
||||
if (this.ActiveForm == null)
|
||||
return null;
|
||||
@@ -190,9 +233,14 @@ namespace TelegramBotBase.Sessions
|
||||
|
||||
Message m = null;
|
||||
|
||||
if (text.Length > Constants.Telegram.MaxMessageLength)
|
||||
{
|
||||
throw new MaxLengthException(text.Length);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
m = await (this.Client.TelegramClient.SendTextMessageAsync(this.DeviceId, text, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification));
|
||||
m = await (this.Client.TelegramClient.SendTextMessageAsync(this.DeviceId, text, parseMode, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification));
|
||||
|
||||
OnMessageSent(new MessageSentEventArgs(m));
|
||||
}
|
||||
@@ -216,16 +264,21 @@ namespace TelegramBotBase.Sessions
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Message> Send(String text, InlineKeyboardMarkup markup, int replyTo = 0, bool disableNotification = false)
|
||||
public async Task<Message> Send(String text, InlineKeyboardMarkup markup, int replyTo = 0, bool disableNotification = false, ParseMode parseMode = ParseMode.Default)
|
||||
{
|
||||
if (this.ActiveForm == null)
|
||||
return null;
|
||||
|
||||
Message m = null;
|
||||
|
||||
if (text.Length > Constants.Telegram.MaxMessageLength)
|
||||
{
|
||||
throw new MaxLengthException(text.Length);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
m = await (this.Client.TelegramClient.SendTextMessageAsync(this.DeviceId, text, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification));
|
||||
m = await (this.Client.TelegramClient.SendTextMessageAsync(this.DeviceId, text, parseMode, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification));
|
||||
|
||||
OnMessageSent(new MessageSentEventArgs(m));
|
||||
}
|
||||
@@ -249,16 +302,21 @@ namespace TelegramBotBase.Sessions
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Message> Send(String text, ReplyKeyboardMarkup markup, int replyTo = 0, bool disableNotification = false)
|
||||
public async Task<Message> Send(String text, ReplyMarkupBase markup, int replyTo = 0, bool disableNotification = false, ParseMode parseMode = ParseMode.Default)
|
||||
{
|
||||
if (this.ActiveForm == null)
|
||||
return null;
|
||||
|
||||
Message m = null;
|
||||
|
||||
if (text.Length > Constants.Telegram.MaxMessageLength)
|
||||
{
|
||||
throw new MaxLengthException(text.Length);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
m = await (this.Client.TelegramClient.SendTextMessageAsync(this.DeviceId, text, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification));
|
||||
m = await (this.Client.TelegramClient.SendTextMessageAsync(this.DeviceId, text, parseMode, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification));
|
||||
|
||||
OnMessageSent(new MessageSentEventArgs(m));
|
||||
}
|
||||
@@ -282,7 +340,7 @@ namespace TelegramBotBase.Sessions
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Message> SendPhoto(InputOnlineFile file, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false)
|
||||
public async Task<Message> SendPhoto(InputOnlineFile file, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false, ParseMode parseMode = ParseMode.Default)
|
||||
{
|
||||
if (this.ActiveForm == null)
|
||||
return null;
|
||||
@@ -293,7 +351,7 @@ namespace TelegramBotBase.Sessions
|
||||
|
||||
try
|
||||
{
|
||||
m = await this.Client.TelegramClient.SendPhotoAsync(this.DeviceId, file, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification);
|
||||
m = await this.Client.TelegramClient.SendPhotoAsync(this.DeviceId, file, parseMode: parseMode, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification);
|
||||
|
||||
OnMessageSent(new MessageSentEventArgs(m));
|
||||
}
|
||||
@@ -465,6 +523,57 @@ namespace TelegramBotBase.Sessions
|
||||
return await DeleteMessage(message.MessageId);
|
||||
}
|
||||
|
||||
|
||||
public virtual async Task ChangeChatPermissions(ChatPermissions permissions)
|
||||
{
|
||||
try
|
||||
{
|
||||
await this.Client.TelegramClient.SetChatPermissionsAsync(this.DeviceId, permissions);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public virtual async Task RestrictUser(int userId, ChatPermissions permissions, DateTime until = default(DateTime))
|
||||
{
|
||||
try
|
||||
{
|
||||
await this.Client.TelegramClient.RestrictChatMemberAsync(this.DeviceId, userId, permissions, until);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public virtual async Task<ChatMember> GetChatUser(int userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await this.Client.TelegramClient.GetChatMemberAsync(this.DeviceId, userId);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual async Task KickUser(int userId, DateTime until = default(DateTime))
|
||||
{
|
||||
try
|
||||
{
|
||||
await this.Client.TelegramClient.KickChatMemberAsync(this.DeviceId, userId, until);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Eventhandler for sent messages
|
||||
/// </summary>
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.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')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A61EDA27-CFDF-4BCB-B2D6-184F94904F2D}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TelegramBotBase</RootNamespace>
|
||||
<AssemblyName>TelegramBotBase</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||
<PackageProjectUrl>https://github.com/MajMcCloud/TelegramBotFramework</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/MajMcCloud/TelegramBotFramework</RepositoryUrl>
|
||||
<PackageReleaseNotes>- moving from .Net Framework 4.7.2 to .Net Standard 2.1 for the Library and .Net Core 3.0 for the test project!</PackageReleaseNotes>
|
||||
<Configurations>Debug;Release;</Configurations>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
|
||||
<RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
@@ -22,6 +23,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
@@ -31,68 +33,43 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Release\TelegramBotBase.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
<DocumentationFile>bin\Release\TelegramBotBase.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Compile Remove="Archive\**" />
|
||||
<EmbeddedResource Remove="Archive\**" />
|
||||
<None Remove="Archive\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Base\ButtonClickedEventArgs.cs" />
|
||||
<Compile Include="Base\ControlBase.cs" />
|
||||
<Compile Include="Base\DataResult.cs" />
|
||||
<Compile Include="Base\MessageClient.cs" />
|
||||
<Compile Include="Base\MessageIncomeResult.cs" />
|
||||
<Compile Include="Base\MessageResult.cs" />
|
||||
<Compile Include="Base\MessageSentEventArgs.cs" />
|
||||
<Compile Include="Base\ResultBase.cs" />
|
||||
<Compile Include="Base\SessionBeginResult.cs" />
|
||||
<Compile Include="Base\SystemExceptionEventArgs.cs" />
|
||||
<Compile Include="Base\UnhandledCallEventArgs.cs" />
|
||||
<Compile Include="Base\SystemCallEventArgs.cs" />
|
||||
<Compile Include="BotBase.cs" />
|
||||
<Compile Include="Controls\ProgressBar.cs" />
|
||||
<Compile Include="Form\AlertDialog.cs" />
|
||||
<Compile Include="Form\ArrayPromptDialog.cs" />
|
||||
<Compile Include="Form\AutoCleanForm.cs" />
|
||||
<Compile Include="Form\ButtonBase.cs" />
|
||||
<Compile Include="Form\ButtonForm.cs" />
|
||||
<Compile Include="Base\FormBase.cs" />
|
||||
<Compile Include="Form\CallbackData.cs" />
|
||||
<Compile Include="Form\PromptDialog.cs" />
|
||||
<Compile Include="SessionBase.cs" />
|
||||
<Compile Include="Sessions\DeviceSession.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Tools\Images.cs" />
|
||||
<None Remove="cpack.ps1" />
|
||||
<None Remove="cpush.ps1" />
|
||||
<None Remove="nuget.exe" />
|
||||
<None Remove="TelegramBotBase.1.5.0.nupkg" />
|
||||
<None Remove="TelegramBotBase.1.5.0.zip" />
|
||||
<None Remove="TelegramBotBase.1.5.1.nupkg" />
|
||||
<None Remove="TelegramBotBase.1.5.1.zip" />
|
||||
<None Remove="TelegramBotBase.1.5.2.nupkg" />
|
||||
<None Remove="TelegramBotBase.1.5.2.zip" />
|
||||
<None Remove="TelegramBotBase.nuspec" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>11.0.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Net.Requests">
|
||||
<Version>4.3.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Telegram.Bot">
|
||||
<Version>14.10.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="4.6.0" />
|
||||
<PackageReference Include="Telegram.Bot" Version="15.0.0" />
|
||||
</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>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -10,12 +10,15 @@
|
||||
<projectUrl>https://github.com/MajMcCloud/TelegramBotFramework</projectUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>$description$</description>
|
||||
<releaseNotes>First release on nuget for easier use.</releaseNotes>
|
||||
<releaseNotes>This is a context based application framework for the C# TelegramBot library.</releaseNotes>
|
||||
<copyright>Copyright 2019</copyright>
|
||||
<tags>Telegram Bot Framework C# Addon Context Modules</tags>
|
||||
<dependencies>
|
||||
<dependency id="Telegram.Bot" version="14.3.0" />
|
||||
<dependency id="Newtonsoft.Json" version="11.0.2" />
|
||||
<dependency id="System.Net.Requests" version="4.3.0" />
|
||||
</dependencies>
|
||||
<repository type="git"
|
||||
url="https://github.com/MajMcCloud/TelegramBotFramework" />
|
||||
</metadata>
|
||||
</package>
|
||||
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
</configuration>
|
||||
+2
-2
@@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
|
||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die einer Assembly zugeordnet sind.
|
||||
[assembly: AssemblyTitle("TelegramBaseTest")]
|
||||
[assembly: AssemblyTitle("TelegramBotBaseTest")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TelegramBaseTest")]
|
||||
[assembly: AssemblyProduct("TelegramBotBaseTest")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
@@ -0,0 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp3.0;net461</TargetFrameworks>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
</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\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TelegramBotBase\TelegramBotBase.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+2
-2
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBaseTest.Tests
|
||||
namespace TelegramBotBaseTest.Tests
|
||||
{
|
||||
public class ButtonTestForm : AutoCleanForm
|
||||
{
|
||||
@@ -62,7 +62,7 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
case "back":
|
||||
|
||||
var st = new Start();
|
||||
var st = new Menu();
|
||||
|
||||
await this.NavigateTo(st);
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TelegramBotBase.Controls;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBotBaseTest.Tests.Controls
|
||||
{
|
||||
public class ButtonGridForm : AutoCleanForm
|
||||
{
|
||||
|
||||
ButtonGrid m_Buttons = null;
|
||||
|
||||
public ButtonGridForm()
|
||||
{
|
||||
this.DeleteMode = TelegramBotBase.Enums.eDeleteMode.OnLeavingForm;
|
||||
|
||||
this.Init += ButtonGridForm_Init;
|
||||
}
|
||||
|
||||
private async Task ButtonGridForm_Init(object sender, TelegramBotBase.Base.InitEventArgs e)
|
||||
{
|
||||
m_Buttons = new ButtonGrid();
|
||||
|
||||
m_Buttons.KeyboardType = TelegramBotBase.Enums.eKeyboardType.InlineKeyBoard;
|
||||
|
||||
ButtonForm bf = new ButtonForm();
|
||||
|
||||
bf.AddButtonRow(new ButtonBase("Back", "back"), new ButtonBase("Switch Keyboard", "switch"));
|
||||
|
||||
bf.AddButtonRow(new ButtonBase("Button1", "b1"), new ButtonBase("Button2", "b2"));
|
||||
|
||||
bf.AddButtonRow(new ButtonBase("Button3", "b3"), new ButtonBase("Button4", "b4"));
|
||||
|
||||
m_Buttons.ButtonsForm = bf;
|
||||
|
||||
m_Buttons.ButtonClicked += Bg_ButtonClicked;
|
||||
|
||||
this.AddControl(m_Buttons);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private async void Bg_ButtonClicked(object sender, TelegramBotBase.Base.ButtonClickedEventArgs e)
|
||||
{
|
||||
if (e.Button == null)
|
||||
return;
|
||||
|
||||
if (e.Button.Value == "back")
|
||||
{
|
||||
var start = new Menu();
|
||||
await this.NavigateTo(start);
|
||||
}
|
||||
else if (e.Button.Value == "switch")
|
||||
{
|
||||
switch (m_Buttons.KeyboardType)
|
||||
{
|
||||
case TelegramBotBase.Enums.eKeyboardType.ReplyKeyboard:
|
||||
m_Buttons.KeyboardType = TelegramBotBase.Enums.eKeyboardType.InlineKeyBoard;
|
||||
break;
|
||||
case TelegramBotBase.Enums.eKeyboardType.InlineKeyBoard:
|
||||
m_Buttons.KeyboardType = TelegramBotBase.Enums.eKeyboardType.ReplyKeyboard;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
await this.Device.Send($"Button clicked with Text: {e.Button.Text} and Value {e.Button.Value}");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -8,7 +8,7 @@ using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
using TelegramBotBase.Controls;
|
||||
|
||||
namespace TelegramBaseTest.Tests.Controls
|
||||
namespace TelegramBotBaseTest.Tests.Controls
|
||||
{
|
||||
public class CalendarPickerForm : AutoCleanForm
|
||||
{
|
||||
@@ -39,7 +39,7 @@ namespace TelegramBaseTest.Tests.Controls
|
||||
{
|
||||
case "back":
|
||||
|
||||
var s = new Start();
|
||||
var s = new Menu();
|
||||
|
||||
await this.NavigateTo(s);
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
using TelegramBotBase.Controls;
|
||||
|
||||
namespace TelegramBaseTest.Tests.Controls
|
||||
namespace TelegramBotBaseTest.Tests.Controls
|
||||
{
|
||||
public class MonthPickerForm : AutoCleanForm
|
||||
{
|
||||
@@ -38,7 +38,7 @@ namespace TelegramBaseTest.Tests.Controls
|
||||
{
|
||||
case "back":
|
||||
|
||||
var s = new Start();
|
||||
var s = new Menu();
|
||||
|
||||
await this.NavigateTo(s);
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
using TelegramBotBase.Controls;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBaseTest.Tests.Controls
|
||||
namespace TelegramBotBaseTest.Tests.Controls
|
||||
{
|
||||
public class ToggleButtons : AutoCleanForm
|
||||
{
|
||||
+2
-2
@@ -7,7 +7,7 @@ using TelegramBotBase.Form;
|
||||
using TelegramBotBase.Controls;
|
||||
using TelegramBotBase.Base;
|
||||
|
||||
namespace TelegramBaseTest.Tests.Controls
|
||||
namespace TelegramBotBaseTest.Tests.Controls
|
||||
{
|
||||
public class TreeViewForms : AutoCleanForm
|
||||
{
|
||||
@@ -60,7 +60,7 @@ namespace TelegramBaseTest.Tests.Controls
|
||||
|
||||
message.Handled = true;
|
||||
|
||||
var start = new Start();
|
||||
var start = new Menu();
|
||||
|
||||
await this.NavigateTo(start);
|
||||
|
||||
@@ -9,7 +9,7 @@ using Telegram.Bot.Types.ReplyMarkups;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBaseTest.Tests
|
||||
namespace TelegramBotBaseTest.Tests
|
||||
{
|
||||
public class DataForm : AutoCleanForm
|
||||
{
|
||||
@@ -110,7 +110,7 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
message.Handled = true;
|
||||
|
||||
var start = new Start();
|
||||
var start = new Menu();
|
||||
|
||||
await this.NavigateTo(start);
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBotBaseTest.Tests.Groups
|
||||
{
|
||||
public class GroupChange : TelegramBotBase.Form.GroupForm
|
||||
{
|
||||
public GroupChange()
|
||||
{
|
||||
this.Opened += GroupChange_Opened;
|
||||
}
|
||||
|
||||
|
||||
private async Task GroupChange_Opened(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
ButtonForm bf = new ButtonForm();
|
||||
|
||||
bf.AddButtonRow(new ButtonBase("Open GroupChange Test", "groupchange"));
|
||||
bf.AddButtonRow(new ButtonBase("Open WelcomeUser Test", "welcomeuser"));
|
||||
bf.AddButtonRow(new ButtonBase("Open LinkReplace Test", "linkreplace"));
|
||||
|
||||
await this.Device.Send("GroupChange started, click to switch", bf);
|
||||
|
||||
}
|
||||
|
||||
public override async Task Action(MessageResult message)
|
||||
{
|
||||
if (message.Handled)
|
||||
return;
|
||||
|
||||
|
||||
var bn = message.RawData;
|
||||
|
||||
await message.ConfirmAction();
|
||||
message.Handled = true;
|
||||
|
||||
switch (bn)
|
||||
{
|
||||
case "groupchange":
|
||||
|
||||
var gc = new GroupChange();
|
||||
|
||||
await this.NavigateTo(gc);
|
||||
|
||||
break;
|
||||
case "welcomeuser":
|
||||
|
||||
var wu = new WelcomeUser();
|
||||
|
||||
await this.NavigateTo(wu);
|
||||
|
||||
break;
|
||||
case "linkreplace":
|
||||
|
||||
var lr = new LinkReplaceTest();
|
||||
|
||||
await this.NavigateTo(lr);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override async Task OnGroupChanged(GroupChangedEventArgs e)
|
||||
{
|
||||
await this.Device.Send("Group has been changed by " + e.OriginalMessage.Message.From.FirstName + " " + e.OriginalMessage.Message.From.LastName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Telegram.Bot.Types;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBotBaseTest.Tests.Groups
|
||||
{
|
||||
public class LinkReplaceTest : TelegramBotBase.Form.GroupForm
|
||||
{
|
||||
|
||||
Dictionary<int, int> Counter { get; set; } = new Dictionary<int, int>();
|
||||
|
||||
private const int Maximum = 3;
|
||||
|
||||
|
||||
public LinkReplaceTest()
|
||||
{
|
||||
this.Opened += LinkReplaceTest_Opened;
|
||||
}
|
||||
|
||||
private async Task LinkReplaceTest_Opened(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
ButtonForm bf = new ButtonForm();
|
||||
|
||||
bf.AddButtonRow(new ButtonBase("Open GroupChange Test", "groupchange"));
|
||||
bf.AddButtonRow(new ButtonBase("Open WelcomeUser Test", "welcomeuser"));
|
||||
bf.AddButtonRow(new ButtonBase("Open LinkReplace Test", "linkreplace"));
|
||||
|
||||
await this.Device.Send("LinkReplaceTest started, click to switch", bf);
|
||||
|
||||
}
|
||||
|
||||
public override async Task Action(MessageResult message)
|
||||
{
|
||||
if (message.Handled)
|
||||
return;
|
||||
|
||||
var bn = message.RawData;
|
||||
|
||||
await message.ConfirmAction();
|
||||
message.Handled = true;
|
||||
|
||||
switch (bn)
|
||||
{
|
||||
case "groupchange":
|
||||
|
||||
var gc = new GroupChange();
|
||||
|
||||
await this.NavigateTo(gc);
|
||||
|
||||
break;
|
||||
case "welcomeuser":
|
||||
|
||||
var wu = new WelcomeUser();
|
||||
|
||||
await this.NavigateTo(wu);
|
||||
|
||||
break;
|
||||
case "linkreplace":
|
||||
|
||||
var lr = new LinkReplaceTest();
|
||||
|
||||
await this.NavigateTo(lr);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override async Task OnMessage(MessageResult e)
|
||||
{
|
||||
var from = e.Message.From.Id;
|
||||
|
||||
if (e.Message.From.IsBot)
|
||||
return;
|
||||
|
||||
var u = await Device.GetChatUser(from);
|
||||
|
||||
//Don't kick Admins or Creators
|
||||
if (u.Status == Telegram.Bot.Types.Enums.ChatMemberStatus.Administrator | u.Status == Telegram.Bot.Types.Enums.ChatMemberStatus.Creator)
|
||||
{
|
||||
await this.Device.Send("You won't get kicked,...not this time.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Are urls inside his message ?
|
||||
if (!HasLinks(e.MessageText))
|
||||
return;
|
||||
|
||||
|
||||
await e.Device.DeleteMessage(e.MessageId);
|
||||
|
||||
var cp = new ChatPermissions();
|
||||
cp.CanAddWebPagePreviews = false;
|
||||
cp.CanChangeInfo = false;
|
||||
cp.CanInviteUsers = false;
|
||||
cp.CanPinMessages = false;
|
||||
cp.CanSendMediaMessages = false;
|
||||
cp.CanSendMessages = false;
|
||||
cp.CanSendOtherMessages = false;
|
||||
cp.CanSendPolls = false;
|
||||
|
||||
//Collect user "mistakes" with sending url, after 3 he gets kicked out.
|
||||
if (Counter.ContainsKey(from))
|
||||
{
|
||||
Counter[from]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Counter[from] = 1;
|
||||
}
|
||||
|
||||
|
||||
if (Counter[from] >= 3)
|
||||
{
|
||||
await e.Device.KickUser(from);
|
||||
|
||||
await e.Device.Send(e.Message.From.FirstName + " " + e.Message.From.LastName + " has been removed from the group");
|
||||
}
|
||||
else
|
||||
{
|
||||
await e.Device.RestrictUser(from, cp, DateTime.UtcNow.AddSeconds(30));
|
||||
|
||||
await e.Device.Send(e.Message.From.FirstName + " " + e.Message.From.LastName + " has been blocked for 30 seconds");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// https://stackoverflow.com/a/20651284
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
private bool HasLinks(String str)
|
||||
{
|
||||
var tmp = str;
|
||||
|
||||
var pattern = @"^(http|https|ftp|)\://|[a-zA-Z0-9\-\.]+\.[a-zA-Z](:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*[^\.\,\)\(\s]$";
|
||||
Regex r = new Regex(pattern);
|
||||
|
||||
var matches = r.Matches(tmp);
|
||||
|
||||
return (matches.Count > 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBotBaseTest.Tests.Groups
|
||||
{
|
||||
public class WelcomeUser : TelegramBotBase.Form.GroupForm
|
||||
{
|
||||
|
||||
public WelcomeUser()
|
||||
{
|
||||
this.Opened += WelcomeUser_Opened;
|
||||
}
|
||||
|
||||
|
||||
private async Task WelcomeUser_Opened(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
ButtonForm bf = new ButtonForm();
|
||||
|
||||
bf.AddButtonRow(new ButtonBase("Open GroupChange Test", "groupchange"));
|
||||
bf.AddButtonRow(new ButtonBase("Open WelcomeUser Test", "welcomeuser"));
|
||||
bf.AddButtonRow(new ButtonBase("Open LinkReplace Test", "linkreplace"));
|
||||
|
||||
await this.Device.Send("WelcomeUser started, click to switch", bf);
|
||||
|
||||
}
|
||||
|
||||
public override async Task Action(MessageResult message)
|
||||
{
|
||||
if (message.Handled)
|
||||
return;
|
||||
|
||||
var bn = message.RawData;
|
||||
|
||||
await message.ConfirmAction();
|
||||
message.Handled = true;
|
||||
|
||||
switch (bn)
|
||||
{
|
||||
case "groupchange":
|
||||
|
||||
var gc = new GroupChange();
|
||||
|
||||
await this.NavigateTo(gc);
|
||||
|
||||
break;
|
||||
case "welcomeuser":
|
||||
|
||||
var wu = new WelcomeUser();
|
||||
|
||||
await this.NavigateTo(wu);
|
||||
|
||||
break;
|
||||
case "linkreplace":
|
||||
|
||||
var lr = new LinkReplaceTest();
|
||||
|
||||
await this.NavigateTo(lr);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override async Task OnMemberChanges(MemberChangeEventArgs e)
|
||||
{
|
||||
|
||||
if (e.Type == Telegram.Bot.Types.Enums.MessageType.ChatMembersAdded)
|
||||
{
|
||||
|
||||
await this.Device.Send("Welcome you new members!\r\n\r\n" + e.Members.Select(a => a.FirstName + " " + a.LastName).Aggregate((a, b) => a + "\r\n" + b));
|
||||
|
||||
}
|
||||
else if (e.Type == Telegram.Bot.Types.Enums.MessageType.ChatMemberLeft)
|
||||
{
|
||||
await this.Device.Send(e.Members.Select(a => a.FirstName + " " + a.LastName).Aggregate((a, b) => a + " and " + b) + " has left the group");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,29 @@ using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBaseTest.Tests
|
||||
namespace TelegramBotBaseTest.Tests
|
||||
{
|
||||
public class Start : AutoCleanForm
|
||||
public class Menu : AutoCleanForm
|
||||
{
|
||||
public Start()
|
||||
public Menu()
|
||||
{
|
||||
this.DeleteMode = TelegramBotBase.Enums.eDeleteMode.OnLeavingForm;
|
||||
}
|
||||
|
||||
public override async Task Load(MessageResult message)
|
||||
{
|
||||
|
||||
|
||||
if (message.Message.Chat.Type == Telegram.Bot.Types.Enums.ChatType.Group | message.Message.Chat.Type == Telegram.Bot.Types.Enums.ChatType.Supergroup)
|
||||
{
|
||||
var sf = new TelegramBotBaseTest.Tests.Groups.WelcomeUser();
|
||||
|
||||
await this.NavigateTo(sf);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override async Task Action(MessageResult message)
|
||||
{
|
||||
var call = message.GetData<CallbackData>();
|
||||
@@ -123,6 +137,15 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
await this.NavigateTo(tb);
|
||||
|
||||
break;
|
||||
case "buttongrid":
|
||||
|
||||
message.Handled = true;
|
||||
|
||||
var bg = new Controls.ButtonGridForm();
|
||||
|
||||
await this.NavigateTo(bg);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -150,6 +173,8 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
btn.AddButtonRow(new ButtonBase("#11 ToggleButtons", new CallbackData("a", "togglebuttons").Serialize()));
|
||||
|
||||
btn.AddButtonRow(new ButtonBase("#12 ButtonGrid", new CallbackData("a", "buttongrid").Serialize()));
|
||||
|
||||
await this.Device.Send("Choose your test:", btn);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBaseTest.Tests
|
||||
namespace TelegramBotBaseTest.Tests
|
||||
{
|
||||
public class ProgressTest : AutoCleanForm
|
||||
{
|
||||
@@ -76,7 +76,7 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
case "start":
|
||||
|
||||
var sf = new Start();
|
||||
var sf = new Menu();
|
||||
|
||||
await this.NavigateTo(sf);
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBaseTest.Tests.Register
|
||||
namespace TelegramBotBaseTest.Tests.Register
|
||||
{
|
||||
public class PerForm : AutoCleanForm
|
||||
{
|
||||
+1
-1
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBaseTest.Tests.Register
|
||||
namespace TelegramBotBaseTest.Tests.Register
|
||||
{
|
||||
public class PerStep: AutoCleanForm
|
||||
{
|
||||
+2
-2
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBaseTest.Tests.Register
|
||||
namespace TelegramBotBaseTest.Tests.Register
|
||||
{
|
||||
public class Start : AutoCleanForm
|
||||
{
|
||||
@@ -43,7 +43,7 @@ namespace TelegramBaseTest.Tests.Register
|
||||
break;
|
||||
case "backtodashboard":
|
||||
|
||||
var start = new Tests.Start();
|
||||
var start = new Tests.Menu();
|
||||
|
||||
await this.NavigateTo(start);
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBaseTest.Tests.Register.Steps
|
||||
namespace TelegramBotBaseTest.Tests.Register.Steps
|
||||
{
|
||||
public class Data
|
||||
{
|
||||
+1
-1
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBaseTest.Tests.Register.Steps
|
||||
namespace TelegramBotBaseTest.Tests.Register.Steps
|
||||
{
|
||||
public class Step1 : AutoCleanForm
|
||||
{
|
||||
+1
-1
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBaseTest.Tests.Register.Steps
|
||||
namespace TelegramBotBaseTest.Tests.Register.Steps
|
||||
{
|
||||
public class Step2 : AutoCleanForm
|
||||
{
|
||||
+1
-1
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBaseTest.Tests.Register.Steps
|
||||
namespace TelegramBotBaseTest.Tests.Register.Steps
|
||||
{
|
||||
public class Step3 : AutoCleanForm
|
||||
{
|
||||
@@ -6,14 +6,14 @@ using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBaseTest.Tests
|
||||
namespace TelegramBotBaseTest.Tests
|
||||
{
|
||||
public class SimpleForm : AutoCleanForm
|
||||
{
|
||||
|
||||
public SimpleForm()
|
||||
{
|
||||
this.DeleteSide = TelegramBotBase.Enums.eSide.Both;
|
||||
this.DeleteSide = TelegramBotBase.Enums.eDeleteSide.Both;
|
||||
this.DeleteMode = TelegramBotBase.Enums.eDeleteMode.OnLeavingForm;
|
||||
|
||||
this.Opened += SimpleForm_Opened;
|
||||
@@ -55,7 +55,7 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
case "back":
|
||||
|
||||
var st = new Start();
|
||||
var st = new Menu();
|
||||
|
||||
await this.NavigateTo(st);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBotBaseTest.Tests
|
||||
{
|
||||
public class Start : SplitterForm
|
||||
{
|
||||
public override async Task<bool> Open(MessageResult e)
|
||||
{
|
||||
var st = new Menu();
|
||||
await this.NavigateTo(st);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override async Task<bool> OpenGroup(MessageResult e)
|
||||
{
|
||||
var st = new Groups.LinkReplaceTest();
|
||||
await this.NavigateTo(st);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override Task<bool> OpenChannel(MessageResult e)
|
||||
{
|
||||
return base.OpenChannel(e);
|
||||
}
|
||||
|
||||
public override Task<bool> OpenSupergroup(MessageResult e)
|
||||
{
|
||||
return base.OpenSupergroup(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using Telegram.Bot.Types;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBaseTest.Tests
|
||||
namespace TelegramBotBaseTest.Tests
|
||||
{
|
||||
public class TestForm : FormBase
|
||||
{
|
||||
@@ -10,7 +10,7 @@ using Telegram.Bot.Types.ReplyMarkups;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBaseTest.Tests
|
||||
namespace TelegramBotBaseTest.Tests
|
||||
{
|
||||
public class TestForm2 : FormBase
|
||||
{
|
||||
@@ -31,9 +31,9 @@ namespace TelegramBaseTest.Tests
|
||||
{
|
||||
await this.Device.Send("Ciao from Form 2");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public override async Task Action(MessageResult message)
|
||||
{
|
||||
@@ -43,6 +43,8 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
await message.DeleteMessage();
|
||||
|
||||
message.Handled = true;
|
||||
|
||||
if (call.Value == "testform1")
|
||||
{
|
||||
|
||||
@@ -52,39 +54,40 @@ namespace TelegramBaseTest.Tests
|
||||
}
|
||||
else if (call.Value == "alert")
|
||||
{
|
||||
var fto = new TestForm2();
|
||||
AlertDialog ad = new AlertDialog("This is a message", "Ok");
|
||||
|
||||
ad.ButtonClicked += async (s, en) =>
|
||||
{
|
||||
var fto = new TestForm2();
|
||||
await this.NavigateTo(fto);
|
||||
};
|
||||
|
||||
AlertDialog ad = new AlertDialog("This is a message", "Ok", fto);
|
||||
|
||||
await this.NavigateTo(ad);
|
||||
}
|
||||
else if (call.Value == "prompt")
|
||||
else if (call.Value == "confirm")
|
||||
{
|
||||
PromptDialog pd = new PromptDialog("Please confirm");
|
||||
|
||||
pd.AddButton(new ButtonBase("Ok", "ok"));
|
||||
pd.AddButton(new ButtonBase("Cancel", "cancel"));
|
||||
|
||||
var tf = new TestForm2();
|
||||
|
||||
pd.ButtonForms.Add("ok", tf);
|
||||
pd.ButtonForms.Add("cancel", tf);
|
||||
|
||||
await this.NavigateTo(pd);
|
||||
}
|
||||
else if (call.Value == "promptevt")
|
||||
{
|
||||
PromptDialog pd = new PromptDialog("Please confirm", new ButtonBase("Ok", "ok"), new ButtonBase("Cancel", "cancel"));
|
||||
ConfirmDialog pd = new ConfirmDialog("Please confirm", new ButtonBase("Ok", "ok"), new ButtonBase("Cancel", "cancel"));
|
||||
|
||||
pd.ButtonClicked += async (s, en) =>
|
||||
{
|
||||
var tf = new TestForm2();
|
||||
|
||||
|
||||
await pd.NavigateTo(tf);
|
||||
};
|
||||
|
||||
await this.NavigateTo(pd);
|
||||
}
|
||||
else if (call.Value == "prompt")
|
||||
{
|
||||
PromptDialog pd = new PromptDialog("Please tell me your name ?");
|
||||
|
||||
pd.Completed += async (s, en) =>
|
||||
{
|
||||
await this.Device.Send("Hello " + pd.Value);
|
||||
};
|
||||
|
||||
await this.OpenModal(pd);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -110,9 +113,9 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
btn.AddButtonRow(new ButtonBase("Information Prompt", CallbackData.Create("navigate", "alert")));
|
||||
|
||||
btn.AddButtonRow(new ButtonBase("Confirmation Prompt without event", CallbackData.Create("navigate", "prompt")));
|
||||
btn.AddButtonRow(new ButtonBase("Confirmation Prompt with event", CallbackData.Create("navigate", "confirm")));
|
||||
|
||||
btn.AddButtonRow(new ButtonBase("Confirmation Prompt with event", CallbackData.Create("navigate", "promptevt")));
|
||||
btn.AddButtonRow(new ButtonBase("Request Prompt", CallbackData.Create("navigate", "prompt")));
|
||||
|
||||
|
||||
await this.Device.SendPhoto(bmp, "Test", btn);
|
||||
+14
-14
@@ -1,13 +1,13 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.168
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29324.140
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TelegramBaseTest", "TelegramBaseTest\TelegramBaseTest.csproj", "{5817184C-0D59-4924-AC6C-6B943967811C}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TelegramBotBase", "TelegramBotBase\TelegramBotBase.csproj", "{0BD16FB9-7ED4-4CCB-83EB-5CEE538E1B6C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TelegramBotBase", "TelegramBotBase\TelegramBotBase.csproj", "{A61EDA27-CFDF-4BCB-B2D6-184F94904F2D}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TelegramBotBaseTest", "TelegramBotBaseTest\TelegramBotBaseTest.csproj", "{88EC0E02-583D-4B9D-956C-81D63C8CFCFA}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E9AE1280-C1F3-4960-9D3D-D4F25142E838}"
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3856B3FB-63E3-444A-9FF0-34171BE7AC5D}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
README.md = README.md
|
||||
EndProjectSection
|
||||
@@ -18,19 +18,19 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5817184C-0D59-4924-AC6C-6B943967811C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5817184C-0D59-4924-AC6C-6B943967811C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5817184C-0D59-4924-AC6C-6B943967811C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5817184C-0D59-4924-AC6C-6B943967811C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A61EDA27-CFDF-4BCB-B2D6-184F94904F2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A61EDA27-CFDF-4BCB-B2D6-184F94904F2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A61EDA27-CFDF-4BCB-B2D6-184F94904F2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A61EDA27-CFDF-4BCB-B2D6-184F94904F2D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0BD16FB9-7ED4-4CCB-83EB-5CEE538E1B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0BD16FB9-7ED4-4CCB-83EB-5CEE538E1B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0BD16FB9-7ED4-4CCB-83EB-5CEE538E1B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0BD16FB9-7ED4-4CCB-83EB-5CEE538E1B6C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{88EC0E02-583D-4B9D-956C-81D63C8CFCFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{88EC0E02-583D-4B9D-956C-81D63C8CFCFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{88EC0E02-583D-4B9D-956C-81D63C8CFCFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{88EC0E02-583D-4B9D-956C-81D63C8CFCFA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {4245F162-E263-45E0-A16A-ED5F411A4AFC}
|
||||
SolutionGuid = {59CB40E1-9FA7-4867-A56F-4F418286F057}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 784 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 6.1 KiB |
Reference in New Issue
Block a user