- Added comments
- added Edit method
This commit is contained in:
parent
94fe263676
commit
ea971979e2
@ -21,15 +21,33 @@ namespace TelegramBotBase.Form
|
|||||||
|
|
||||||
public enum eDeleteMode
|
public enum eDeleteMode
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Don't delete any message.
|
||||||
|
/// </summary>
|
||||||
None = 0,
|
None = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Delete messages on every callback/action.
|
||||||
|
/// </summary>
|
||||||
OnEveryCall = 1,
|
OnEveryCall = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Delete on leaving this form.
|
||||||
|
/// </summary>
|
||||||
OnLeavingForm = 2
|
OnLeavingForm = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum eSide
|
public enum eSide
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Delete only messages from this bot.
|
||||||
|
/// </summary>
|
||||||
BotOnly = 0,
|
BotOnly = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Delete only user messages.
|
||||||
|
/// </summary>
|
||||||
UserOnly = 1,
|
UserOnly = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Delete all messages in this context.
|
||||||
|
/// </summary>
|
||||||
Both = 2
|
Both = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -83,7 +83,7 @@ namespace TelegramBotBase.Sessions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EventHandlerList __Events = new EventHandlerList();
|
private EventHandlerList __Events = new EventHandlerList();
|
||||||
|
|
||||||
private static object __evMessageSent = new object();
|
private static object __evMessageSent = new object();
|
||||||
private static object __evMessageReceived = new object();
|
private static object __evMessageReceived = new object();
|
||||||
@ -138,6 +138,39 @@ namespace TelegramBotBase.Sessions
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Edits the text message
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="messageId"></param>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
/// <param name="buttons"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<Message> Edit(Message message, ButtonForm buttons = null)
|
||||||
|
{
|
||||||
|
if (this.ActiveForm == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
InlineKeyboardMarkup markup = null;
|
||||||
|
if (buttons != null)
|
||||||
|
{
|
||||||
|
markup = buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var m = await this.Client.TelegramClient.EditMessageTextAsync(this.DeviceId, message.MessageId, message.Text, replyMarkup: markup);
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a simple text message
|
/// Sends a simple text message
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -163,7 +196,7 @@ namespace TelegramBotBase.Sessions
|
|||||||
{
|
{
|
||||||
m = await (this.Client.TelegramClient.SendTextMessageAsync(this.DeviceId, text, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification));
|
m = await (this.Client.TelegramClient.SendTextMessageAsync(this.DeviceId, text, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification));
|
||||||
|
|
||||||
OnMessageSent(new MessageSentEventArgs( m));
|
OnMessageSent(new MessageSentEventArgs(m));
|
||||||
}
|
}
|
||||||
catch (ApiRequestException ex)
|
catch (ApiRequestException ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user