added more exception handling
This commit is contained in:
parent
7142c8e59f
commit
43fe6533d2
@ -85,6 +85,10 @@ namespace TelegramBotBase
|
||||
try
|
||||
{
|
||||
Client_TryMessage(sender, e);
|
||||
}
|
||||
catch (Telegram.Bot.Exceptions.ApiRequestException ex)
|
||||
{
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@ -95,9 +95,23 @@ namespace TelegramBotBase.Sessions
|
||||
markup = buttons;
|
||||
}
|
||||
|
||||
var message = await (this.Client.TelegramClient.SendTextMessageAsync(this.DeviceId, text, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification));
|
||||
Message m = null;
|
||||
|
||||
OnMessageSent(new MessageSentEventArgs(message.MessageId, message));
|
||||
try
|
||||
{
|
||||
m = await (this.Client.TelegramClient.SendTextMessageAsync(this.DeviceId, text, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification));
|
||||
}
|
||||
catch (Telegram.Bot.Exceptions.ApiRequestException ex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
OnMessageSent(new MessageSentEventArgs(m.MessageId, m));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -112,9 +126,22 @@ namespace TelegramBotBase.Sessions
|
||||
if (this.ActiveForm == null)
|
||||
return;
|
||||
|
||||
var message = await (this.Client.TelegramClient.SendTextMessageAsync(this.DeviceId, text, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification));
|
||||
Message m = null;
|
||||
|
||||
OnMessageSent(new MessageSentEventArgs(message.MessageId, message));
|
||||
try
|
||||
{
|
||||
m = await (this.Client.TelegramClient.SendTextMessageAsync(this.DeviceId, text, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification));
|
||||
}
|
||||
catch (Telegram.Bot.Exceptions.ApiRequestException ex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
OnMessageSent(new MessageSentEventArgs(m.MessageId, m));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -135,9 +162,22 @@ namespace TelegramBotBase.Sessions
|
||||
markup = buttons;
|
||||
}
|
||||
|
||||
var message = await this.Client.TelegramClient.SendPhotoAsync(this.DeviceId, file, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification);
|
||||
Message m = null;
|
||||
|
||||
OnMessageSent(new MessageSentEventArgs(message.MessageId, message));
|
||||
try
|
||||
{
|
||||
m = await this.Client.TelegramClient.SendPhotoAsync(this.DeviceId, file, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification);
|
||||
}
|
||||
catch (Telegram.Bot.Exceptions.ApiRequestException ex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
OnMessageSent(new MessageSentEventArgs(m.MessageId, m));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -50,8 +50,8 @@
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Telegram.Bot, Version=14.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Telegram.Bot.14.4.0\lib\net45\Telegram.Bot.dll</HintPath>
|
||||
<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>
|
||||
|
||||
@ -34,5 +34,5 @@
|
||||
<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.4.0" targetFramework="net452" />
|
||||
<package id="Telegram.Bot" version="14.6.0" targetFramework="net452" />
|
||||
</packages>
|
||||
Loading…
x
Reference in New Issue
Block a user