Skip to content

Commit

Permalink
Add /teachers
Browse files Browse the repository at this point in the history
  • Loading branch information
wh0o7 committed Oct 21, 2023
1 parent 01e073e commit 317458c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions TeachersTimetable/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private static async Task Run()
await Core.Start(new[]
{
new BotCommand("start", "Запустить приложение"), new BotCommand("help", "Помощь"),
new BotCommand("teachers", "Посмотреть список преподователей"), new BotCommand("teachers", "Преподаватели"),
new BotCommand("belltime", "Посмотреть расписание звонков")
});
}
Expand Down
9 changes: 9 additions & 0 deletions TeachersTimetable/Services/CommandsService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using MongoDB.Driver;
using TeachersTimetable.Config;
using Telegram.BotAPI.AvailableMethods;
using Telegram.BotAPI.AvailableTypes;
using TelegramBot_Timetable_Core;
using TelegramBot_Timetable_Core.Config;
using TelegramBot_Timetable_Core.Models;
using TelegramBot_Timetable_Core.Services;

Expand All @@ -19,6 +21,7 @@ public class CommandsService : ICommandsService
private readonly IMongoService _mongoService;
private readonly IBotService _botService;
private readonly IDistributionService _distributionService;
private static string _teachersList;

public CommandsService(IInterfaceService interfaceService, IAccountService accountService, IMongoService mongoService,
IBotService botService, IDistributionService distributionService)
Expand All @@ -30,6 +33,7 @@ public CommandsService(IInterfaceService interfaceService, IAccountService accou
this._mongoService = mongoService;
this._botService = botService;
this._distributionService = distributionService;
_teachersList = string.Join('\n', new Config<TeachersConfig>().Entries.Teachers);
}

private async void OnMessageReceive(Message message)
Expand Down Expand Up @@ -60,6 +64,11 @@ private async void OnMessageReceive(Message message)
$"Вы пользуетесь ботом, который поможет узнать Вам актуальное расписание преподавателей МГКЦТ.\nСоздатель @litolax"));
break;
}
case "/teachers":
{
this._botService.SendMessage(new SendMessageArgs(sender.Id, _teachersList));
break;
}
case "/belltime":
{
this._botService.SendMessage(new SendMessageArgs(sender.Id, $"""
Expand Down

0 comments on commit 317458c

Please sign in to comment.