- Adding a message loop interface to build custom message loops - extracting default message loop from BotBase into seperate class - updates to BotBaseBuilder for integration of custom message loops - updating all result classes for using the new Update object of V17 - improving MessageResult and UpdateResult classes - BotBase has been prepared for cleanup (a lot of comments) - Comment cleanup at the next build - updating Readme
55 lines
1.3 KiB
C#
55 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Telegram.Bot;
|
|
|
|
namespace TelegramBotBase.Base
|
|
{
|
|
public class ResultBase : EventArgs
|
|
{
|
|
public MessageClient Client { get; set; }
|
|
|
|
public virtual long DeviceId { get; set; }
|
|
|
|
public int MessageId
|
|
{
|
|
get
|
|
{
|
|
return this.Message.MessageId;
|
|
}
|
|
}
|
|
|
|
public virtual Telegram.Bot.Types.Message Message { get; set; }
|
|
|
|
/// <summary>
|
|
/// Deletes the current message
|
|
/// </summary>
|
|
/// <param name="messageId"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task DeleteMessage()
|
|
{
|
|
await DeleteMessage(this.MessageId);
|
|
}
|
|
|
|
/// <summary>
|
|
///Deletes the current message or the given one.
|
|
/// </summary>
|
|
/// <param name="messageId"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task DeleteMessage(int messageId = -1)
|
|
{
|
|
try
|
|
{
|
|
await this.Client.TelegramClient.DeleteMessageAsync(this.DeviceId, (messageId == -1 ? this.MessageId : messageId));
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|