Update of Testproject
This commit is contained in:
parent
dbcb4c19ef
commit
6a42d75267
@ -5,7 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TelegramBotBase;
|
||||
using TelegramBotBase.Form;
|
||||
using TelegramBotBase.Tests;
|
||||
using TelegramBaseTest.Tests;
|
||||
|
||||
namespace TelegramBaseTest
|
||||
{
|
||||
@ -16,7 +16,7 @@ namespace TelegramBaseTest
|
||||
|
||||
String APIKey = "";
|
||||
|
||||
BotBase<TestForm> bb = new BotBase<TestForm>(APIKey);
|
||||
BotBase<TestForm2> bb = new BotBase<TestForm2>(APIKey);
|
||||
|
||||
bb.SystemCalls.Add("/start");
|
||||
bb.SystemCalls.Add("/form1");
|
||||
|
||||
@ -33,21 +33,33 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</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.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Telegram.Bot.14.4.0\lib\net45\Telegram.Bot.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Tests\TestForm.cs" />
|
||||
<Compile Include="Tests\TestForm2.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TelegramBotBase\TelegramBotBase.csproj">
|
||||
|
||||
@ -7,7 +7,7 @@ using Telegram.Bot.Types;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBotBase.Tests
|
||||
namespace TelegramBaseTest.Tests
|
||||
{
|
||||
public class TestForm : FormBase
|
||||
{
|
||||
@ -22,12 +22,12 @@ namespace TelegramBotBase.Tests
|
||||
|
||||
public override async Task Opened()
|
||||
{
|
||||
await this.Device.Send("Willkommen in Formular 1");
|
||||
await this.Device.Send("Welcome to Form 1");
|
||||
}
|
||||
|
||||
public override async Task Closed()
|
||||
{
|
||||
await this.Device.Send("Tschüss in Formular 1");
|
||||
await this.Device.Send("Ciao from Form 1");
|
||||
}
|
||||
|
||||
public override async Task Load(MessageResult message)
|
||||
@ -59,6 +59,9 @@ namespace TelegramBotBase.Tests
|
||||
|
||||
default:
|
||||
|
||||
if (message.RawMessageData == null)
|
||||
return;
|
||||
|
||||
this.LastMessage = message.RawMessageData.Message.Text;
|
||||
|
||||
break;
|
||||
@ -73,7 +76,7 @@ namespace TelegramBotBase.Tests
|
||||
if (message.Command == "reply")
|
||||
{
|
||||
|
||||
await this.Device.Send("Letzte Nachricht: " + this.LastMessage);
|
||||
await this.Device.Send("Last message: " + this.LastMessage);
|
||||
|
||||
}
|
||||
|
||||
@ -6,12 +6,11 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.InlineKeyboardButtons;
|
||||
using Telegram.Bot.Types.ReplyMarkups;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBotBase.Tests
|
||||
namespace TelegramBaseTest.Tests
|
||||
{
|
||||
public class TestForm2 : FormBase
|
||||
{
|
||||
@ -23,12 +22,12 @@ namespace TelegramBotBase.Tests
|
||||
|
||||
public override async Task Opened()
|
||||
{
|
||||
await this.Device.Send("Willkommen in Formular 2");
|
||||
await this.Device.Send("Welcome to Form 2");
|
||||
}
|
||||
|
||||
public override async Task Closed()
|
||||
{
|
||||
await this.Device.Send("Tschüss in Formular 2");
|
||||
await this.Device.Send("Ciao from Form 2");
|
||||
}
|
||||
|
||||
public override async Task Load(MessageResult message)
|
||||
@ -58,14 +57,14 @@ namespace TelegramBotBase.Tests
|
||||
var fto = new TestForm2();
|
||||
await fto.Init();
|
||||
|
||||
AlertDialog ad = new AlertDialog("Dies ist eine Meldung !", "Ok", fto);
|
||||
AlertDialog ad = new AlertDialog("This is a message", "Ok", fto);
|
||||
|
||||
|
||||
await this.NavigateTo(ad);
|
||||
}
|
||||
else if (call.Value == "prompt")
|
||||
{
|
||||
PromptDialog pd = new PromptDialog("Bitte bestätigen !", new ButtonBase("Ok", "ok"), new ButtonBase("Abbrechen", "cancel"));
|
||||
PromptDialog pd = new PromptDialog("Please confirm", new ButtonBase("Ok", "ok"), new ButtonBase("Cancel", "cancel"));
|
||||
|
||||
var tf = new TestForm2();
|
||||
|
||||
@ -89,7 +88,7 @@ namespace TelegramBotBase.Tests
|
||||
|
||||
g.FillRectangle(Brushes.White, 0, 0, bmp.Width, bmp.Height);
|
||||
|
||||
g.DrawString("Testbild", new Font("Arial", 24, FontStyle.Bold, GraphicsUnit.Pixel), Brushes.Black, new PointF(50, 50));
|
||||
g.DrawString("Test Image", new Font("Arial", 24, FontStyle.Bold, GraphicsUnit.Pixel), Brushes.Black, new PointF(50, 50));
|
||||
|
||||
}
|
||||
|
||||
@ -97,9 +96,9 @@ namespace TelegramBotBase.Tests
|
||||
|
||||
ButtonForm btn = new ButtonForm();
|
||||
|
||||
btn.AddButtonRow(new ButtonBase("Zum Testformular 1", CallbackData.Create("navigate", "testform1")), new ButtonBase("Zum Testformular 1", CallbackData.Create("navigate", "testform1")));
|
||||
//btn.AddButtonRow(new ButtonBase("Zum Testformular 1", CallbackData.Create("navigate", "testform1")), new ButtonBase("Zum Testformular 1", CallbackData.Create("navigate", "testform1")));
|
||||
|
||||
btn.AddButtonRow(new ButtonBase("Info Dialog", CallbackData.Create("navigate", "alert")), new ButtonBase("Bestätigungs Dialog", CallbackData.Create("navigate", "prompt")));
|
||||
btn.AddButtonRow(new ButtonBase("Information Prompt", CallbackData.Create("navigate", "alert")), new ButtonBase("Confirmation Prompt", CallbackData.Create("navigate", "prompt")));
|
||||
|
||||
|
||||
await this.Device.SendPhoto(bmp, "Test", btn);
|
||||
6
TelegramBaseTest/packages.config
Normal file
6
TelegramBaseTest/packages.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net452" />
|
||||
<package id="System.Net.Requests" version="4.3.0" targetFramework="net452" />
|
||||
<package id="Telegram.Bot" version="14.4.0" targetFramework="net452" />
|
||||
</packages>
|
||||
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Telegram.Bot.Types.InlineKeyboardButtons;
|
||||
using Telegram.Bot.Types.ReplyMarkups;
|
||||
|
||||
namespace TelegramBotBase.Form
|
||||
@ -71,9 +70,7 @@ namespace TelegramBotBase.Form
|
||||
|
||||
public static implicit operator InlineKeyboardMarkup(ButtonForm form)
|
||||
{
|
||||
InlineKeyboardMarkup ikm = new InlineKeyboardMarkup();
|
||||
|
||||
ikm.InlineKeyboard = form.ToArray();
|
||||
InlineKeyboardMarkup ikm = new InlineKeyboardMarkup(form.ToArray());
|
||||
|
||||
return ikm;
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
using Telegram.Bot.Types.InputFiles;
|
||||
using Telegram.Bot.Types.ReplyMarkups;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Form;
|
||||
@ -123,7 +124,7 @@ namespace TelegramBotBase.Sessions
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <returns></returns>
|
||||
public async Task SendPhoto(FileToSend file, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false)
|
||||
public async Task SendPhoto(InputOnlineFile file, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false)
|
||||
{
|
||||
if (this.ActiveForm == null)
|
||||
return;
|
||||
@ -151,7 +152,7 @@ namespace TelegramBotBase.Sessions
|
||||
{
|
||||
using (var fileStream = Tools.Images.ToStream(image, ImageFormat.Png))
|
||||
{
|
||||
var fts = new FileToSend(name, fileStream);
|
||||
InputOnlineFile fts = new InputOnlineFile(fileStream, name);
|
||||
|
||||
await SendPhoto(fts, buttons, replyTo, disableNotification);
|
||||
}
|
||||
@ -169,7 +170,7 @@ namespace TelegramBotBase.Sessions
|
||||
{
|
||||
using (var fileStream = Tools.Images.ToStream(image, ImageFormat.Png))
|
||||
{
|
||||
var fts = new FileToSend(name, fileStream);
|
||||
InputOnlineFile fts = new InputOnlineFile(fileStream, name);
|
||||
|
||||
await SendPhoto(fts, buttons, replyTo, disableNotification);
|
||||
}
|
||||
@ -189,7 +190,7 @@ namespace TelegramBotBase.Sessions
|
||||
{
|
||||
MemoryStream ms = new MemoryStream(document);
|
||||
|
||||
FileToSend fts = new FileToSend(filename, ms);
|
||||
InputOnlineFile fts = new InputOnlineFile(ms, filename);
|
||||
|
||||
await SendDocument(fts, caption, buttons, replyTo, disableNotification);
|
||||
}
|
||||
@ -203,7 +204,7 @@ namespace TelegramBotBase.Sessions
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <returns></returns>
|
||||
public async Task SendDocument(FileToSend document, String caption = "", ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false)
|
||||
public async Task SendDocument(InputOnlineFile document, String caption = "", ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false)
|
||||
{
|
||||
InlineKeyboardMarkup markup = null;
|
||||
if (buttons != null)
|
||||
|
||||
@ -30,8 +30,8 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
@ -50,8 +50,8 @@
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Telegram.Bot, Version=13.2.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Telegram.Bot.13.2.1\lib\netstandard1.1\Telegram.Bot.dll</HintPath>
|
||||
<Reference Include="Telegram.Bot, Version=14.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Telegram.Bot.14.4.0\lib\net45\Telegram.Bot.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
@ -75,11 +75,9 @@
|
||||
<Compile Include="Form\FormBase.cs" />
|
||||
<Compile Include="Form\CallbackData.cs" />
|
||||
<Compile Include="Form\PromptDialog.cs" />
|
||||
<Compile Include="Tests\TestForm.cs" />
|
||||
<Compile Include="SessionBase.cs" />
|
||||
<Compile Include="Sessions\DeviceSession.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Tests\TestForm2.cs" />
|
||||
<Compile Include="Tools\Images.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<packages>
|
||||
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net452" />
|
||||
<package id="NETStandard.Library" version="1.6.1" targetFramework="net452" />
|
||||
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
|
||||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net452" />
|
||||
<package id="System.Collections" version="4.3.0" targetFramework="net452" />
|
||||
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net452" />
|
||||
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net452" />
|
||||
@ -13,8 +13,9 @@
|
||||
<package id="System.IO.Compression" version="4.3.0" targetFramework="net452" />
|
||||
<package id="System.Linq" version="4.3.0" targetFramework="net452" />
|
||||
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net452" />
|
||||
<package id="System.Net.Http" version="4.3.0" targetFramework="net452" />
|
||||
<package id="System.Net.Http" version="4.3.3" targetFramework="net452" />
|
||||
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net452" />
|
||||
<package id="System.Net.Requests" version="4.3.0" targetFramework="net452" />
|
||||
<package id="System.ObjectModel" version="4.3.0" targetFramework="net452" />
|
||||
<package id="System.Reflection" version="4.3.0" targetFramework="net452" />
|
||||
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net452" />
|
||||
@ -33,5 +34,5 @@
|
||||
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net452" />
|
||||
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net452" />
|
||||
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net452" />
|
||||
<package id="Telegram.Bot" version="13.2.1" targetFramework="net452" />
|
||||
<package id="Telegram.Bot" version="14.4.0" targetFramework="net452" />
|
||||
</packages>
|
||||
Loading…
x
Reference in New Issue
Block a user