upstream: apply changes
This commit is contained in:
@@ -123,7 +123,7 @@ public class MessageResult : ResultBase
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Confirm incomming action (i.e. Button click)
|
||||
/// Confirm incoming action (i.e. Button click)
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
@@ -18,9 +18,9 @@ namespace TelegramBotBase;
|
||||
/// Bot base class for full Device/Context and Messagehandling
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class BotBase
|
||||
public sealed class BotBase
|
||||
{
|
||||
public BotBase()
|
||||
internal BotBase()
|
||||
{
|
||||
SystemSettings = new Dictionary<ESettings, uint>();
|
||||
|
||||
@@ -32,10 +32,7 @@ public class BotBase
|
||||
|
||||
BotCommandScopes = new Dictionary<BotCommandScope, List<BotCommand>>();
|
||||
|
||||
Sessions = new SessionBase
|
||||
{
|
||||
BotBase = this
|
||||
};
|
||||
Sessions = new SessionManager(this);
|
||||
}
|
||||
|
||||
public MessageClient Client { get; set; }
|
||||
@@ -48,7 +45,7 @@ public class BotBase
|
||||
/// <summary>
|
||||
/// List of all running/active sessions
|
||||
/// </summary>
|
||||
public SessionBase Sessions { get; set; }
|
||||
public SessionManager Sessions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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);
|
||||
}
|
||||
|
||||
//Enable auto session saving
|
||||
// Enable auto session saving
|
||||
if (GetSetting(ESettings.SaveSessionsOnConsoleExit, false))
|
||||
{
|
||||
// should be waited until finish
|
||||
Console.SetHandler(() => { Sessions.SaveSessionStates().GetAwaiter().GetResult(); });
|
||||
}
|
||||
|
||||
@@ -329,8 +327,6 @@ public class BotBase
|
||||
|
||||
private static readonly object EvMessage = new();
|
||||
|
||||
private static object __evSystemCall = new();
|
||||
|
||||
public delegate Task BotCommandEventHandler(object sender, BotCommandEventArgs e);
|
||||
|
||||
private static readonly object EvException = new();
|
||||
@@ -356,7 +352,7 @@ public class BotBase
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will be called on incomming message
|
||||
/// Will be called on incoming message
|
||||
/// </summary>
|
||||
public event EventHandler<MessageIncomeEventArgs> Message
|
||||
{
|
||||
|
||||
@@ -48,8 +48,6 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
|
||||
Client = _client
|
||||
};
|
||||
|
||||
bot.Sessions.Client = bot.Client;
|
||||
|
||||
bot.BotCommandScopes = BotCommandScopes;
|
||||
|
||||
bot.StateMachine = _statemachine;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ButtonFormDataSource : IDataSource<ButtonRow>
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the amount of rows exisiting.
|
||||
/// Returns the amount of rows existing.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual int Count => ButtonForm.Count;
|
||||
@@ -134,4 +134,4 @@ public class ButtonFormDataSource : IDataSource<ButtonRow>
|
||||
{
|
||||
return ds.ButtonForm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using TelegramBotBase.Base;
|
||||
namespace TelegramBotBase.Form;
|
||||
|
||||
/// <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>
|
||||
public class SplitterForm : FormBase
|
||||
{
|
||||
@@ -90,4 +90,4 @@ public class SplitterForm : FormBase
|
||||
{
|
||||
return base.SentData(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ public class English : Localization
|
||||
Values["ToggleButton_OnIcon"] = "⚫";
|
||||
Values["ToggleButton_OffIcon"] = "⚪";
|
||||
Values["ToggleButton_Title"] = "Toggle";
|
||||
Values["ToggleButton_Changed"] = "Choosen";
|
||||
Values["ToggleButton_Changed"] = "Chosen";
|
||||
Values["MultiToggleButton_SelectedIcon"] = "✅";
|
||||
Values["MultiToggleButton_Title"] = "Multi-Toggle";
|
||||
Values["MultiToggleButton_Changed"] = "Choosen";
|
||||
Values["MultiToggleButton_Changed"] = "Chosen";
|
||||
Values["PromptDialog_Back"] = "Back";
|
||||
Values["ToggleButton_Changed"] = "Setting changed";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,17 +16,18 @@ namespace TelegramBotBase;
|
||||
/// <summary>
|
||||
/// Base class for managing all active sessions
|
||||
/// </summary>
|
||||
public class SessionBase
|
||||
public class SessionManager
|
||||
{
|
||||
public SessionBase()
|
||||
public SessionManager(BotBase botBase)
|
||||
{
|
||||
BotBase = botBase;
|
||||
SessionList = new Dictionary<long, DeviceSession>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Basic message client.
|
||||
/// </summary>
|
||||
public MessageClient Client { get; set; }
|
||||
public MessageClient Client => BotBase.Client;
|
||||
|
||||
/// <summary>
|
||||
/// A list of all active sessions.
|
||||
@@ -37,18 +38,7 @@ public class SessionBase
|
||||
/// <summary>
|
||||
/// Reference to the Main BotBase instance for later use.
|
||||
/// </summary>
|
||||
public BotBase BotBase { get; set; }
|
||||
|
||||
/// <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;
|
||||
}
|
||||
public BotBase BotBase { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Get device session from Device/ChatId
|
||||
@@ -80,7 +70,7 @@ public class SessionBase
|
||||
|
||||
await start.OnOpened(EventArgs.Empty);
|
||||
|
||||
this[deviceId] = ds;
|
||||
SessionList[deviceId] = ds;
|
||||
return ds;
|
||||
}
|
||||
|
||||
@@ -90,7 +80,7 @@ public class SessionBase
|
||||
/// <param name="deviceId"></param>
|
||||
public void EndSession(long deviceId)
|
||||
{
|
||||
var d = this[deviceId];
|
||||
var d = SessionList[deviceId];
|
||||
if (d != null)
|
||||
{
|
||||
SessionList.Remove(deviceId);
|
||||
@@ -125,7 +125,7 @@ public class DeviceSession : IDeviceSession
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Confirm incomming action (i.e. Button click)
|
||||
/// Confirm incoming action (i.e. Button click)
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
@@ -992,4 +992,4 @@ public class DeviceSession : IDeviceSession
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0"/>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -50,15 +50,15 @@
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Archive\**"/>
|
||||
<EmbeddedResource Remove="Archive\**"/>
|
||||
<None Remove="Archive\**"/>
|
||||
<Compile Remove="Archive\**" />
|
||||
<EmbeddedResource Remove="Archive\**" />
|
||||
<None Remove="Archive\**" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Telegram.Bot" Version="18.0.0"/>
|
||||
<PackageReference Include="Telegram.Bot.Extensions.Polling" Version="1.0.2"/>
|
||||
<PackageReference Include="Telegram.Bot" Version="18.0.0" />
|
||||
<PackageReference Include="Telegram.Bot.Extensions.Polling" Version="1.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user