diff --git a/TelegramBotBase/Base/ActionResult.cs b/TelegramBotBase/Base/ActionResult.cs deleted file mode 100644 index f8f6a0f..0000000 --- a/TelegramBotBase/Base/ActionResult.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TelegramBotBase.Base -{ - //public class ActionResult : ResultBase - //{ - // public Telegram.Bot.Args.CallbackQueryEventArgs RawCallbackData { get; set; } - - // public override long DeviceId - // { - // get - // { - // return this.RawCallbackData?.CallbackQuery.Message?.Chat.Id ?? 0; - // } - // } - - // public String Command - // { - // get - // { - // return this.RawCallbackData.CallbackQuery.Message.Text ?? ""; - // } - // } - - // public String RawData - // { - // get - // { - // return this.RawCallbackData.CallbackQuery.Data; - // } - // } - - // public T GetData() - // where T : class - // { - // T cd = null; - // try - // { - // cd = Newtonsoft.Json.JsonConvert.DeserializeObject(this.RawData); - - // return cd; - // } - // catch - // { - - // } - - // return null; - // } - - // /// - // /// Bestätigt den Erhalt der Aktion. - // /// - // /// - // /// - // public async Task ConfirmAction(String message = "") - // { - // try - // { - // await this.Client.TelegramClient.AnswerCallbackQueryAsync(this.RawCallbackData.CallbackQuery.Id, message); - // } - // catch - // { - - // } - // } - - // public override async Task DeleteMessage() - // { - // try - // { - // await this.Client.TelegramClient.DeleteMessageAsync(this.DeviceId, this.RawCallbackData.CallbackQuery.Message.MessageId); - // } - // catch - // { - - // } - // } - - // public ActionResult(Telegram.Bot.Args.CallbackQueryEventArgs callback) - // { - // this.RawCallbackData = callback; - // this.Message = callback.CallbackQuery.Message; - // } - - //} -} diff --git a/TelegramBotBase/Base/ButtonClickedEventArgs.cs b/TelegramBotBase/Base/ButtonClickedEventArgs.cs index 33750d9..94662a1 100644 --- a/TelegramBotBase/Base/ButtonClickedEventArgs.cs +++ b/TelegramBotBase/Base/ButtonClickedEventArgs.cs @@ -7,6 +7,9 @@ using TelegramBotBase.Form; namespace TelegramBotBase.Base { + /// + /// Button get clicked event + /// public class ButtonClickedEventArgs : EventArgs { public ButtonBase Button { get; set; } diff --git a/TelegramBotBase/Base/ControlBase.cs b/TelegramBotBase/Base/ControlBase.cs index 707ad27..32ac97c 100644 --- a/TelegramBotBase/Base/ControlBase.cs +++ b/TelegramBotBase/Base/ControlBase.cs @@ -6,6 +6,9 @@ using System.Threading.Tasks; namespace TelegramBotBase.Base { + /// + /// Base class for controls + /// public class ControlBase { public Sessions.DeviceSession Device { get; set; } diff --git a/TelegramBotBase/Form/FormBase.cs b/TelegramBotBase/Base/FormBase.cs similarity index 73% rename from TelegramBotBase/Form/FormBase.cs rename to TelegramBotBase/Base/FormBase.cs index 0dc8e2b..d5c7d23 100644 --- a/TelegramBotBase/Form/FormBase.cs +++ b/TelegramBotBase/Base/FormBase.cs @@ -8,6 +8,9 @@ using TelegramBotBase.Sessions; namespace TelegramBotBase.Form { + /// + /// Base class for forms + /// public class FormBase : IDisposable { public DeviceSession Device { get; set; } @@ -17,7 +20,7 @@ namespace TelegramBotBase.Form public bool CustomEventManagement { get; set; } = false; /// - /// Gibt an, dass das Formular gewechselt wurde, es werden keine weiteren Events ausgeführt + /// contains if the form has been switched (navigated) /// public bool FormSwitched { get; set; } = false; @@ -34,7 +37,7 @@ namespace TelegramBotBase.Form } /// - /// Wird nur aufgerufen, beim erstmaligen Laden des Formulares. + /// Will get called at the initialization (once per context) /// public virtual async Task Init(params object[] args) { @@ -75,30 +78,8 @@ namespace TelegramBotBase.Form } - ///// - ///// Navigiert zur neuen Form. - ///// - ///// - ///// - //public async Task NavigateTo(FormBase newForm) - //{ - // DeviceSession ds = this.Device; - // if (ds == null) - // return; - - // this.FormSwitched = true; - - // ds.ActiveForm = newForm; - // newForm.Client = this.Client; - // newForm.Device = ds; - - // await this.Closed(); - - // await newForm.Opened(); - //} - /// - /// Navigiert zur neuen Form. + /// Navigates to a new form /// /// /// @@ -121,6 +102,9 @@ namespace TelegramBotBase.Form await newForm.Opened(); } + /// + /// Cleanup + /// public void Dispose() { this.Client = null; diff --git a/TelegramBotBase/Base/MessageClient.cs b/TelegramBotBase/Base/MessageClient.cs index 9ab07eb..91af2c8 100644 --- a/TelegramBotBase/Base/MessageClient.cs +++ b/TelegramBotBase/Base/MessageClient.cs @@ -7,6 +7,9 @@ using System.Threading.Tasks; namespace TelegramBotBase.Base { + /// + /// Base class for message handling + /// public class MessageClient { diff --git a/TelegramBotBase/Base/MessageResult.cs b/TelegramBotBase/Base/MessageResult.cs index 879a5a6..6f0ad9b 100644 --- a/TelegramBotBase/Base/MessageResult.cs +++ b/TelegramBotBase/Base/MessageResult.cs @@ -12,6 +12,9 @@ namespace TelegramBotBase.Base public Telegram.Bot.Args.CallbackQueryEventArgs RawCallbackData { get; set; } + /// + /// Returns the Device/ChatId + /// public override long DeviceId { get @@ -21,7 +24,7 @@ namespace TelegramBotBase.Base } /// - /// Die Id der Nachricht + /// The message id /// public new int MessageId { @@ -48,7 +51,7 @@ namespace TelegramBotBase.Base } /// - /// Ist diese eine Aktion? (z.B.: Button Klick) + /// Is this an action ? (i.e. button click) /// public bool IsAction { @@ -87,7 +90,7 @@ namespace TelegramBotBase.Base } /// - /// Bestätigt den Erhalt der Aktion. + /// Confirm incomming action (i.e. Button click) /// /// /// diff --git a/TelegramBotBase/Base/ResultBase.cs b/TelegramBotBase/Base/ResultBase.cs index b792b7d..c2d7e8e 100644 --- a/TelegramBotBase/Base/ResultBase.cs +++ b/TelegramBotBase/Base/ResultBase.cs @@ -23,7 +23,7 @@ namespace TelegramBotBase.Base public Telegram.Bot.Types.Message Message { get; set; } /// - /// Löscht die aktuelle Nachricht, oder die übergebene + /// Deletes the current message /// /// /// @@ -33,7 +33,7 @@ namespace TelegramBotBase.Base } /// - /// Löscht die aktuelle Nachricht, oder die übergebene + ///Deletes the current message or the given one. /// /// /// diff --git a/TelegramBotBase/Base/SystemCallEventArgs.cs b/TelegramBotBase/Base/SystemCallEventArgs.cs index bf0b0f3..55f39d2 100644 --- a/TelegramBotBase/Base/SystemCallEventArgs.cs +++ b/TelegramBotBase/Base/SystemCallEventArgs.cs @@ -7,6 +7,9 @@ using TelegramBotBase.Sessions; namespace TelegramBotBase.Base { + /// + /// Base class for given system call results + /// public class SystemCallEventArgs : EventArgs { public String Command { get; set; } diff --git a/TelegramBotBase/BotBase.cs b/TelegramBotBase/BotBase.cs index 0b38963..8f8017d 100644 --- a/TelegramBotBase/BotBase.cs +++ b/TelegramBotBase/BotBase.cs @@ -10,14 +10,23 @@ using TelegramBotBase.Sessions; namespace TelegramBotBase { + /// + /// Bot base class for full Device/Context and Messagehandling + /// + /// public class BotBase where T : FormBase { public MessageClient Client { get; set; } + /// + /// Your TelegramBot APIKey + /// public String APIKey { get; set; } = ""; - + /// + /// List of all running/active sessions + /// public SessionBase Sessions { get; set; } /// @@ -39,7 +48,7 @@ namespace TelegramBotBase /// - /// SKips all messages during running (good for big delay updates) + /// Skips all messages during running (good for big delay updates) /// public bool SkipAllMessages { get; set; } = false; @@ -48,7 +57,10 @@ namespace TelegramBotBase /// public bool LogAllMessages { get; set; } = false; - + /// + /// Simple start of your Bot with the APIKey + /// + /// public BotBase(String apiKey) { this.APIKey = apiKey; @@ -61,6 +73,9 @@ namespace TelegramBotBase this.Sessions.Client = this.Client; } + /// + /// Start your Bot + /// public void Start() { if (this.Client == null) @@ -73,7 +88,9 @@ namespace TelegramBotBase this.Client.TelegramClient.StartReceiving(); } - + /// + /// Stop your Bot + /// public void Stop() { if (this.Client == null) @@ -82,7 +99,11 @@ namespace TelegramBotBase this.Client.TelegramClient.StopReceiving(); } - + /// + /// Send a message to all active Sessions. + /// + /// + /// public async Task SentToAll(String message) { if (this.Client == null) @@ -258,7 +279,7 @@ namespace TelegramBotBase } /// - /// Wird aufgerufen wenn eine Session begonnen wird + /// Will be called if a session/context gets started /// public event EventHandler SessionBegins @@ -279,6 +300,9 @@ namespace TelegramBotBase } + /// + /// Will be called on incomming message + /// public event EventHandler Message { add @@ -297,6 +321,9 @@ namespace TelegramBotBase } + /// + /// Will be called if a system call gets raised + /// public event EventHandler SystemCall { add @@ -315,6 +342,9 @@ namespace TelegramBotBase } + /// + /// Will be called on an inner exception + /// public event EventHandler Exception { add @@ -333,6 +363,9 @@ namespace TelegramBotBase } + /// + /// Will be called if no form handeled this call + /// public event EventHandler UnhandledCall { add diff --git a/TelegramBotBase/Controls/ProgressBar.cs b/TelegramBotBase/Controls/ProgressBar.cs index 63a032a..77678f6 100644 --- a/TelegramBotBase/Controls/ProgressBar.cs +++ b/TelegramBotBase/Controls/ProgressBar.cs @@ -6,6 +6,9 @@ using System.Threading.Tasks; namespace TelegramBotBase.Controls { + /// + /// A simple control for show and managing progress. + /// public class ProgressBar : Base.ControlBase { public enum eProgressStyle diff --git a/TelegramBotBase/Form/AlertDialog.cs b/TelegramBotBase/Form/AlertDialog.cs index 4634970..bfbed26 100644 --- a/TelegramBotBase/Form/AlertDialog.cs +++ b/TelegramBotBase/Form/AlertDialog.cs @@ -8,6 +8,9 @@ using TelegramBotBase.Base; namespace TelegramBotBase.Form { + /// + /// A simple prompt dialog with one ok Button + /// public class AlertDialog : PromptDialog { public String ButtonText { get; set; } diff --git a/TelegramBotBase/Form/ArrayPromptDialog.cs b/TelegramBotBase/Form/ArrayPromptDialog.cs index 7a423b8..1677281 100644 --- a/TelegramBotBase/Form/ArrayPromptDialog.cs +++ b/TelegramBotBase/Form/ArrayPromptDialog.cs @@ -8,6 +8,9 @@ using TelegramBotBase.Base; namespace TelegramBotBase.Form { + /// + /// A prompt with a lot of buttons + /// public class ArrayPromptDialog : FormBase { public String Message { get; set; } diff --git a/TelegramBotBase/Form/AutoCleanForm.cs b/TelegramBotBase/Form/AutoCleanForm.cs index 22caa82..d48be5b 100644 --- a/TelegramBotBase/Form/AutoCleanForm.cs +++ b/TelegramBotBase/Form/AutoCleanForm.cs @@ -8,6 +8,9 @@ using TelegramBotBase.Base; namespace TelegramBotBase.Form { + /// + /// A form which cleans up old messages sent within + /// public class AutoCleanForm : FormBase { List OldMessages { get; set; } @@ -16,8 +19,9 @@ namespace TelegramBotBase.Form public enum eDeleteMode { - OnEveryCall = 0, - OnLeavingForm = 1 + None = 0, + OnEveryCall = 1, + OnLeavingForm = 2 } public AutoCleanForm() diff --git a/TelegramBotBase/Form/ButtonBase.cs b/TelegramBotBase/Form/ButtonBase.cs index ac9e34d..48891ab 100644 --- a/TelegramBotBase/Form/ButtonBase.cs +++ b/TelegramBotBase/Form/ButtonBase.cs @@ -6,6 +6,9 @@ using System.Threading.Tasks; namespace TelegramBotBase.Form { + /// + /// Base class for button handling + /// public class ButtonBase { public String Text { get; set; } diff --git a/TelegramBotBase/Form/ButtonForm.cs b/TelegramBotBase/Form/ButtonForm.cs index b0d30bb..fe60fbd 100644 --- a/TelegramBotBase/Form/ButtonForm.cs +++ b/TelegramBotBase/Form/ButtonForm.cs @@ -7,6 +7,9 @@ using Telegram.Bot.Types.ReplyMarkups; namespace TelegramBotBase.Form { + /// + /// Base class for an buttons array + /// public class ButtonForm { List> Buttons = new List>(); @@ -47,7 +50,7 @@ namespace TelegramBotBase.Form } /// - /// Fügt die Buttons automatisch aufgesplittet in Spalten ein. + /// Add buttons splitted in the amount of columns (i.e. 2 per row...) /// /// /// diff --git a/TelegramBotBase/Form/CallbackData.cs b/TelegramBotBase/Form/CallbackData.cs index 8f31a11..f7a74e3 100644 --- a/TelegramBotBase/Form/CallbackData.cs +++ b/TelegramBotBase/Form/CallbackData.cs @@ -6,6 +6,9 @@ using System.Threading.Tasks; namespace TelegramBotBase.Form { + /// + /// Base class for serializing buttons and data + /// public class CallbackData { public String Method { get; set; } diff --git a/TelegramBotBase/Properties/AssemblyInfo.cs b/TelegramBotBase/Properties/AssemblyInfo.cs index 3ef8564..0605170 100644 --- a/TelegramBotBase/Properties/AssemblyInfo.cs +++ b/TelegramBotBase/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ 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("TelegramBotBase")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyTitle("TelegramBotBase Framework")] +[assembly: AssemblyDescription("A simple addon for the original C# Telegram Bot library.")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TelegramBotBase")] -[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyCompany("Florian Dahn")] +[assembly: AssemblyProduct("TelegramBotBase Framework")] +[assembly: AssemblyCopyright("Copyright © Florian Dahn 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -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.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.2.0.0")] +[assembly: AssemblyFileVersion("1.2.0.0")] diff --git a/TelegramBotBase/SessionBase.cs b/TelegramBotBase/SessionBase.cs index 482aa32..7039718 100644 --- a/TelegramBotBase/SessionBase.cs +++ b/TelegramBotBase/SessionBase.cs @@ -8,6 +8,9 @@ using TelegramBotBase.Form; using TelegramBotBase.Sessions; namespace TelegramBotBase { + /// + /// Base class for managing all active sessions + /// public class SessionBase { public MessageClient Client { get; set; } @@ -20,6 +23,11 @@ namespace TelegramBotBase this.SessionList = new Dictionary(); } + /// + /// Get device session from Device/ChatId + /// + /// + /// public DeviceSession this[long key] { get @@ -32,12 +40,23 @@ namespace TelegramBotBase } } + /// + /// Get device session from Device/ChatId + /// + /// + /// public DeviceSession GetSession(long deviceId) { DeviceSession ds = this.SessionList.FirstOrDefault(a => a.Key == deviceId).Value ?? null; return ds; } + /// + /// Start a new session + /// + /// + /// + /// public async Task StartSession(long deviceId) where T : FormBase { @@ -56,7 +75,10 @@ namespace TelegramBotBase return ds; } - + /// + /// End session + /// + /// public void EndSession(long deviceId) { var d = this[deviceId]; diff --git a/TelegramBotBase/Sessions/DeviceSession.cs b/TelegramBotBase/Sessions/DeviceSession.cs index e358d1f..308191d 100644 --- a/TelegramBotBase/Sessions/DeviceSession.cs +++ b/TelegramBotBase/Sessions/DeviceSession.cs @@ -17,8 +17,14 @@ using TelegramBotBase.Form; namespace TelegramBotBase.Sessions { + /// + /// Base class for a device/chat session + /// public class DeviceSession { + /// + /// Device or chat id + /// public long DeviceId { get; set; } public DateTime LastAction { get; set; } @@ -57,7 +63,7 @@ namespace TelegramBotBase.Sessions } /// - /// Bearbeitet die bestehende Text-Nachricht. + /// Edits the text message /// /// /// @@ -89,9 +95,10 @@ namespace TelegramBotBase.Sessions } /// - /// Sendet eine einfache Text-Nachricht. + /// Sends a simple text message /// /// + /// /// /// /// @@ -128,9 +135,10 @@ namespace TelegramBotBase.Sessions } /// - /// Sendet eine einfache Text-Nachricht. + /// Sends a simple text message /// /// + /// /// /// /// @@ -160,9 +168,10 @@ namespace TelegramBotBase.Sessions } /// - /// Sendet ein Bild + /// Sends an image /// /// + /// /// /// /// @@ -198,43 +207,49 @@ namespace TelegramBotBase.Sessions } /// - /// Sendet ein Bild + /// Sends an image /// /// /// + /// /// /// /// - public async Task SendPhoto(Image image, String name, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false) + public async Task SendPhoto(Image image, String name, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false) { using (var fileStream = Tools.Images.ToStream(image, ImageFormat.Png)) { InputOnlineFile fts = new InputOnlineFile(fileStream, name); - await SendPhoto(fts, buttons, replyTo, disableNotification); + var m = await SendPhoto(fts, buttons, replyTo, disableNotification); + + return m; } } /// - /// Sendet ein Bild + /// Sends an image /// /// /// + /// /// /// /// - public async Task SendPhoto(Bitmap image, String name, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false) + public async Task SendPhoto(Bitmap image, String name, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false) { using (var fileStream = Tools.Images.ToStream(image, ImageFormat.Png)) { InputOnlineFile fts = new InputOnlineFile(fileStream, name); - await SendPhoto(fts, buttons, replyTo, disableNotification); + var m = await SendPhoto(fts, buttons, replyTo, disableNotification); + + return m; } } /// - /// Sendet ein Dokument + /// Sends an document /// /// /// @@ -243,17 +258,19 @@ namespace TelegramBotBase.Sessions /// /// /// - public async Task SendDocument(String filename, byte[] document, String caption = "", ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false) + public async Task SendDocument(String filename, byte[] document, String caption = "", ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false) { MemoryStream ms = new MemoryStream(document); InputOnlineFile fts = new InputOnlineFile(ms, filename); - await SendDocument(fts, caption, buttons, replyTo, disableNotification); + var m = await SendDocument(fts, caption, buttons, replyTo, disableNotification); + + return m; } /// - /// Sendet ein Dokument + /// Sends an document /// /// /// @@ -261,7 +278,7 @@ namespace TelegramBotBase.Sessions /// /// /// - public async Task SendDocument(InputOnlineFile 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) @@ -269,13 +286,15 @@ namespace TelegramBotBase.Sessions markup = buttons; } - var message = await this.Client.TelegramClient.SendDocumentAsync(this.DeviceId, document, caption, replyMarkup: markup, disableNotification: disableNotification, replyToMessageId: replyTo); + var m = await this.Client.TelegramClient.SendDocumentAsync(this.DeviceId, document, caption, replyMarkup: markup, disableNotification: disableNotification, replyToMessageId: replyTo); - OnMessageSent(new MessageSentEventArgs(message.MessageId, message)); + OnMessageSent(new MessageSentEventArgs(m.MessageId, m)); + + return m; } /// - /// Legt eine Chat Aktion Fest (Wird angezeigt) + /// Set a chat action (showed to the user) /// /// /// @@ -285,7 +304,7 @@ namespace TelegramBotBase.Sessions } /// - /// Löscht die aktuelle Nachricht, oder die übergebene + /// Deletes a message /// /// /// @@ -306,16 +325,18 @@ namespace TelegramBotBase.Sessions } /// - /// Löscht die aktuelle Nachricht, oder die übergebene + /// Deletes the given message /// - /// + /// /// public virtual async Task DeleteMessage(Message message) { return await DeleteMessage(message.MessageId); } - + /// + /// Eventhandler for sent messages + /// public event EventHandler MessageSent { add diff --git a/TelegramBotBase/TelegramBotBase.csproj b/TelegramBotBase/TelegramBotBase.csproj index d0cc597..fe864ef 100644 --- a/TelegramBotBase/TelegramBotBase.csproj +++ b/TelegramBotBase/TelegramBotBase.csproj @@ -9,8 +9,9 @@ Properties TelegramBotBase TelegramBotBase - v4.5.2 + v4.5.1 512 + true @@ -28,35 +29,26 @@ TRACE prompt 4 + bin\Release\TelegramBotBase.xml + + + true - - ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll - True - - - ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll - True - - - ..\..\..\UGI\packages\Telegram.Bot.14.6.0\lib\net45\Telegram.Bot.dll - True - - @@ -75,7 +67,7 @@ - + @@ -84,7 +76,15 @@ - + + 11.0.2 + + + 4.3.0 + + + 14.10.0 +