- adding a lot of english translations

- switching german to english
- some bug fixes in device sessions and improvements
- adding xml documentation
This commit is contained in:
FlorianDahn 2019-02-22 16:35:35 +01:00
parent 7439b009be
commit aa53dc9386
22 changed files with 203 additions and 214 deletions

View File

@ -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<T>()
// where T : class
// {
// T cd = null;
// try
// {
// cd = Newtonsoft.Json.JsonConvert.DeserializeObject<T>(this.RawData);
// return cd;
// }
// catch
// {
// }
// return null;
// }
// /// <summary>
// /// Bestätigt den Erhalt der Aktion.
// /// </summary>
// /// <param name="message"></param>
// /// <returns></returns>
// 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;
// }
//}
}

View File

@ -7,6 +7,9 @@ using TelegramBotBase.Form;
namespace TelegramBotBase.Base namespace TelegramBotBase.Base
{ {
/// <summary>
/// Button get clicked event
/// </summary>
public class ButtonClickedEventArgs : EventArgs public class ButtonClickedEventArgs : EventArgs
{ {
public ButtonBase Button { get; set; } public ButtonBase Button { get; set; }

View File

@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace TelegramBotBase.Base namespace TelegramBotBase.Base
{ {
/// <summary>
/// Base class for controls
/// </summary>
public class ControlBase public class ControlBase
{ {
public Sessions.DeviceSession Device { get; set; } public Sessions.DeviceSession Device { get; set; }

View File

@ -8,6 +8,9 @@ using TelegramBotBase.Sessions;
namespace TelegramBotBase.Form namespace TelegramBotBase.Form
{ {
/// <summary>
/// Base class for forms
/// </summary>
public class FormBase : IDisposable public class FormBase : IDisposable
{ {
public DeviceSession Device { get; set; } public DeviceSession Device { get; set; }
@ -17,7 +20,7 @@ namespace TelegramBotBase.Form
public bool CustomEventManagement { get; set; } = false; public bool CustomEventManagement { get; set; } = false;
/// <summary> /// <summary>
/// Gibt an, dass das Formular gewechselt wurde, es werden keine weiteren Events ausgeführt /// contains if the form has been switched (navigated)
/// </summary> /// </summary>
public bool FormSwitched { get; set; } = false; public bool FormSwitched { get; set; } = false;
@ -34,7 +37,7 @@ namespace TelegramBotBase.Form
} }
/// <summary> /// <summary>
/// Wird nur aufgerufen, beim erstmaligen Laden des Formulares. /// Will get called at the initialization (once per context)
/// </summary> /// </summary>
public virtual async Task Init(params object[] args) public virtual async Task Init(params object[] args)
{ {
@ -75,30 +78,8 @@ namespace TelegramBotBase.Form
} }
///// <summary>
///// Navigiert zur neuen Form.
///// </summary>
///// <param name="newForm"></param>
///// <returns></returns>
//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();
//}
/// <summary> /// <summary>
/// Navigiert zur neuen Form. /// Navigates to a new form
/// </summary> /// </summary>
/// <param name="newForm"></param> /// <param name="newForm"></param>
/// <returns></returns> /// <returns></returns>
@ -121,6 +102,9 @@ namespace TelegramBotBase.Form
await newForm.Opened(); await newForm.Opened();
} }
/// <summary>
/// Cleanup
/// </summary>
public void Dispose() public void Dispose()
{ {
this.Client = null; this.Client = null;

View File

@ -7,6 +7,9 @@ using System.Threading.Tasks;
namespace TelegramBotBase.Base namespace TelegramBotBase.Base
{ {
/// <summary>
/// Base class for message handling
/// </summary>
public class MessageClient public class MessageClient
{ {

View File

@ -12,6 +12,9 @@ namespace TelegramBotBase.Base
public Telegram.Bot.Args.CallbackQueryEventArgs RawCallbackData { get; set; } public Telegram.Bot.Args.CallbackQueryEventArgs RawCallbackData { get; set; }
/// <summary>
/// Returns the Device/ChatId
/// </summary>
public override long DeviceId public override long DeviceId
{ {
get get
@ -21,7 +24,7 @@ namespace TelegramBotBase.Base
} }
/// <summary> /// <summary>
/// Die Id der Nachricht /// The message id
/// </summary> /// </summary>
public new int MessageId public new int MessageId
{ {
@ -48,7 +51,7 @@ namespace TelegramBotBase.Base
} }
/// <summary> /// <summary>
/// Ist diese eine Aktion? (z.B.: Button Klick) /// Is this an action ? (i.e. button click)
/// </summary> /// </summary>
public bool IsAction public bool IsAction
{ {
@ -87,7 +90,7 @@ namespace TelegramBotBase.Base
} }
/// <summary> /// <summary>
/// Bestätigt den Erhalt der Aktion. /// Confirm incomming action (i.e. Button click)
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
/// <returns></returns> /// <returns></returns>

View File

@ -23,7 +23,7 @@ namespace TelegramBotBase.Base
public Telegram.Bot.Types.Message Message { get; set; } public Telegram.Bot.Types.Message Message { get; set; }
/// <summary> /// <summary>
/// Löscht die aktuelle Nachricht, oder die übergebene /// Deletes the current message
/// </summary> /// </summary>
/// <param name="messageId"></param> /// <param name="messageId"></param>
/// <returns></returns> /// <returns></returns>
@ -33,7 +33,7 @@ namespace TelegramBotBase.Base
} }
/// <summary> /// <summary>
/// Löscht die aktuelle Nachricht, oder die übergebene ///Deletes the current message or the given one.
/// </summary> /// </summary>
/// <param name="messageId"></param> /// <param name="messageId"></param>
/// <returns></returns> /// <returns></returns>

View File

@ -7,6 +7,9 @@ using TelegramBotBase.Sessions;
namespace TelegramBotBase.Base namespace TelegramBotBase.Base
{ {
/// <summary>
/// Base class for given system call results
/// </summary>
public class SystemCallEventArgs : EventArgs public class SystemCallEventArgs : EventArgs
{ {
public String Command { get; set; } public String Command { get; set; }

View File

@ -10,14 +10,23 @@ using TelegramBotBase.Sessions;
namespace TelegramBotBase namespace TelegramBotBase
{ {
/// <summary>
/// Bot base class for full Device/Context and Messagehandling
/// </summary>
/// <typeparam name="T"></typeparam>
public class BotBase<T> public class BotBase<T>
where T : FormBase where T : FormBase
{ {
public MessageClient Client { get; set; } public MessageClient Client { get; set; }
/// <summary>
/// Your TelegramBot APIKey
/// </summary>
public String APIKey { get; set; } = ""; public String APIKey { get; set; } = "";
/// <summary>
/// List of all running/active sessions
/// </summary>
public SessionBase Sessions { get; set; } public SessionBase Sessions { get; set; }
/// <summary> /// <summary>
@ -39,7 +48,7 @@ namespace TelegramBotBase
/// <summary> /// <summary>
/// SKips all messages during running (good for big delay updates) /// Skips all messages during running (good for big delay updates)
/// </summary> /// </summary>
public bool SkipAllMessages { get; set; } = false; public bool SkipAllMessages { get; set; } = false;
@ -48,7 +57,10 @@ namespace TelegramBotBase
/// </summary> /// </summary>
public bool LogAllMessages { get; set; } = false; public bool LogAllMessages { get; set; } = false;
/// <summary>
/// Simple start of your Bot with the APIKey
/// </summary>
/// <param name="apiKey"></param>
public BotBase(String apiKey) public BotBase(String apiKey)
{ {
this.APIKey = apiKey; this.APIKey = apiKey;
@ -61,6 +73,9 @@ namespace TelegramBotBase
this.Sessions.Client = this.Client; this.Sessions.Client = this.Client;
} }
/// <summary>
/// Start your Bot
/// </summary>
public void Start() public void Start()
{ {
if (this.Client == null) if (this.Client == null)
@ -73,7 +88,9 @@ namespace TelegramBotBase
this.Client.TelegramClient.StartReceiving(); this.Client.TelegramClient.StartReceiving();
} }
/// <summary>
/// Stop your Bot
/// </summary>
public void Stop() public void Stop()
{ {
if (this.Client == null) if (this.Client == null)
@ -82,7 +99,11 @@ namespace TelegramBotBase
this.Client.TelegramClient.StopReceiving(); this.Client.TelegramClient.StopReceiving();
} }
/// <summary>
/// Send a message to all active Sessions.
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
public async Task SentToAll(String message) public async Task SentToAll(String message)
{ {
if (this.Client == null) if (this.Client == null)
@ -258,7 +279,7 @@ namespace TelegramBotBase
} }
/// <summary> /// <summary>
/// Wird aufgerufen wenn eine Session begonnen wird /// Will be called if a session/context gets started
/// </summary> /// </summary>
public event EventHandler<SessionBeginResult> SessionBegins public event EventHandler<SessionBeginResult> SessionBegins
@ -279,6 +300,9 @@ namespace TelegramBotBase
} }
/// <summary>
/// Will be called on incomming message
/// </summary>
public event EventHandler<MessageIncomeResult> Message public event EventHandler<MessageIncomeResult> Message
{ {
add add
@ -297,6 +321,9 @@ namespace TelegramBotBase
} }
/// <summary>
/// Will be called if a system call gets raised
/// </summary>
public event EventHandler<SystemCallEventArgs> SystemCall public event EventHandler<SystemCallEventArgs> SystemCall
{ {
add add
@ -315,6 +342,9 @@ namespace TelegramBotBase
} }
/// <summary>
/// Will be called on an inner exception
/// </summary>
public event EventHandler<SystemExceptionEventArgs> Exception public event EventHandler<SystemExceptionEventArgs> Exception
{ {
add add
@ -333,6 +363,9 @@ namespace TelegramBotBase
} }
/// <summary>
/// Will be called if no form handeled this call
/// </summary>
public event EventHandler<UnhandledCallEventArgs> UnhandledCall public event EventHandler<UnhandledCallEventArgs> UnhandledCall
{ {
add add

View File

@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace TelegramBotBase.Controls namespace TelegramBotBase.Controls
{ {
/// <summary>
/// A simple control for show and managing progress.
/// </summary>
public class ProgressBar : Base.ControlBase public class ProgressBar : Base.ControlBase
{ {
public enum eProgressStyle public enum eProgressStyle

View File

@ -8,6 +8,9 @@ using TelegramBotBase.Base;
namespace TelegramBotBase.Form namespace TelegramBotBase.Form
{ {
/// <summary>
/// A simple prompt dialog with one ok Button
/// </summary>
public class AlertDialog : PromptDialog public class AlertDialog : PromptDialog
{ {
public String ButtonText { get; set; } public String ButtonText { get; set; }

View File

@ -8,6 +8,9 @@ using TelegramBotBase.Base;
namespace TelegramBotBase.Form namespace TelegramBotBase.Form
{ {
/// <summary>
/// A prompt with a lot of buttons
/// </summary>
public class ArrayPromptDialog : FormBase public class ArrayPromptDialog : FormBase
{ {
public String Message { get; set; } public String Message { get; set; }

View File

@ -8,6 +8,9 @@ using TelegramBotBase.Base;
namespace TelegramBotBase.Form namespace TelegramBotBase.Form
{ {
/// <summary>
/// A form which cleans up old messages sent within
/// </summary>
public class AutoCleanForm : FormBase public class AutoCleanForm : FormBase
{ {
List<Message> OldMessages { get; set; } List<Message> OldMessages { get; set; }
@ -16,8 +19,9 @@ namespace TelegramBotBase.Form
public enum eDeleteMode public enum eDeleteMode
{ {
OnEveryCall = 0, None = 0,
OnLeavingForm = 1 OnEveryCall = 1,
OnLeavingForm = 2
} }
public AutoCleanForm() public AutoCleanForm()

View File

@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace TelegramBotBase.Form namespace TelegramBotBase.Form
{ {
/// <summary>
/// Base class for button handling
/// </summary>
public class ButtonBase public class ButtonBase
{ {
public String Text { get; set; } public String Text { get; set; }

View File

@ -7,6 +7,9 @@ using Telegram.Bot.Types.ReplyMarkups;
namespace TelegramBotBase.Form namespace TelegramBotBase.Form
{ {
/// <summary>
/// Base class for an buttons array
/// </summary>
public class ButtonForm public class ButtonForm
{ {
List<List<ButtonBase>> Buttons = new List<List<ButtonBase>>(); List<List<ButtonBase>> Buttons = new List<List<ButtonBase>>();
@ -47,7 +50,7 @@ namespace TelegramBotBase.Form
} }
/// <summary> /// <summary>
/// Fügt die Buttons automatisch aufgesplittet in Spalten ein. /// Add buttons splitted in the amount of columns (i.e. 2 per row...)
/// </summary> /// </summary>
/// <param name="buttons"></param> /// <param name="buttons"></param>
/// <param name="buttonsPerRow"></param> /// <param name="buttonsPerRow"></param>

View File

@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace TelegramBotBase.Form namespace TelegramBotBase.Form
{ {
/// <summary>
/// Base class for serializing buttons and data
/// </summary>
public class CallbackData public class CallbackData
{ {
public String Method { get; set; } public String Method { get; set; }

View File

@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden // Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind. // die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("TelegramBotBase")] [assembly: AssemblyTitle("TelegramBotBase Framework")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("A simple addon for the original C# Telegram Bot library.")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("Florian Dahn")]
[assembly: AssemblyProduct("TelegramBotBase")] [assembly: AssemblyProduct("TelegramBotBase Framework")]
[assembly: AssemblyCopyright("Copyright © 2017")] [assembly: AssemblyCopyright("Copyright © Florian Dahn 2019")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.2.0.0")]

View File

@ -8,6 +8,9 @@ using TelegramBotBase.Form;
using TelegramBotBase.Sessions; using TelegramBotBase.Sessions;
namespace TelegramBotBase namespace TelegramBotBase
{ {
/// <summary>
/// Base class for managing all active sessions
/// </summary>
public class SessionBase public class SessionBase
{ {
public MessageClient Client { get; set; } public MessageClient Client { get; set; }
@ -20,6 +23,11 @@ namespace TelegramBotBase
this.SessionList = new Dictionary<long, DeviceSession>(); this.SessionList = new Dictionary<long, DeviceSession>();
} }
/// <summary>
/// Get device session from Device/ChatId
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public DeviceSession this[long key] public DeviceSession this[long key]
{ {
get get
@ -32,12 +40,23 @@ namespace TelegramBotBase
} }
} }
/// <summary>
/// Get device session from Device/ChatId
/// </summary>
/// <param name="deviceId"></param>
/// <returns></returns>
public DeviceSession GetSession(long deviceId) public DeviceSession GetSession(long deviceId)
{ {
DeviceSession ds = this.SessionList.FirstOrDefault(a => a.Key == deviceId).Value ?? null; DeviceSession ds = this.SessionList.FirstOrDefault(a => a.Key == deviceId).Value ?? null;
return ds; return ds;
} }
/// <summary>
/// Start a new session
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="deviceId"></param>
/// <returns></returns>
public async Task<DeviceSession> StartSession<T>(long deviceId) public async Task<DeviceSession> StartSession<T>(long deviceId)
where T : FormBase where T : FormBase
{ {
@ -56,7 +75,10 @@ namespace TelegramBotBase
return ds; return ds;
} }
/// <summary>
/// End session
/// </summary>
/// <param name="deviceId"></param>
public void EndSession(long deviceId) public void EndSession(long deviceId)
{ {
var d = this[deviceId]; var d = this[deviceId];

View File

@ -17,8 +17,14 @@ using TelegramBotBase.Form;
namespace TelegramBotBase.Sessions namespace TelegramBotBase.Sessions
{ {
/// <summary>
/// Base class for a device/chat session
/// </summary>
public class DeviceSession public class DeviceSession
{ {
/// <summary>
/// Device or chat id
/// </summary>
public long DeviceId { get; set; } public long DeviceId { get; set; }
public DateTime LastAction { get; set; } public DateTime LastAction { get; set; }
@ -57,7 +63,7 @@ namespace TelegramBotBase.Sessions
} }
/// <summary> /// <summary>
/// Bearbeitet die bestehende Text-Nachricht. /// Edits the text message
/// </summary> /// </summary>
/// <param name="messageId"></param> /// <param name="messageId"></param>
/// <param name="text"></param> /// <param name="text"></param>
@ -89,9 +95,10 @@ namespace TelegramBotBase.Sessions
} }
/// <summary> /// <summary>
/// Sendet eine einfache Text-Nachricht. /// Sends a simple text message
/// </summary> /// </summary>
/// <param name="text"></param> /// <param name="text"></param>
/// <param name="buttons"></param>
/// <param name="replyTo"></param> /// <param name="replyTo"></param>
/// <param name="disableNotification"></param> /// <param name="disableNotification"></param>
/// <returns></returns> /// <returns></returns>
@ -128,9 +135,10 @@ namespace TelegramBotBase.Sessions
} }
/// <summary> /// <summary>
/// Sendet eine einfache Text-Nachricht. /// Sends a simple text message
/// </summary> /// </summary>
/// <param name="text"></param> /// <param name="text"></param>
/// <param name="markup"></param>
/// <param name="replyTo"></param> /// <param name="replyTo"></param>
/// <param name="disableNotification"></param> /// <param name="disableNotification"></param>
/// <returns></returns> /// <returns></returns>
@ -160,9 +168,10 @@ namespace TelegramBotBase.Sessions
} }
/// <summary> /// <summary>
/// Sendet ein Bild /// Sends an image
/// </summary> /// </summary>
/// <param name="file"></param> /// <param name="file"></param>
/// <param name="buttons"></param>
/// <param name="replyTo"></param> /// <param name="replyTo"></param>
/// <param name="disableNotification"></param> /// <param name="disableNotification"></param>
/// <returns></returns> /// <returns></returns>
@ -198,43 +207,49 @@ namespace TelegramBotBase.Sessions
} }
/// <summary> /// <summary>
/// Sendet ein Bild /// Sends an image
/// </summary> /// </summary>
/// <param name="image"></param> /// <param name="image"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <param name="buttons"></param>
/// <param name="replyTo"></param> /// <param name="replyTo"></param>
/// <param name="disableNotification"></param> /// <param name="disableNotification"></param>
/// <returns></returns> /// <returns></returns>
public async Task SendPhoto(Image image, String name, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false) public async Task<Message> SendPhoto(Image image, String name, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false)
{ {
using (var fileStream = Tools.Images.ToStream(image, ImageFormat.Png)) using (var fileStream = Tools.Images.ToStream(image, ImageFormat.Png))
{ {
InputOnlineFile fts = new InputOnlineFile(fileStream, name); InputOnlineFile fts = new InputOnlineFile(fileStream, name);
await SendPhoto(fts, buttons, replyTo, disableNotification); var m = await SendPhoto(fts, buttons, replyTo, disableNotification);
return m;
} }
} }
/// <summary> /// <summary>
/// Sendet ein Bild /// Sends an image
/// </summary> /// </summary>
/// <param name="image"></param> /// <param name="image"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <param name="buttons"></param>
/// <param name="replyTo"></param> /// <param name="replyTo"></param>
/// <param name="disableNotification"></param> /// <param name="disableNotification"></param>
/// <returns></returns> /// <returns></returns>
public async Task SendPhoto(Bitmap image, String name, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false) public async Task<Message> SendPhoto(Bitmap image, String name, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false)
{ {
using (var fileStream = Tools.Images.ToStream(image, ImageFormat.Png)) using (var fileStream = Tools.Images.ToStream(image, ImageFormat.Png))
{ {
InputOnlineFile fts = new InputOnlineFile(fileStream, name); InputOnlineFile fts = new InputOnlineFile(fileStream, name);
await SendPhoto(fts, buttons, replyTo, disableNotification); var m = await SendPhoto(fts, buttons, replyTo, disableNotification);
return m;
} }
} }
/// <summary> /// <summary>
/// Sendet ein Dokument /// Sends an document
/// </summary> /// </summary>
/// <param name="filename"></param> /// <param name="filename"></param>
/// <param name="document"></param> /// <param name="document"></param>
@ -243,17 +258,19 @@ namespace TelegramBotBase.Sessions
/// <param name="replyTo"></param> /// <param name="replyTo"></param>
/// <param name="disableNotification"></param> /// <param name="disableNotification"></param>
/// <returns></returns> /// <returns></returns>
public async Task SendDocument(String filename, byte[] document, String caption = "", ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false) public async Task<Message> SendDocument(String filename, byte[] document, String caption = "", ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false)
{ {
MemoryStream ms = new MemoryStream(document); MemoryStream ms = new MemoryStream(document);
InputOnlineFile fts = new InputOnlineFile(ms, filename); InputOnlineFile fts = new InputOnlineFile(ms, filename);
await SendDocument(fts, caption, buttons, replyTo, disableNotification); var m = await SendDocument(fts, caption, buttons, replyTo, disableNotification);
return m;
} }
/// <summary> /// <summary>
/// Sendet ein Dokument /// Sends an document
/// </summary> /// </summary>
/// <param name="document"></param> /// <param name="document"></param>
/// <param name="caption"></param> /// <param name="caption"></param>
@ -261,7 +278,7 @@ namespace TelegramBotBase.Sessions
/// <param name="replyTo"></param> /// <param name="replyTo"></param>
/// <param name="disableNotification"></param> /// <param name="disableNotification"></param>
/// <returns></returns> /// <returns></returns>
public async Task SendDocument(InputOnlineFile document, String caption = "", ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false) public async Task<Message> SendDocument(InputOnlineFile document, String caption = "", ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false)
{ {
InlineKeyboardMarkup markup = null; InlineKeyboardMarkup markup = null;
if (buttons != null) if (buttons != null)
@ -269,13 +286,15 @@ namespace TelegramBotBase.Sessions
markup = buttons; 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;
} }
/// <summary> /// <summary>
/// Legt eine Chat Aktion Fest (Wird angezeigt) /// Set a chat action (showed to the user)
/// </summary> /// </summary>
/// <param name="action"></param> /// <param name="action"></param>
/// <returns></returns> /// <returns></returns>
@ -285,7 +304,7 @@ namespace TelegramBotBase.Sessions
} }
/// <summary> /// <summary>
/// Löscht die aktuelle Nachricht, oder die übergebene /// Deletes a message
/// </summary> /// </summary>
/// <param name="messageId"></param> /// <param name="messageId"></param>
/// <returns></returns> /// <returns></returns>
@ -306,16 +325,18 @@ namespace TelegramBotBase.Sessions
} }
/// <summary> /// <summary>
/// Löscht die aktuelle Nachricht, oder die übergebene /// Deletes the given message
/// </summary> /// </summary>
/// <param name="messageId"></param> /// <param name="message"></param>
/// <returns></returns> /// <returns></returns>
public virtual async Task<bool> DeleteMessage(Message message) public virtual async Task<bool> DeleteMessage(Message message)
{ {
return await DeleteMessage(message.MessageId); return await DeleteMessage(message.MessageId);
} }
/// <summary>
/// Eventhandler for sent messages
/// </summary>
public event EventHandler<MessageSentEventArgs> MessageSent public event EventHandler<MessageSentEventArgs> MessageSent
{ {
add add

View File

@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TelegramBotBase</RootNamespace> <RootNamespace>TelegramBotBase</RootNamespace>
<AssemblyName>TelegramBotBase</AssemblyName> <AssemblyName>TelegramBotBase</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -28,35 +29,26 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\TelegramBotBase.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <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" />
<Reference Include="System.ComponentModel.Composition" /> <Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" /> <Reference Include="System.IO.Compression" />
<Reference Include="System.Numerics" /> <Reference Include="System.Numerics" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Telegram.Bot, Version=14.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\UGI\packages\Telegram.Bot.14.6.0\lib\net45\Telegram.Bot.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Base\ActionResult.cs" />
<Compile Include="Base\ButtonClickedEventArgs.cs" /> <Compile Include="Base\ButtonClickedEventArgs.cs" />
<Compile Include="Base\ControlBase.cs" /> <Compile Include="Base\ControlBase.cs" />
<Compile Include="Base\MessageClient.cs" /> <Compile Include="Base\MessageClient.cs" />
@ -75,7 +67,7 @@
<Compile Include="Form\AutoCleanForm.cs" /> <Compile Include="Form\AutoCleanForm.cs" />
<Compile Include="Form\ButtonBase.cs" /> <Compile Include="Form\ButtonBase.cs" />
<Compile Include="Form\ButtonForm.cs" /> <Compile Include="Form\ButtonForm.cs" />
<Compile Include="Form\FormBase.cs" /> <Compile Include="Base\FormBase.cs" />
<Compile Include="Form\CallbackData.cs" /> <Compile Include="Form\CallbackData.cs" />
<Compile Include="Form\PromptDialog.cs" /> <Compile Include="Form\PromptDialog.cs" />
<Compile Include="SessionBase.cs" /> <Compile Include="SessionBase.cs" />
@ -84,7 +76,15 @@
<Compile Include="Tools\Images.cs" /> <Compile Include="Tools\Images.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <PackageReference Include="Newtonsoft.Json">
<Version>11.0.2</Version>
</PackageReference>
<PackageReference Include="System.Net.Requests">
<Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="Telegram.Bot">
<Version>14.10.0</Version>
</PackageReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -0,0 +1,21 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<license type="expression">MIT</license>
<projectUrl>https://github.com/MajMcCloud/TelegramBotFramework</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>First release on nuget for easier use.</releaseNotes>
<copyright>Copyright 2019</copyright>
<tags>Telegram Bot Framework C# Addon Context Modules</tags>
<dependencies>
<dependency id="Telegram.Bot" version="14.3.0" />
<dependency id="Newtonsoft.Json" version="11.0.2" />
</dependencies>
</metadata>
</package>

View File

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<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="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" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net452" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net452" />
<package id="System.Globalization" version="4.3.0" targetFramework="net452" />
<package id="System.IO" version="4.3.0" targetFramework="net452" />
<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.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" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net452" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net452" />
<package id="System.Runtime" version="4.3.0" targetFramework="net452" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net452" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net452" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net452" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net452" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net452" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net452" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net452" />
<package id="System.Threading" version="4.3.0" targetFramework="net452" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net452" />
<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="14.6.0" targetFramework="net452" />
</packages>