diff --git a/TelegramBotBase/Base/MessageClient.cs b/TelegramBotBase/Base/MessageClient.cs
index 99c45db..db7e27b 100644
--- a/TelegramBotBase/Base/MessageClient.cs
+++ b/TelegramBotBase/Base/MessageClient.cs
@@ -94,7 +94,7 @@ public class MessageClient
}
- public string ApiKey { get; set; }
+ public string ApiKey { get; }
public ITelegramBotClient TelegramClient { get; set; }
diff --git a/TelegramBotBase/BotBase.cs b/TelegramBotBase/BotBase.cs
index 14fe7ba..05f8053 100644
--- a/TelegramBotBase/BotBase.cs
+++ b/TelegramBotBase/BotBase.cs
@@ -15,13 +15,16 @@ using Console = TelegramBotBase.Tools.Console;
namespace TelegramBotBase;
///
-/// Bot base class for full Device/Context and Messagehandling
+/// Bot base class for full Device/Context and message handling
///
///
public sealed class BotBase
{
- internal BotBase()
+ internal BotBase(string apiKey, MessageClient client)
{
+ ApiKey = apiKey;
+ Client = client;
+
SystemSettings = new Dictionary();
SetSetting(ESettings.MaxNumberOfRetries, 5);
@@ -35,38 +38,38 @@ public sealed class BotBase
Sessions = new SessionManager(this);
}
- public MessageClient Client { get; set; }
+ public MessageClient Client { get; }
///
/// Your TelegramBot APIKey
///
- public string ApiKey { get; set; } = "";
+ public string ApiKey { get; }
///
/// List of all running/active sessions
///
- public SessionManager Sessions { get; set; }
+ public SessionManager Sessions { get; }
///
/// Contains System commands which will be available at everytime and didnt get passed to forms, i.e. /start
///
- public Dictionary> BotCommandScopes { get; set; } = new();
+ public Dictionary> BotCommandScopes { get; internal set; }
///
/// Enable the SessionState (you need to implement on call forms the IStateForm interface)
///
- public IStateMachine StateMachine { get; set; }
+ public IStateMachine StateMachine { get; internal set; }
///
/// Offers functionality to manage the creation process of the start form.
///
- public IStartFormFactory StartFormFactory { get; set; }
+ public IStartFormFactory StartFormFactory { get; internal set; }
///
/// Contains the message loop factory, which cares about "message-management."
///
- public IMessageLoopFactory MessageLoopFactory { get; set; }
+ public IMessageLoopFactory MessageLoopFactory { get; internal set; }
///
/// All internal used settings.
@@ -210,7 +213,6 @@ public sealed class BotBase
e.Device = ds;
await MessageLoopFactory.MessageLoop(this, ds, new UpdateResult(e.UpdateData, ds), e);
- //await Client_Loop(this, e);
}
catch (Exception ex)
{
@@ -315,7 +317,7 @@ public sealed class BotBase
return defaultValue;
}
- return SystemSettings[set] == 0u ? false : true;
+ return SystemSettings[set] != 0u;
}
diff --git a/TelegramBotBase/Builder/BotBaseBuilder.cs b/TelegramBotBase/Builder/BotBaseBuilder.cs
index f73e27d..dc22976 100644
--- a/TelegramBotBase/Builder/BotBaseBuilder.cs
+++ b/TelegramBotBase/Builder/BotBaseBuilder.cs
@@ -27,7 +27,7 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
private IMessageLoopFactory _messageLoopFactory;
- private IStateMachine _statemachine;
+ private IStateMachine _stateMachine;
private BotBaseBuilder()
{
@@ -41,19 +41,14 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
public BotBase Build()
{
- var bot = new BotBase
+ var bot = new BotBase(_apiKey, _client)
{
- ApiKey = _apiKey,
StartFormFactory = _factory,
- Client = _client
+ BotCommandScopes = BotCommandScopes,
+ StateMachine = _stateMachine,
+ MessageLoopFactory = _messageLoopFactory
};
- bot.BotCommandScopes = BotCommandScopes;
-
- bot.StateMachine = _statemachine;
-
- bot.MessageLoopFactory = _messageLoopFactory;
-
bot.MessageLoopFactory.UnhandledCall += bot.MessageLoopFactory_UnhandledCall;
return bot;
@@ -315,26 +310,26 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
public ILanguageSelectionStage UseSerialization(IStateMachine machine)
{
- _statemachine = machine;
+ _stateMachine = machine;
return this;
}
public ILanguageSelectionStage UseJSON(string path)
{
- _statemachine = new JsonStateMachine(path);
+ _stateMachine = new JsonStateMachine(path);
return this;
}
public ILanguageSelectionStage UseSimpleJSON(string path)
{
- _statemachine = new SimpleJsonStateMachine(path);
+ _stateMachine = new SimpleJsonStateMachine(path);
return this;
}
public ILanguageSelectionStage UseXML(string path)
{
- _statemachine = new XmlStateMachine(path);
+ _stateMachine = new XmlStateMachine(path);
return this;
}