upstream: apply changes
This commit is contained in:
parent
8d02b54b05
commit
77242a200f
@ -1,74 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{673A56F5-6110-4AED-A68D-562FD6ED3EA6}</ProjectGuid>
|
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RootNamespace>AsyncFormUpdates</RootNamespace>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<AssemblyName>AsyncFormUpdates</AssemblyName>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
<Nullable>disable</Nullable>
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
|
||||||
<Deterministic>true</Deterministic>
|
|
||||||
<TargetFrameworkProfile/>
|
|
||||||
</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>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="mscorlib"/>
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.9" />
|
||||||
<Reference Include="System"/>
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.9" />
|
||||||
<Reference Include="System.Core"/>
|
|
||||||
<Reference Include="System.Xml.Linq"/>
|
|
||||||
<Reference Include="System.Data.DataSetExtensions"/>
|
|
||||||
<Reference Include="Microsoft.CSharp"/>
|
|
||||||
<Reference Include="System.Data"/>
|
|
||||||
<Reference Include="System.Net.Http"/>
|
|
||||||
<Reference Include="System.Xml"/>
|
|
||||||
<Reference Include="Telegram.Bot, Version=17.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\packages\Telegram.Bot.17.0.0\lib\netstandard2.0\Telegram.Bot.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="forms\AsyncFormEdit.cs"/>
|
<ProjectReference Include="..\..\TelegramBotBase\TelegramBotBase.csproj" />
|
||||||
<Compile Include="forms\AsyncFormUpdate.cs"/>
|
|
||||||
<Compile Include="forms\Start.cs"/>
|
|
||||||
<Compile Include="Program.cs"/>
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs"/>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="App.config"/>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\..\TelegramBotBase\TelegramBotBase.csproj">
|
|
||||||
<Project>{0bd16fb9-7ed4-4ccb-83eb-5cee538e1b6c}</Project>
|
|
||||||
<Name>TelegramBotBase</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
|
|
||||||
<PackageReference Include="System.Net.Requests" Version="4.3.0"/>
|
|
||||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0"/>
|
|
||||||
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4"/>
|
|
||||||
<PackageReference Include="Telegram.Bot" Version="18.0.0"/>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System.Timers;
|
||||||
using System.Timers;
|
|
||||||
using AsyncFormUpdates.forms;
|
using AsyncFormUpdates.forms;
|
||||||
using TelegramBotBase;
|
using TelegramBotBase;
|
||||||
using TelegramBotBase.Builder;
|
using TelegramBotBase.Builder;
|
||||||
|
using Timer = System.Timers.Timer;
|
||||||
|
|
||||||
namespace AsyncFormUpdates
|
namespace AsyncFormUpdates
|
||||||
{
|
{
|
||||||
@ -10,7 +10,7 @@ namespace AsyncFormUpdates
|
|||||||
{
|
{
|
||||||
private static BotBase __bot;
|
private static BotBase __bot;
|
||||||
|
|
||||||
private static void Main(string[] args)
|
private static async Task Main(string[] args)
|
||||||
{
|
{
|
||||||
var apiKey = "APIKey";
|
var apiKey = "APIKey";
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ namespace AsyncFormUpdates
|
|||||||
.QuickStart<Start>(apiKey)
|
.QuickStart<Start>(apiKey)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
__bot.Start();
|
await __bot.Start();
|
||||||
|
|
||||||
var timer = new Timer(5000);
|
var timer = new Timer(5000);
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ namespace AsyncFormUpdates
|
|||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
|
|
||||||
timer.Stop();
|
timer.Stop();
|
||||||
__bot.Stop();
|
await __bot.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async void Timer_Elapsed(object sender, ElapsedEventArgs e)
|
private static async void Timer_Elapsed(object sender, ElapsedEventArgs e)
|
||||||
@ -46,4 +46,4 @@ namespace AsyncFormUpdates
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,35 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
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("AsyncFormUpdates")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("")]
|
|
||||||
[assembly: AssemblyProduct("AsyncFormUpdates")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © 2021")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
|
|
||||||
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
|
|
||||||
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
|
||||||
[assembly: Guid("673a56f5-6110-4aed-a68d-562fd6ed3ea6")]
|
|
||||||
|
|
||||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
|
||||||
//
|
|
||||||
// Hauptversion
|
|
||||||
// Nebenversion
|
|
||||||
// Buildnummer
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
|
||||||
// indem Sie "*" wie unten gezeigt eingeben:
|
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
||||||
@ -123,7 +123,7 @@ public class MessageResult : ResultBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Confirm incomming action (i.e. Button click)
|
/// Confirm incoming action (i.e. Button click)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="message"></param>
|
/// <param name="message"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|||||||
@ -18,9 +18,9 @@ namespace TelegramBotBase;
|
|||||||
/// Bot base class for full Device/Context and Messagehandling
|
/// Bot base class for full Device/Context and Messagehandling
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
public class BotBase
|
public sealed class BotBase
|
||||||
{
|
{
|
||||||
public BotBase()
|
internal BotBase()
|
||||||
{
|
{
|
||||||
SystemSettings = new Dictionary<ESettings, uint>();
|
SystemSettings = new Dictionary<ESettings, uint>();
|
||||||
|
|
||||||
@ -32,10 +32,7 @@ public class BotBase
|
|||||||
|
|
||||||
BotCommandScopes = new Dictionary<BotCommandScope, List<BotCommand>>();
|
BotCommandScopes = new Dictionary<BotCommandScope, List<BotCommand>>();
|
||||||
|
|
||||||
Sessions = new SessionBase
|
Sessions = new SessionManager(this);
|
||||||
{
|
|
||||||
BotBase = this
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageClient Client { get; set; }
|
public MessageClient Client { get; set; }
|
||||||
@ -48,7 +45,7 @@ public class BotBase
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of all running/active sessions
|
/// List of all running/active sessions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SessionBase Sessions { get; set; }
|
public SessionManager Sessions { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains System commands which will be available at everytime and didnt get passed to forms, i.e. /start
|
/// Contains System commands which will be available at everytime and didnt get passed to forms, i.e. /start
|
||||||
@ -94,9 +91,10 @@ public class BotBase
|
|||||||
await Sessions.LoadSessionStates(StateMachine);
|
await Sessions.LoadSessionStates(StateMachine);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Enable auto session saving
|
// Enable auto session saving
|
||||||
if (GetSetting(ESettings.SaveSessionsOnConsoleExit, false))
|
if (GetSetting(ESettings.SaveSessionsOnConsoleExit, false))
|
||||||
{
|
{
|
||||||
|
// should be waited until finish
|
||||||
Console.SetHandler(() => { Sessions.SaveSessionStates().GetAwaiter().GetResult(); });
|
Console.SetHandler(() => { Sessions.SaveSessionStates().GetAwaiter().GetResult(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,8 +327,6 @@ public class BotBase
|
|||||||
|
|
||||||
private static readonly object EvMessage = new();
|
private static readonly object EvMessage = new();
|
||||||
|
|
||||||
private static object __evSystemCall = new();
|
|
||||||
|
|
||||||
public delegate Task BotCommandEventHandler(object sender, BotCommandEventArgs e);
|
public delegate Task BotCommandEventHandler(object sender, BotCommandEventArgs e);
|
||||||
|
|
||||||
private static readonly object EvException = new();
|
private static readonly object EvException = new();
|
||||||
@ -356,7 +352,7 @@ public class BotBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Will be called on incomming message
|
/// Will be called on incoming message
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<MessageIncomeEventArgs> Message
|
public event EventHandler<MessageIncomeEventArgs> Message
|
||||||
{
|
{
|
||||||
|
|||||||
@ -48,8 +48,6 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
|
|||||||
Client = _client
|
Client = _client
|
||||||
};
|
};
|
||||||
|
|
||||||
bot.Sessions.Client = bot.Client;
|
|
||||||
|
|
||||||
bot.BotCommandScopes = BotCommandScopes;
|
bot.BotCommandScopes = BotCommandScopes;
|
||||||
|
|
||||||
bot.StateMachine = _statemachine;
|
bot.StateMachine = _statemachine;
|
||||||
|
|||||||
@ -39,7 +39,7 @@ public class ButtonFormDataSource : IDataSource<ButtonRow>
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the amount of rows exisiting.
|
/// Returns the amount of rows existing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual int Count => ButtonForm.Count;
|
public virtual int Count => ButtonForm.Count;
|
||||||
@ -134,4 +134,4 @@ public class ButtonFormDataSource : IDataSource<ButtonRow>
|
|||||||
{
|
{
|
||||||
return ds.ButtonForm;
|
return ds.ButtonForm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ using TelegramBotBase.Base;
|
|||||||
namespace TelegramBotBase.Form;
|
namespace TelegramBotBase.Form;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is used to split incomming requests depending on the chat type.
|
/// This is used to split incoming requests depending on the chat type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SplitterForm : FormBase
|
public class SplitterForm : FormBase
|
||||||
{
|
{
|
||||||
@ -90,4 +90,4 @@ public class SplitterForm : FormBase
|
|||||||
{
|
{
|
||||||
return base.SentData(message);
|
return base.SentData(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,11 +25,11 @@ public class English : Localization
|
|||||||
Values["ToggleButton_OnIcon"] = "⚫";
|
Values["ToggleButton_OnIcon"] = "⚫";
|
||||||
Values["ToggleButton_OffIcon"] = "⚪";
|
Values["ToggleButton_OffIcon"] = "⚪";
|
||||||
Values["ToggleButton_Title"] = "Toggle";
|
Values["ToggleButton_Title"] = "Toggle";
|
||||||
Values["ToggleButton_Changed"] = "Choosen";
|
Values["ToggleButton_Changed"] = "Chosen";
|
||||||
Values["MultiToggleButton_SelectedIcon"] = "✅";
|
Values["MultiToggleButton_SelectedIcon"] = "✅";
|
||||||
Values["MultiToggleButton_Title"] = "Multi-Toggle";
|
Values["MultiToggleButton_Title"] = "Multi-Toggle";
|
||||||
Values["MultiToggleButton_Changed"] = "Choosen";
|
Values["MultiToggleButton_Changed"] = "Chosen";
|
||||||
Values["PromptDialog_Back"] = "Back";
|
Values["PromptDialog_Back"] = "Back";
|
||||||
Values["ToggleButton_Changed"] = "Setting changed";
|
Values["ToggleButton_Changed"] = "Setting changed";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,17 +16,18 @@ namespace TelegramBotBase;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Base class for managing all active sessions
|
/// Base class for managing all active sessions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SessionBase
|
public class SessionManager
|
||||||
{
|
{
|
||||||
public SessionBase()
|
public SessionManager(BotBase botBase)
|
||||||
{
|
{
|
||||||
|
BotBase = botBase;
|
||||||
SessionList = new Dictionary<long, DeviceSession>();
|
SessionList = new Dictionary<long, DeviceSession>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Basic message client.
|
/// The Basic message client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MessageClient Client { get; set; }
|
public MessageClient Client => BotBase.Client;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A list of all active sessions.
|
/// A list of all active sessions.
|
||||||
@ -37,18 +38,7 @@ public class SessionBase
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reference to the Main BotBase instance for later use.
|
/// Reference to the Main BotBase instance for later use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BotBase BotBase { get; set; }
|
public BotBase BotBase { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get device session from Device/ChatId
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public DeviceSession this[long key]
|
|
||||||
{
|
|
||||||
get => SessionList[key];
|
|
||||||
set => SessionList[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get device session from Device/ChatId
|
/// Get device session from Device/ChatId
|
||||||
@ -80,7 +70,7 @@ public class SessionBase
|
|||||||
|
|
||||||
await start.OnOpened(EventArgs.Empty);
|
await start.OnOpened(EventArgs.Empty);
|
||||||
|
|
||||||
this[deviceId] = ds;
|
SessionList[deviceId] = ds;
|
||||||
return ds;
|
return ds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +80,7 @@ public class SessionBase
|
|||||||
/// <param name="deviceId"></param>
|
/// <param name="deviceId"></param>
|
||||||
public void EndSession(long deviceId)
|
public void EndSession(long deviceId)
|
||||||
{
|
{
|
||||||
var d = this[deviceId];
|
var d = SessionList[deviceId];
|
||||||
if (d != null)
|
if (d != null)
|
||||||
{
|
{
|
||||||
SessionList.Remove(deviceId);
|
SessionList.Remove(deviceId);
|
||||||
@ -125,7 +125,7 @@ public class DeviceSession : IDeviceSession
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Confirm incomming action (i.e. Button click)
|
/// Confirm incoming action (i.e. Button click)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="message"></param>
|
/// <param name="message"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@ -992,4 +992,4 @@ public class DeviceSession : IDeviceSession
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,8 +22,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0"/>
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
|
||||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
|
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
@ -50,15 +50,15 @@
|
|||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="Archive\**"/>
|
<Compile Remove="Archive\**" />
|
||||||
<EmbeddedResource Remove="Archive\**"/>
|
<EmbeddedResource Remove="Archive\**" />
|
||||||
<None Remove="Archive\**"/>
|
<None Remove="Archive\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Telegram.Bot" Version="18.0.0"/>
|
<PackageReference Include="Telegram.Bot" Version="18.0.0" />
|
||||||
<PackageReference Include="Telegram.Bot.Extensions.Polling" Version="1.0.2"/>
|
<PackageReference Include="Telegram.Bot.Extensions.Polling" Version="1.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user