public AntiBayanBot.Core.Models.BayanResult GetBayanResult(Bitmap bitmap, Telegram.Bot.Types.Message message) { Core.Models.MessageData forwardMsgData = null; if (message.ForwardFrom != null) { forwardMsgData = new Core.Models.MessageData() { MessageId = message.MessageId, ChatId = message.Chat.Id, UserId = message.ForwardFrom.Id, UserFullName = GetUserFullName(message.ForwardFrom.FirstName, message.ForwardFrom.LastName), UserName = message.ForwardFrom.Username, DateTimeAdded = message.ForwardDate.Value }; } else if (message.ForwardFromChat != null) { forwardMsgData = new Core.Models.MessageData() { MessageId = message.MessageId, ChatId = message.Chat.Id, UserId = message.ForwardFromChat.Id, UserFullName = message.ForwardFromChat.Title, UserName = message.ForwardFromChat.Title, DateTimeAdded = message.ForwardDate.Value }; } var msgData = new Core.Models.MessageData() { MessageId = message.MessageId, ChatId = message.Chat.Id, UserId = message.From.Id, UserFullName = GetUserFullName(message.From.FirstName, message.From.LastName), UserName = message.From.Username, DateTimeAdded = message.Date }; var messageData = forwardMsgData ?? msgData; if (IsInnerForward(messageData.DateTimeAdded, messageData.UserId, messageData.ChatId)) { return(new Core.Models.BayanResult()); } var result = Recognition.BayanDetector.DetectPhotoBayan(bitmap, messageData); if (result.IsBayan) { // Наказываем баяниста var statisticsRepository = new Core.Dal.StatisticsRepository(); // Сколько он уже набаянил var bayans = statisticsRepository.IncrementBayansCount(msgData); result.BayansCount = bayans; } return(result); }
public string GetStatsMessage(long chatId, string chatName) { var result = $"<b>Топ заядлых баянистов в группе {chatName}:</b>\n"; var stats = new Core.Dal.StatisticsRepository().GetChatStatistics(chatId, 10); foreach (var user in stats) { result += $"{GetUserTargetName(user.UserName, user.UserFullName)} ({user.Bayans})\n"; } return(result); }