private void Client_DataReceived(object sender, SimpleTCP.Message e) { ChatOutput.Invoke((MethodInvoker) delegate() { ChatOutput.Text += e.MessageString; }); }
private void Server_DataReceived(object sender, SimpleTCP.Message e) { ChatOutput.Invoke((MethodInvoker) delegate() { ChatOutput.Text += e.MessageString; e.ReplyLine(string.Format("You said: {0}", e.MessageString)); }); }
/// <summary> /// Sends a privte message to a player /// <note>Use with caution as sending too many PMs will cause the chat to get slow/stuck.</note> /// </summary> /// <param name="message"></param> /// <param name="player"></param> public void Pm(string message, Player player) { ChatOutput.Invoke(this, new RconChatEventArgs(new ChatMessage($"[=> {player.Name}] {message}"))); foreach (var segment in Util.SegmentString(message, CHAR_LIMIT)) { SendCommand("warn", player.Slot.ToString(), segment); } }
/// <summary> /// Broadcasts a message in chat /// </summary> /// <param name="message"></param> public void Say(string message) { ChatOutput.Invoke(this, new RconChatEventArgs(new ChatMessage(message))); foreach (var segment in Util.SegmentString(message, CHAR_LIMIT)) { SendCommand("say", segment); } }
private void Append(string msg) { if (ChatOutput.InvokeRequired) { Invoke(new ChatAppend(Append), new object[] { msg }); } else { ChatOutput.AppendText(ip + ": " + msg + "\n"); } }
public void Given_User_Message_Where_Input_Is_Empty_Then_Stop() { ChatOutput output = new ChatOutput(); bool success = buildPipeline().Flow(new ChatInput() { UserName = "******", HideUserName = false, Message = "", Timestamp = new DateTimeOffset(2016, 1, 1, 0, 0, 0, new TimeSpan(0, 0, 0)) }, ref output); Assert.IsFalse(success); }
public void Given_User_Message_Then_Print_Chat() { ChatOutput output = new ChatOutput(); bool success = buildPipeline().Flow(new ChatInput() { UserName = "******", HideUserName = false, Message = "Hello, World!", Timestamp = new DateTimeOffset(2016, 1, 1, 0, 0, 0, new TimeSpan(0, 0, 0)) }, ref output); Assert.IsTrue(success); Assert.AreEqual("20160101-0000 - Anthony: Hello, World!", output.Message.ToString()); }
public void Given_Server_Message_Then_Print_Chat() { ChatOutput output = new ChatOutput(); bool success = buildPipeline().Flow(new ChatInput() { UserName = "******", HideUserName = true, Message = "(Message of the day) Welcome!", Timestamp = new DateTimeOffset(2016, 1, 1, 0, 0, 0, new TimeSpan(0, 0, 0)) }, ref output); Assert.IsTrue(success); Assert.AreEqual("20160101-0000 - (Message of the day) Welcome!", output.Message.ToString()); }
/// <summary> /// Sends a privte message to a player /// <note>Use with caution as sending too many PMs will cause the chat to get slow/stuck.</note> /// </summary> /// <param name="message"></param> /// <param name="player"></param> public void Pm(string message, Player player) { ChatOutput.Invoke(this, new RconChatEventArgs(new ChatMessage($"[=> {player.Name}] {message}"))); SendCommand("warn", player.Slot.ToString(), message); }
/// <summary> /// Broadcasts a message in chat /// </summary> /// <param name="message"></param> public void Say(string message) { ChatOutput.Invoke(this, new RconChatEventArgs(new ChatMessage(message))); SendCommand("say", message); }
// GET: api/Chat public OutputListChat Get() { var tkn = Token.GetToken(Request); int id = tkn.IdUser; using (ChatContextDataContext db = new ChatContextDataContext()) { //OutputListChat output = new OutputListChat(); //List<OutputListChat> mdchatval = new List<OutputListChat>(); //var chatlist = db.GetlastChat(id).ToList(); //foreach(var item in chatlist) //{ // OutputListChat data = new OutputListChat(); // data.Name = item.Name; // data.Reply = item.Reply; // data.Photo = item.Photo; // data.NameLogin = item.NameLogin; // data.Timestamp = item.Timestamp; // data.Con_Id = item.Con_Id; // data.From_Id = item.From_Id; // data.To_Id = item.To_Id; // mdchatval.Add(data); //} string name = (from a in db.TblUser where a.Id == id select a.Name).FirstOrDefault(); List <ChatOutput> chat = new List <ChatOutput>(); OutputListChat output = new OutputListChat(); var chatlist = db.GetlastChat(id).ToList(); foreach (var item in chatlist) { ChatOutput data = new ChatOutput(); data.Name = item.Name; data.Reply = item.Reply; data.Photo = item.Photo; data.Timestamp = item.Timestamp; data.Con_Id = item.Con_Id; data.From_Id = item.From_Id; data.To_Id = item.To_Id; data.Name2 = item.Name2; chat.Add(data); } output.ListChat = chat; output.NameLogin = name; var replace = (from a in chat select a).ToList(); foreach (var isi in replace) { if (isi.To_Id == id) { isi.Name = isi.Name; } else { isi.Name = isi.Name2; } } //var chatlist = (from a in db.TblUser // join b in db.Conversation on a.Id equals b.From_Id // join c in db.ConversationReply on b.Con_Id equals c.Con_Id // where b.To_Id == id // select new MdChat // { // From_Id = b.From_Id, // Name = a.Name, // To_Id = b.To_Id, // Con_Id = b.Con_Id // }).Distinct().ToList(); //return chatlist; //var chatlist = from ta in from a in db.TblUser // join b in db.Conversation on a.Id equals b.From_Id // join c in db.ConversationReply on b.Con_Id equals c.Con_Id // select new { a.Id, b.To_Id, b.From_Id, c.Con_Id // join u in (from u in db.ConversationReply // group u by u.Con_Id into g // select new // { // conid = g.Key, // Maxstatus = g.Max(x => x.Id) // }) on new { ta.Con_Id } equals new { u.conid } // select ta; // //{ // // Name= a.Name, // // Con_Id = b.Con_Id, // // To_Id = b.To_Id, // // From_Id = b.From_Id // //}); return(output); } }
private void StopButton_Click(object sender, EventArgs e) { if (backgroundWorker1.WorkerSupportsCancellation == true) { backgroundWorker1.CancelAsync(); chatOutput += "[info] IntelBot was stopped.\n"; this.Invoke(new MethodInvoker(delegate { ChatOutput.Text = chatOutput; ChatOutput.SelectionStart = ChatOutput.Text.Length; ChatOutput.ScrollToCaret(); })); } }
private void BackgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; chatOutput = "[info] Starting IntelBot...\n"; //string path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Documents\\EVE\\logs\\Chatlogs\\"; string channelInput = ChannelName.Text; chatOutput += "[info] Path found: " + path + "\n"; this.Invoke(new MethodInvoker(delegate { ChatOutput.Text = chatOutput; ChatOutput.SelectionStart = ChatOutput.Text.Length; ChatOutput.ScrollToCaret(); })); string fileName = GetFileName(channelInput, path); if (fileName == "") { chatOutput += "[ERROR] Channel not found. Please check your input and try again!\n"; ChatOutput.Text = chatOutput; ChatOutput.SelectionStart = ChatOutput.Text.Length; ChatOutput.ScrollToCaret(); } else { chatOutput += "[info] Chat found: " + fileName + "\n"; this.Invoke(new MethodInvoker(delegate { ChatOutput.Text = chatOutput; ChatOutput.SelectionStart = ChatOutput.Text.Length; ChatOutput.ScrollToCaret(); })); string filePath = path + fileName; string keyword1 = System1.Text; if (keyword1 == "") { keyword1 = "nofilterusedasdf1234"; } string keyword2 = System2.Text; if (keyword2 == "") { keyword2 = "nofilterusedasdf1234"; } string keyword3 = System3.Text; if (keyword3 == "") { keyword3 = "nofilterusedasdf1234"; } string keyword4 = System4.Text; if (keyword4 == "") { keyword4 = "nofilterusedasdf1234"; } string keyword5 = System5.Text; if (keyword5 == "") { keyword5 = "nofilterusedasdf1234"; } string keyword6 = System6.Text; if (keyword6 == "") { keyword6 = "nofilterusedasdf1234"; } string keyword7 = System7.Text; if (keyword7 == "") { keyword7 = "nofilterusedasdf1234"; } string keyword8 = System8.Text; if (keyword8 == "") { keyword8 = "nofilterusedasdf1234"; } string keyword9 = System9.Text; if (keyword9 == "") { keyword9 = "nofilterusedasdf1234"; } string[] keywords = new string[] { keyword1, keyword2, keyword3, keyword4, keyword5, keyword6, keyword7, keyword8, keyword9 }; chatOutput += "[info] Filters applied\n"; this.Invoke(new MethodInvoker(delegate { ChatOutput.Text = chatOutput; ChatOutput.SelectionStart = ChatOutput.Text.Length; ChatOutput.ScrollToCaret(); })); chatOutput += "[info] IntelBot running...\n"; this.Invoke(new MethodInvoker(delegate { ChatOutput.Text = chatOutput; ChatOutput.SelectionStart = ChatOutput.Text.Length; ChatOutput.ScrollToCaret(); })); int WrittenLines = 0; player = new System.Media.SoundPlayer(configPath + "alarm.wav"); while (true) { var allLines = ReadLinesFromFile(filePath); for (int i = WrittenLines; i < allLines.Count; i++) //Alle Zeilen durchgehen { if (WrittenLines < allLines.Count) //Alte Zeilen ausfiltern { if (allLines[i].Contains(keywords[0]) || allLines[i].Contains(keywords[1]) || allLines[i].Contains(keywords[2]) || allLines[i].Contains(keywords[3]) || allLines[i].Contains(keywords[4]) || allLines[i].Contains(keywords[5]) || allLines[i].Contains(keywords[6]) || allLines[i].Contains(keywords[7]) || allLines[i].Contains(keywords[8])) //Nach Keywords filtern { chatOutput += "---WARNING!--- "; player.Play(); } chatOutput += allLines[i] + "\n"; this.Invoke(new MethodInvoker(delegate { ChatOutput.Text = chatOutput; ChatOutput.SelectionStart = ChatOutput.Text.Length; ChatOutput.ScrollToCaret(); })); WrittenLines = i + 1; } } if (worker.CancellationPending == true) { e.Cancel = true; break; } System.Threading.Thread.Sleep(1000); } } }
private void Form1_Load(object sender, EventArgs e) { var filestream = new System.IO.FileStream(configPath + "IntelBotConfig.txt", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite); System.IO.StreamReader file = new System.IO.StreamReader(filestream, System.Text.Encoding.UTF8, true, 128); string conftxt = file.ReadToEnd(); file.Close(); if (conftxt == "") { string[] filters = new string[] { "", "", "", "", "", "", "", "", "", }; System.IO.Directory.CreateDirectory(configPath); bool done = SaveToConf(configPath, "Local", filters); using (WebClient wc = new WebClient()) { wc.DownloadFileAsync(new System.Uri("https://dl.dropboxusercontent.com/s/xbs42i9b5q74p90/Jamaican%20Horn%20Siren.wav"), configPath + "\\alarm.wav"); } player = new System.Media.SoundPlayer(configPath + "alarm.wav"); if (done == true) { ChannelName.Text = "Local"; chatOutput += "[info] File: IntelBotConfig.txt Created.\n"; chatOutput += "[info] File: alarm.wav created. To change the alarm-sound go to " + configPath + " and change the file \"alarm.wav\".\n"; } else { chatOutput += "[ERROR] Config could not be created!\n"; } } else { ChannelName.Text = ReadConfig("channel", configPath); System1.Text = ReadConfig("filter1", configPath); System2.Text = ReadConfig("filter2", configPath); System3.Text = ReadConfig("filter3", configPath); System4.Text = ReadConfig("filter4", configPath); System5.Text = ReadConfig("filter5", configPath); System6.Text = ReadConfig("filter6", configPath); System7.Text = ReadConfig("filter7", configPath); System8.Text = ReadConfig("filter8", configPath); System9.Text = ReadConfig("filter9", configPath); chatOutput += "[info] File: IntelBotConfig.txt found and applied.\n"; } this.Invoke(new MethodInvoker(delegate { ChatOutput.Text = chatOutput; ChatOutput.SelectionStart = ChatOutput.Text.Length; ChatOutput.ScrollToCaret(); })); }