void ProcessGiftMessage(GiftMessage message) { try { // 送礼物, 赚积分 var giftScore = ScoreService.CalScore(message); UserService.AddScore(message.RoomId, message.UserId, message.UserName, giftScore); // 感谢 var userScore = UserService.GetScore(message.RoomId, message.UserId); Obs.ThanksMessage.AddMessage("感谢 {0} 送的 {1}, 总积分 {2}", message.UserName, message.GiftName, userScore); GiftMessage.SetProcessResult(message, ProcessResult.Ok); OnGiftMessageProcessed(message); } catch (Exception) { GiftMessage.SetProcessResult(message, ProcessResult.Error); throw; } }
void ProcessChouqinMessage(ChouqinMessage message) { try { // 酬勤赚积分 var chouqinScore = ScoreService.CalScore(message); UserService.AddScore(message.RoomId, message.UserId, message.UserName, chouqinScore); // 感谢 var userScore = UserService.GetScore(message.RoomId, message.UserId); Obs.ThanksMessage.AddMessage("感谢 {0} 送的 {1}, 总积分 {2}", message.UserName, message.ChouqinName, userScore); ChouqinMessage.SetProcessResult(message, ProcessResult.Ok);; OnChouqinMessageProcessed(message); } catch (Exception) { ChouqinMessage.SetProcessResult(message, ProcessResult.Error); throw; } }
void ProcessChatMessage(ChatMessage chatMessage) { try { // 发弹幕, 赚积分 var score = ScoreService.CalScore(chatMessage); UserService.AddScore(chatMessage.RoomId, chatMessage.UserId, chatMessage.UserName, score); // 处理弹幕命令 if (IsChatCommand(chatMessage.Text)) { ProcessChatCommand(chatMessage); } ChatMessage.SetProcessResult(chatMessage, ProcessResult.Ok); OnChatMessageProcessed(chatMessage); } catch (Exception) { ChatMessage.SetProcessResult(chatMessage, ProcessResult.Error); throw; } }