-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |