Skip to content

Commit

Permalink
add: plan a topic
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-aslan committed Dec 14, 2024
1 parent 4197a51 commit 48dfa71
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions SmartHomeServer/MQTT/PlanATopic.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Business.Abstract;
using SmartHomeServer.MQTT.Abstract;
using System.Text;
using Telegram.Bot;

namespace SmartHomeServer.MQTT;

[Topic(Topic = "planA")]
public class PlanATopic : ITopic
{
ITelegramBotClient _client;
IStatService _statService;
ILogService _logService;
IUserService _userService;

public PlanATopic(IBotService botService, IStatService statService, ILogService logService, IUserService userService)
{
_client = new TelegramBotClient(botService.GetSelectedBot().Token);
_statService = statService;
_logService = logService;
_userService = userService;
}

public void Execute(MQTTMessage message)
{
_userService.GetAdmins().ForEach(e =>
{
_client.SendMessage(e.ChatId, "alarm: Plan A");
});

_logService.AddAsync(message.Topic, Encoding.Default.GetString(message.Payload), message.Sender);
}
}

0 comments on commit 48dfa71

Please sign in to comment.