public async void HandleMessage(Room room, Message message) { var chatLine = message.Line as ChatLine; if (chatLine == null || chatLine.SenderId == "0") return; await Task.Yield(); var senderId = long.Parse(chatLine.SenderId); var recipientDevices = Notifications .Where(n => n.UserId != senderId && !room.IsBanned(n.Name) && n.Rooms.Contains(chatLine.Chat)) .Where(n => IsMatch(n.Regex, chatLine.Content)) .Select(n => n.DeviceToken) .ToList(); if (recipientDevices.Count > 0) { var content = $"[{chatLine.Chat}] {WebUtility.HtmlDecode(chatLine.Sender)}: {WebUtility.HtmlDecode(chatLine.Content)}"; await Notify(recipientDevices, content); } }
// For RohBot rooms public CommandTarget(Connection connection, string room) { Room = Program.RoomManager.Get(room); Connection = connection; }
// For Steam rooms public CommandTarget(Room room, SteamPersona sender) { Room = room; Persona = sender; }
public void SendLeaveRoom(Room room) { Send(new Chat { Method = "leave", Name = room.RoomInfo.Name, ShortName = room.RoomInfo.ShortName }); }
public void SendJoinRoom(Room room) { Send(new Chat { Method = "join", Name = room.RoomInfo.Name, ShortName = room.RoomInfo.ShortName }); room.SendHistory(this); }
private static string GetRankString(Room room, string username) { if (Util.IsAdmin(room, username)) return "Administrator"; if (Util.IsMod(room, username)) return "Moderator"; if (room.IsBanned(username)) return "Guest"; return "Member"; }