Update DeviceSession.cs
- adding EditReplyMarkup to Device methods - adding GetChatTitle method to get easier the name of a chat/group/channel - some cleanup
This commit is contained in:
parent
d24f8e7ac5
commit
ef667d12d8
@ -35,6 +35,18 @@ namespace TelegramBotBase.Sessions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public String ChatTitle { get; set; }
|
public String ChatTitle { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the ChatTitle depending on groups/channels or users
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public String GetChatTitle()
|
||||||
|
{
|
||||||
|
return LastMessage?.Chat.Title
|
||||||
|
?? LastMessage?.Chat.Username
|
||||||
|
?? LastMessage?.Chat.FirstName
|
||||||
|
?? ChatTitle;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When did any last action happend (message received or button clicked)
|
/// When did any last action happend (message received or button clicked)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -132,9 +144,6 @@ namespace TelegramBotBase.Sessions
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<Message> Edit(int messageId, String text, ButtonForm buttons = null)
|
public async Task<Message> Edit(int messageId, String text, ButtonForm buttons = null)
|
||||||
{
|
{
|
||||||
if (this.ActiveForm == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
InlineKeyboardMarkup markup = buttons;
|
InlineKeyboardMarkup markup = buttons;
|
||||||
|
|
||||||
if (text.Length > Constants.Telegram.MaxMessageLength)
|
if (text.Length > Constants.Telegram.MaxMessageLength)
|
||||||
@ -164,9 +173,6 @@ namespace TelegramBotBase.Sessions
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<Message> Edit(int messageId, String text, InlineKeyboardMarkup markup)
|
public async Task<Message> Edit(int messageId, String text, InlineKeyboardMarkup markup)
|
||||||
{
|
{
|
||||||
if (this.ActiveForm == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (text.Length > Constants.Telegram.MaxMessageLength)
|
if (text.Length > Constants.Telegram.MaxMessageLength)
|
||||||
{
|
{
|
||||||
throw new MaxLengthException(text.Length);
|
throw new MaxLengthException(text.Length);
|
||||||
@ -194,9 +200,6 @@ namespace TelegramBotBase.Sessions
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<Message> Edit(Message message, ButtonForm buttons = null)
|
public async Task<Message> Edit(Message message, ButtonForm buttons = null)
|
||||||
{
|
{
|
||||||
if (this.ActiveForm == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
InlineKeyboardMarkup markup = buttons;
|
InlineKeyboardMarkup markup = buttons;
|
||||||
|
|
||||||
if (message.Text.Length > Constants.Telegram.MaxMessageLength)
|
if (message.Text.Length > Constants.Telegram.MaxMessageLength)
|
||||||
@ -217,6 +220,27 @@ namespace TelegramBotBase.Sessions
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Edits the reply keyboard markup (buttons)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="messageId"></param>
|
||||||
|
/// <param name="bf"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<Message> EditReplyMarkup(int messageId, ButtonForm bf)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return await this.Client.TelegramClient.EditMessageReplyMarkupAsync(this.DeviceId, messageId, bf);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a simple text message
|
/// Sends a simple text message
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user