mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Debug logs in fetcher/sender, fixed error in HS
This commit is contained in:
+3
-1
@@ -160,7 +160,9 @@ namespace Kruzya.TelegramBot.Core
|
|||||||
|
|
||||||
private void HookAppDomain()
|
private void HookAppDomain()
|
||||||
{
|
{
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += delegate(object? sender, ResolveEventArgs args)
|
var appDomain = AppDomain.CurrentDomain;
|
||||||
|
|
||||||
|
appDomain.AssemblyResolve += delegate(object? sender, ResolveEventArgs args)
|
||||||
{
|
{
|
||||||
var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||||
string assemblyPath = Path.Combine(basePath, new AssemblyName(args.Name).Name + ".dll");
|
string assemblyPath = Path.Combine(basePath, new AssemblyName(args.Name).Name + ".dll");
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ using System.Text;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BotFramework;
|
using BotFramework;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Telegram.Bot.Exceptions;
|
using Telegram.Bot.Exceptions;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
|
|
||||||
namespace Kruzya.TelegramBot.Core.Service
|
namespace Kruzya.TelegramBot.Core.Service
|
||||||
{
|
{
|
||||||
public abstract class AbstractTimedHostedService
|
public abstract class AbstractTimedHostedService : IHostedService, IDisposable
|
||||||
{
|
{
|
||||||
private Timer _timer;
|
private Timer _timer;
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ namespace Kruzya.TelegramBot.RichSiteSummary
|
|||||||
services.AddQueue<UserMessage>()
|
services.AddQueue<UserMessage>()
|
||||||
.AddQueue<UserUnsubscribe>();
|
.AddQueue<UserUnsubscribe>();
|
||||||
|
|
||||||
services.AddHostedService<RssFetch>();
|
services.AddHostedService<RssFetch>()
|
||||||
|
.AddHostedService<Unsubscriber>()
|
||||||
|
.AddHostedService<MessageSender>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Service
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.LogDebug($"Message for {message.ChatId.Identifier} dequeued.");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _bot.BotClient.SendTextMessageAsync(message.ChatId, message.Text, message.ParseMode,
|
await _bot.BotClient.SendTextMessageAsync(message.ChatId, message.Text, message.ParseMode,
|
||||||
@@ -43,6 +44,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Service
|
|||||||
}
|
}
|
||||||
catch (ApiRequestException e)
|
catch (ApiRequestException e)
|
||||||
{
|
{
|
||||||
|
_logger.LogDebug($"Message for {message.ChatId.Identifier} is failed: {e.Message}.");
|
||||||
if (!e.Message.Contains("bot was blocked by user"))
|
if (!e.Message.Contains("bot was blocked by user"))
|
||||||
{
|
{
|
||||||
ReEnqueue(message, e, message.ChatId); // looks like a network issue
|
ReEnqueue(message, e, message.ChatId); // looks like a network issue
|
||||||
@@ -58,6 +60,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Service
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
_logger.LogDebug($"Message for {message.ChatId.Identifier} is failed: {e.Message}.");
|
||||||
ReEnqueue(message, e);
|
ReEnqueue(message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Service
|
|||||||
};
|
};
|
||||||
|
|
||||||
_queue.Enqueue(message);
|
_queue.Enqueue(message);
|
||||||
|
_logger.LogDebug($"Enqueued message for {subscriber.SubscriberId}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user