- 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:
parent
7439b009be
commit
aa53dc9386
@ -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;
|
||||
// }
|
||||
|
||||
//}
|
||||
}
|
||||
@ -7,6 +7,9 @@ using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBotBase.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// Button get clicked event
|
||||
/// </summary>
|
||||
public class ButtonClickedEventArgs : EventArgs
|
||||
{
|
||||
public ButtonBase Button { get; set; }
|
||||
|
||||
@ -6,6 +6,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for controls
|
||||
/// </summary>
|
||||
public class ControlBase
|
||||
{
|
||||
public Sessions.DeviceSession Device { get; set; }
|
||||
|
||||
@ -8,6 +8,9 @@ using TelegramBotBase.Sessions;
|
||||
|
||||
namespace TelegramBotBase.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for forms
|
||||
/// </summary>
|
||||
public class FormBase : IDisposable
|
||||
{
|
||||
public DeviceSession Device { get; set; }
|
||||
@ -17,7 +20,7 @@ namespace TelegramBotBase.Form
|
||||
public bool CustomEventManagement { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gibt an, dass das Formular gewechselt wurde, es werden keine weiteren Events ausgeführt
|
||||
/// contains if the form has been switched (navigated)
|
||||
/// </summary>
|
||||
public bool FormSwitched { get; set; } = false;
|
||||
|
||||
@ -34,7 +37,7 @@ namespace TelegramBotBase.Form
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wird nur aufgerufen, beim erstmaligen Laden des Formulares.
|
||||
/// Will get called at the initialization (once per context)
|
||||
/// </summary>
|
||||
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>
|
||||
/// Navigiert zur neuen Form.
|
||||
/// Navigates to a new form
|
||||
/// </summary>
|
||||
/// <param name="newForm"></param>
|
||||
/// <returns></returns>
|
||||
@ -121,6 +102,9 @@ namespace TelegramBotBase.Form
|
||||
await newForm.Opened();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleanup
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
this.Client = null;
|
||||
@ -7,6 +7,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for message handling
|
||||
/// </summary>
|
||||
public class MessageClient
|
||||
{
|
||||
|
||||
|
||||
@ -12,6 +12,9 @@ namespace TelegramBotBase.Base
|
||||
|
||||
public Telegram.Bot.Args.CallbackQueryEventArgs RawCallbackData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Device/ChatId
|
||||
/// </summary>
|
||||
public override long DeviceId
|
||||
{
|
||||
get
|
||||
@ -21,7 +24,7 @@ namespace TelegramBotBase.Base
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Die Id der Nachricht
|
||||
/// The message id
|
||||
/// </summary>
|
||||
public new int MessageId
|
||||
{
|
||||
@ -48,7 +51,7 @@ namespace TelegramBotBase.Base
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ist diese eine Aktion? (z.B.: Button Klick)
|
||||
/// Is this an action ? (i.e. button click)
|
||||
/// </summary>
|
||||
public bool IsAction
|
||||
{
|
||||
@ -87,7 +90,7 @@ namespace TelegramBotBase.Base
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bestätigt den Erhalt der Aktion.
|
||||
/// Confirm incomming action (i.e. Button click)
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
@ -23,7 +23,7 @@ namespace TelegramBotBase.Base
|
||||
public Telegram.Bot.Types.Message Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Löscht die aktuelle Nachricht, oder die übergebene
|
||||
/// Deletes the current message
|
||||
/// </summary>
|
||||
/// <param name="messageId"></param>
|
||||
/// <returns></returns>
|
||||
@ -33,7 +33,7 @@ namespace TelegramBotBase.Base
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Löscht die aktuelle Nachricht, oder die übergebene
|
||||
///Deletes the current message or the given one.
|
||||
/// </summary>
|
||||
/// <param name="messageId"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
@ -7,6 +7,9 @@ using TelegramBotBase.Sessions;
|
||||
|
||||
namespace TelegramBotBase.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for given system call results
|
||||
/// </summary>
|
||||
public class SystemCallEventArgs : EventArgs
|
||||
{
|
||||
public String Command { get; set; }
|
||||
|
||||
@ -10,14 +10,23 @@ using TelegramBotBase.Sessions;
|
||||
|
||||
namespace TelegramBotBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Bot base class for full Device/Context and Messagehandling
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class BotBase<T>
|
||||
where T : FormBase
|
||||
{
|
||||
public MessageClient Client { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Your TelegramBot APIKey
|
||||
/// </summary>
|
||||
public String APIKey { get; set; } = "";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// List of all running/active sessions
|
||||
/// </summary>
|
||||
public SessionBase Sessions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -39,7 +48,7 @@ namespace TelegramBotBase
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// SKips all messages during running (good for big delay updates)
|
||||
/// Skips all messages during running (good for big delay updates)
|
||||
/// </summary>
|
||||
public bool SkipAllMessages { get; set; } = false;
|
||||
|
||||
@ -48,7 +57,10 @@ namespace TelegramBotBase
|
||||
/// </summary>
|
||||
public bool LogAllMessages { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Simple start of your Bot with the APIKey
|
||||
/// </summary>
|
||||
/// <param name="apiKey"></param>
|
||||
public BotBase(String apiKey)
|
||||
{
|
||||
this.APIKey = apiKey;
|
||||
@ -61,6 +73,9 @@ namespace TelegramBotBase
|
||||
this.Sessions.Client = this.Client;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start your Bot
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
if (this.Client == null)
|
||||
@ -73,7 +88,9 @@ namespace TelegramBotBase
|
||||
this.Client.TelegramClient.StartReceiving();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Stop your Bot
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
if (this.Client == null)
|
||||
@ -82,7 +99,11 @@ namespace TelegramBotBase
|
||||
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)
|
||||
{
|
||||
if (this.Client == null)
|
||||
@ -258,7 +279,7 @@ namespace TelegramBotBase
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wird aufgerufen wenn eine Session begonnen wird
|
||||
/// Will be called if a session/context gets started
|
||||
/// </summary>
|
||||
|
||||
public event EventHandler<SessionBeginResult> SessionBegins
|
||||
@ -279,6 +300,9 @@ namespace TelegramBotBase
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will be called on incomming message
|
||||
/// </summary>
|
||||
public event EventHandler<MessageIncomeResult> Message
|
||||
{
|
||||
add
|
||||
@ -297,6 +321,9 @@ namespace TelegramBotBase
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will be called if a system call gets raised
|
||||
/// </summary>
|
||||
public event EventHandler<SystemCallEventArgs> SystemCall
|
||||
{
|
||||
add
|
||||
@ -315,6 +342,9 @@ namespace TelegramBotBase
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will be called on an inner exception
|
||||
/// </summary>
|
||||
public event EventHandler<SystemExceptionEventArgs> Exception
|
||||
{
|
||||
add
|
||||
@ -333,6 +363,9 @@ namespace TelegramBotBase
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will be called if no form handeled this call
|
||||
/// </summary>
|
||||
public event EventHandler<UnhandledCallEventArgs> UnhandledCall
|
||||
{
|
||||
add
|
||||
|
||||
@ -6,6 +6,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple control for show and managing progress.
|
||||
/// </summary>
|
||||
public class ProgressBar : Base.ControlBase
|
||||
{
|
||||
public enum eProgressStyle
|
||||
|
||||
@ -8,6 +8,9 @@ using TelegramBotBase.Base;
|
||||
|
||||
namespace TelegramBotBase.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple prompt dialog with one ok Button
|
||||
/// </summary>
|
||||
public class AlertDialog : PromptDialog
|
||||
{
|
||||
public String ButtonText { get; set; }
|
||||
|
||||
@ -8,6 +8,9 @@ using TelegramBotBase.Base;
|
||||
|
||||
namespace TelegramBotBase.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// A prompt with a lot of buttons
|
||||
/// </summary>
|
||||
public class ArrayPromptDialog : FormBase
|
||||
{
|
||||
public String Message { get; set; }
|
||||
|
||||
@ -8,6 +8,9 @@ using TelegramBotBase.Base;
|
||||
|
||||
namespace TelegramBotBase.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// A form which cleans up old messages sent within
|
||||
/// </summary>
|
||||
public class AutoCleanForm : FormBase
|
||||
{
|
||||
List<Message> 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()
|
||||
|
||||
@ -6,6 +6,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for button handling
|
||||
/// </summary>
|
||||
public class ButtonBase
|
||||
{
|
||||
public String Text { get; set; }
|
||||
|
||||
@ -7,6 +7,9 @@ using Telegram.Bot.Types.ReplyMarkups;
|
||||
|
||||
namespace TelegramBotBase.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for an buttons array
|
||||
/// </summary>
|
||||
public class ButtonForm
|
||||
{
|
||||
List<List<ButtonBase>> Buttons = new List<List<ButtonBase>>();
|
||||
@ -47,7 +50,7 @@ namespace TelegramBotBase.Form
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fügt die Buttons automatisch aufgesplittet in Spalten ein.
|
||||
/// Add buttons splitted in the amount of columns (i.e. 2 per row...)
|
||||
/// </summary>
|
||||
/// <param name="buttons"></param>
|
||||
/// <param name="buttonsPerRow"></param>
|
||||
|
||||
@ -6,6 +6,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for serializing buttons and data
|
||||
/// </summary>
|
||||
public class CallbackData
|
||||
{
|
||||
public String Method { get; set; }
|
||||
|
||||
@ -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")]
|
||||
|
||||
@ -8,6 +8,9 @@ using TelegramBotBase.Form;
|
||||
using TelegramBotBase.Sessions;
|
||||
namespace TelegramBotBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for managing all active sessions
|
||||
/// </summary>
|
||||
public class SessionBase
|
||||
{
|
||||
public MessageClient Client { get; set; }
|
||||
@ -20,6 +23,11 @@ namespace TelegramBotBase
|
||||
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]
|
||||
{
|
||||
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)
|
||||
{
|
||||
DeviceSession ds = this.SessionList.FirstOrDefault(a => a.Key == deviceId).Value ?? null;
|
||||
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)
|
||||
where T : FormBase
|
||||
{
|
||||
@ -56,7 +75,10 @@ namespace TelegramBotBase
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// End session
|
||||
/// </summary>
|
||||
/// <param name="deviceId"></param>
|
||||
public void EndSession(long deviceId)
|
||||
{
|
||||
var d = this[deviceId];
|
||||
|
||||
@ -17,8 +17,14 @@ using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBotBase.Sessions
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for a device/chat session
|
||||
/// </summary>
|
||||
public class DeviceSession
|
||||
{
|
||||
/// <summary>
|
||||
/// Device or chat id
|
||||
/// </summary>
|
||||
public long DeviceId { get; set; }
|
||||
|
||||
public DateTime LastAction { get; set; }
|
||||
@ -57,7 +63,7 @@ namespace TelegramBotBase.Sessions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bearbeitet die bestehende Text-Nachricht.
|
||||
/// Edits the text message
|
||||
/// </summary>
|
||||
/// <param name="messageId"></param>
|
||||
/// <param name="text"></param>
|
||||
@ -89,9 +95,10 @@ namespace TelegramBotBase.Sessions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sendet eine einfache Text-Nachricht.
|
||||
/// Sends a simple text message
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="buttons"></param>
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <returns></returns>
|
||||
@ -128,9 +135,10 @@ namespace TelegramBotBase.Sessions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sendet eine einfache Text-Nachricht.
|
||||
/// Sends a simple text message
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="markup"></param>
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <returns></returns>
|
||||
@ -160,9 +168,10 @@ namespace TelegramBotBase.Sessions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sendet ein Bild
|
||||
/// Sends an image
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <param name="buttons"></param>
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <returns></returns>
|
||||
@ -198,43 +207,49 @@ namespace TelegramBotBase.Sessions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sendet ein Bild
|
||||
/// Sends an image
|
||||
/// </summary>
|
||||
/// <param name="image"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="buttons"></param>
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <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))
|
||||
{
|
||||
InputOnlineFile fts = new InputOnlineFile(fileStream, name);
|
||||
|
||||
await SendPhoto(fts, buttons, replyTo, disableNotification);
|
||||
var m = await SendPhoto(fts, buttons, replyTo, disableNotification);
|
||||
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sendet ein Bild
|
||||
/// Sends an image
|
||||
/// </summary>
|
||||
/// <param name="image"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="buttons"></param>
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <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))
|
||||
{
|
||||
InputOnlineFile fts = new InputOnlineFile(fileStream, name);
|
||||
|
||||
await SendPhoto(fts, buttons, replyTo, disableNotification);
|
||||
var m = await SendPhoto(fts, buttons, replyTo, disableNotification);
|
||||
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sendet ein Dokument
|
||||
/// Sends an document
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <param name="document"></param>
|
||||
@ -243,17 +258,19 @@ namespace TelegramBotBase.Sessions
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <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);
|
||||
|
||||
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>
|
||||
/// Sendet ein Dokument
|
||||
/// Sends an document
|
||||
/// </summary>
|
||||
/// <param name="document"></param>
|
||||
/// <param name="caption"></param>
|
||||
@ -261,7 +278,7 @@ namespace TelegramBotBase.Sessions
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <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;
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Legt eine Chat Aktion Fest (Wird angezeigt)
|
||||
/// Set a chat action (showed to the user)
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
@ -285,7 +304,7 @@ namespace TelegramBotBase.Sessions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Löscht die aktuelle Nachricht, oder die übergebene
|
||||
/// Deletes a message
|
||||
/// </summary>
|
||||
/// <param name="messageId"></param>
|
||||
/// <returns></returns>
|
||||
@ -306,16 +325,18 @@ namespace TelegramBotBase.Sessions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Löscht die aktuelle Nachricht, oder die übergebene
|
||||
/// Deletes the given message
|
||||
/// </summary>
|
||||
/// <param name="messageId"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<bool> DeleteMessage(Message message)
|
||||
{
|
||||
return await DeleteMessage(message.MessageId);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Eventhandler for sent messages
|
||||
/// </summary>
|
||||
public event EventHandler<MessageSentEventArgs> MessageSent
|
||||
{
|
||||
add
|
||||
|
||||
@ -9,8 +9,9 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TelegramBotBase</RootNamespace>
|
||||
<AssemblyName>TelegramBotBase</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@ -28,35 +29,26 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Release\TelegramBotBase.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<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.ComponentModel.Composition" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<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.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<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>
|
||||
<Compile Include="Base\ActionResult.cs" />
|
||||
<Compile Include="Base\ButtonClickedEventArgs.cs" />
|
||||
<Compile Include="Base\ControlBase.cs" />
|
||||
<Compile Include="Base\MessageClient.cs" />
|
||||
@ -75,7 +67,7 @@
|
||||
<Compile Include="Form\AutoCleanForm.cs" />
|
||||
<Compile Include="Form\ButtonBase.cs" />
|
||||
<Compile Include="Form\ButtonForm.cs" />
|
||||
<Compile Include="Form\FormBase.cs" />
|
||||
<Compile Include="Base\FormBase.cs" />
|
||||
<Compile Include="Form\CallbackData.cs" />
|
||||
<Compile Include="Form\PromptDialog.cs" />
|
||||
<Compile Include="SessionBase.cs" />
|
||||
@ -84,7 +76,15 @@
|
||||
<Compile Include="Tools\Images.cs" />
|
||||
</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>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
21
TelegramBotBase/TelegramBotBase.nuspec
Normal file
21
TelegramBotBase/TelegramBotBase.nuspec
Normal 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>
|
||||
@ -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>
|
||||
Loading…
x
Reference in New Issue
Block a user