public void should_parse_room_message_into_proper_type() { var message = new agsXMPP.protocol.client.Message() {From = "[email protected]/Dharma Soft", Body = "Message Body"}; var xmppMessage = MessageFactory.Create(message); Assert.That(xmppMessage.MessageType,Is.EqualTo(MessageType.RoomMessage)); }
public void Execute(Message message) { if(_directory.RemoveSubscriber(message.From.Bare)) { _communicator.SendMessage(message.From.Bare,REMOVED_CONFIRMATION_MESSAGE); } }
public static bool IsContentMessage(Message msg) { //A "content message" -- that is, a message stanza whose primary meaning is contained in //standard messaging content such as the XMPP <body/> or any other properly-namespaced child //element(s) other than those defined for chat state notifications in this specification. return !string.IsNullOrEmpty(msg.Body) || msg.HasTag(XamlBody.TAG); }
/// <summary> /// 命令发送 /// </summary> /// <param name="ToServerName"></param> /// <param name="strCommand"></param> public void SendCommand(string ToServerName, string strCommand) { agsXMPP.Jid jid = new agsXMPP.Jid(ToServerName); agsXMPP.protocol.client.Message sendMsg = new agsXMPP.protocol.client.Message(jid, MessageType.chat, strCommand); objXmpp.Send(sendMsg); LogTrace(ToServerName + " " + strCommand); }
private void ConnectionOnMessage(object sender, Message msg) { OnMessageReceived(new MessageReceivedArgs { Message = Create(msg) }); }
private void OnMessage(object sender, agsXMPP.protocol.client.Message message) { if (!String.IsNullOrEmpty(message.Body) && message.From.Resource != _username) { string user = string.Format("{0}@{1}/{2}", message.From.User, message.From.Server, message.From.Resource); var content = message.Body.Trim(); if (message.From.Server != _confServer && !content.StartsWith(Robot.Alias ?? Robot.Name, StringComparison.OrdinalIgnoreCase)) { content = string.Concat(Robot.Alias ?? Robot.Name, " ", content); } Logger.Info(string.Format("[{0}] {1}: {2}", DateTime.Now, user, content)); var userObj = Robot.GetUser(message.Id, user, message.From.Bare, Id); if (userObj.Name != _username) { Task.Run(() => { Robot.Receive(new TextMessage(userObj, content)); }); } } }
private void Message1() { // transient message (will not be stored offline if the server support AMP) /* <message to='*****@*****.**' from='[email protected]/elsinore' type='chat' id='chatty1'> <body>Who's there?</body> <amp xmlns='http://jabber.org/protocol/amp'> <rule action='drop' condition='deliver' value='stored'/> </amp> </message> */ agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.To = new Jid("*****@*****.**"); msg.From = new Jid("[email protected]/elsinore"); msg.Type = MessageType.chat; msg.Id = "chatty1"; msg.Body = "Who's there?"; Amp amp = new Amp(); Rule rule = new Rule(Condition.Deliver, "stored", agsXMPP.protocol.extensions.amp.Action.drop); amp.AddRule(rule); msg.AddChild(amp); Program.Print(msg); }
//������Ϣ private void button2_Click(object sender, EventArgs e) { agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); if (listBox1.SelectedIndex > 0) { msg.Type = MessageType.chat; msg.Body = richTextBox2.Text; msg.From = new Jid(con.Username, "localhost", "resource"); msg.To = new Jid(name, "localhost", con.Username); con.Send(msg); richTextBox2.Text = ""; } else { msg.Type = MessageType.groupchat; msg.Body = richTextBox2.Text; msg.From = new Jid(con.Username, "localhost", "resource"); msg.To = new Jid(con.Server, "localhost", con.Username); con.Send(msg); richTextBox2.Text = ""; } }
private void button2_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(textBox4.Text)) { MessageBox.Show("要发送到的uid不能为空!"); } else if (string.IsNullOrWhiteSpace(textBox2.Text)) { MessageBox.Show("消息不能为空!"); } else { try { int touid = int.Parse(textBox4.Text); string JID_RECEIVER = touid + "@10.80.5.254"; agsXMPP.protocol.client.Message m = new agsXMPP.protocol.client.Message(new Jid(JID_RECEIVER), MessageType.chat, textBox2.Text); m.To = new Jid(JID_RECEIVER); m.From = selfJid; xmpp.Send(m); }catch (FormatException fe) { MessageBox.Show("要发送到的uid只能是数字"); } } }
public void ProcessMessage(Message message) { if (!CanProcess(message)) return; ChatMember from = _directory.LookUp(message.From.Bare); if (from == null) return; if (from.ActiveInChat) { IEnumerable<ChatMember> recipients = _directory.GetToListForSubscriber(message.From.Bare); foreach (ChatMember member in recipients) { if (member.ActiveInChat) { _communicator.SendMessage(member.Jid, string.Format("[\"{0}\"] {1}", from.Alias, message.Body)); } } } else { _communicator.SendMessage(from.Jid, NOT_ACTIVE_IN_CHAT_MESSAGE); } }
protected virtual void ProcessMessage(Message message) { if (message.Body == null) return; try { var msgObj = MessageFactory.GetMessageFromXml(message.Body); if (msgObj == null) return; var msgType = msgObj.GetType(); if (msgType == typeof(GameStartMessage)) ProcessGameStartMessage(message.From, (GameStartMessage)msgObj); if (msgType == typeof(GameOverMessage)) ProcessGameOverMessage(message.From, (GameOverMessage)msgObj); if (msgType == typeof(TurnResultMessage)) ProcessTurnResultMessage(message.From, (TurnResultMessage)msgObj); if (msgType == typeof(TurnStartMessage)) ProcessTurnStartMessage(message.From, (TurnStartMessage)msgObj); if (msgType == typeof(RegistrationCompleteMessage)) ProcessRegistrationCompleteMessage(message.From); if (msgType == typeof(TournamentStartedMessage)) ProcessTournamentStartedMessage(message.From, (TournamentStartedMessage)msgObj); if (msgType == typeof(PlayerMoveMessage)) ProcessPlayerMoveMessage(message.From, (PlayerMoveMessage)msgObj); if (msgType == typeof(RegisterMessage)) ProcessRegisterMessage(message.From); } catch (Exception) { } }
/// <summary> /// Al usuario B le llega un mensaje y levanta un formulario drmChat /// </summary> /// <param name="msg">Message enviado por A</param> public void SwitchMessage(agsXMPP.protocol.client.Message msg) { if (msg.Type == MessageType.groupchat) { return; } if (msg.Body != null)//--> es un chat { frmChat f = null; if (ChatForms.ContainsKey(msg.From.Bare)) { f = (frmChat)ChatForms[msg.From.Bare]; f.Show(); } else { RosterNode rn = RosterControl.GetRosterItem(msg.From); string nick = msg.From.Bare; if (rn != null) { nick = rn.Text; } f = new frmChat(msg.From, nick); f.Show(); f.IncomingMessage(msg); } } if (msg.HasTag(typeof(Comand))) { } }
private void xmpp_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { new Task(delegate { //ignore empty messages if (msg.Body.IsNullOrEmpty() || msg.Error != null) { return; } //get the message's sender, remove XMPP resource from the message var messageSender = msg.From.ToString(); messageSender = messageSender.Contains("/") ? messageSender.Substring(0, messageSender.IndexOf("/")) : messageSender; //if messages bounced and sender is this client itself, ignore the message if (messageSender.ToLower() == String.Format("{0}@{1}", this.Username, this.Server).ToLower()) { logger.Warn("Bounced message revceived. Ignoring"); return; } logger.Info("Received message from {0}", messageSender); //Raise MessageReceived event this.onMessageReceived(messageSender, msg.Body); }).Start(); }
private void MessageCallBack(object sender, Message msg, object data) { if (msg.Body != null) { var payload = new MessagePayload(); payload.Attachments = new List<MessagePayloadAttachment>(); if (!msg.Body.Contains("@everyone")) { msg.Body = string.Concat("@everyone: ", msg.Body); } payload.Attachments.Add(new MessagePayloadAttachment() { Text = msg.Body.Replace("@everyone", "@channel"), Title = string.Format("{0}: Message from {1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "Marvin"), Colour = "#ff0066" }); Plugin.SendToRoom(payload, Properties.Settings.Default.FleetRoomName, Properties.Settings.Default.SlackWebhook, Properties.Settings.Default.FleetBotName); if (msg.Body.Contains("bog_all")) { foreach (var hook in Properties.Settings.Default.DiscordLinkSlackWebhooks) { Plugin.SendToRoom(payload, Properties.Settings.Default.FleetRoomName, hook, Properties.Settings.Default.FleetBotName); } } } }
private void Say(Room room, string message, bool html) { Msg msg; if (room.IsChat) { var to = new Jid(room.JabberId, "chat.hipchat.com", string.Empty); msg = new Msg(to, current.JabberId, MessageType.chat, message); } else { Out.WriteLine("{0:HH:mm:ss} [{1}] {2}", DateTime.Now, current.Name, message); var to = new Jid(room.JabberId, "conf.hipchat.com", string.Empty); msg = new Msg(to, current.JabberId, MessageType.groupchat, message); } if (html) { msg.Html = new Html(); msg.Html.Body = new Body(); msg.Html.Body.Value = message; } Out.WriteLine(msg.ToString()); connection.Send(msg); }
public bool CanProcess(Message message) { if (message == null) return false; return !string.IsNullOrEmpty(CommandProcessor.GetCommandFromMessage(message.Body)); }
/// <summary> /// Procesar llegada de mensaje /// </summary> /// <param name="msg"></param> private void IncomingMessage(agsXMPP.protocol.client.Message msg) { if (msg.Type == MessageType.error) { //TODO: HAY QUE MANEJAR EL ERROR AQUI return; } if (msg.Subject != null)//------------> SI CAMBIA EL ASUNTO { txtSubject.Text = msg.Subject; rtfChat.SelectionColor = Color.DarkGreen; // El Nickname del que envia esta en el GroupChat, en el Jid.Resource rtfChat.AppendText(msg.From.Resource + " changed subject: "); rtfChat.SelectionColor = Color.Black; rtfChat.AppendText(msg.Subject); rtfChat.AppendText("\r\n"); } else { if (msg.Body == null) { return; } rtfChat.SelectionColor = Color.Red; // The Nickname of the sender is in GroupChat in the Resource of the Jid rtfChat.AppendText(msg.From.Resource + " said: "); rtfChat.SelectionColor = Color.Black; rtfChat.AppendText(msg.Body); rtfChat.AppendText("\r\n"); } }
public Message Create(FlowDocument document) { var xdoc = new XmlDocument(); xdoc.LoadXml(XamlWriter.Save(document)); var newAttr = xdoc.CreateAttribute("xml:space"); newAttr.Value = "preserve"; xdoc.DocumentElement.Attributes.Append(newAttr); var sb = new StringBuilder(xdoc.OuterXml); //see: http://stackoverflow.com/questions/2624068/wpf-richtextbox-xamlwriter-behaviour var xamlPart = sb.Replace("{}{", "{").ToString(); var txtPart = new TextRange(document.ContentStart, document.ContentEnd) .Text .TrimEnd(); var xaml = new XamlBody(); xaml.Content = xamlPart; var msg = new Message { Body = txtPart, }; msg.AddChild(xaml); return msg; }
private void listUsers_MouseDoubleClick(object sender, MouseEventArgs e) { if (listUsers.SelectedItems.Count > 0 && listUsers.SelectedItems[0] != null) { initFormDialog(); string name = listUsers.SelectedItems[0].Text; string jid = listUsers.SelectedItems[0].Name; int indexTab = findTagPage(jid); List <agsXMPP.protocol.client.Message> msgsWait = waitList.FindAll(item => item.From.Bare == jid);//получает все сообщения из списка ожидающих сообщений с нужным jid if (indexTab == -1) { createTabPage(name, jid);//, getHistoryFromDB(jid)); tabsDialog.SelectedIndex = tabsDialog.TabPages.Count - 1; } else { tabsDialog.SelectedIndex = indexTab; } indexTab = tabsDialog.SelectedIndex; //добавляем сообщения из ожидания в диалог for (int i = msgsWait.Count - 1; i >= 0; i--) { agsXMPP.protocol.client.Message msgWait = msgsWait[i]; ((TextBox)tabsDialog.TabPages[indexTab].Controls[0]).AppendText(formateString(msgWait.From.Bare, msgWait.Body)); waitList.Remove(msgWait); } } }
/// <summary> /// Отправляет сообщение к собеседнику с заданным jid и выводит его в textbox с чатом, а также добавляет в историю(в бд) /// </summary> /// <param name="toJid">jid получателя</param> /// <param name="dialog">textbox с чатом</param> /// <param name="message">сообщение</param> public void SendTextMessage(Jid toJid, RichTextBox dialog, string message) { agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(toJid, MessageType.chat, message); xmpp.Send(msg); addMessToDialog(nickname, message, dialog, Settings.myColor); //addMessageToHistoryDB(mainJid.Bare, mainJid.Resource, toJid.Bare, toJid.Resource, message); }
void XmppConnection_OnMessage(object sender, Message msg) { if (!roomName.Contains(msg.From.User)) return; if (msg.From.Resource == Client.LoginPacket.AllSummonerData.Summoner.Name) return; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { if (msg.Body == "This room is not anonymous") return; var tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd) { Text = msg.From.Resource + ": " }; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Turquoise); tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd) { Text = msg.Body.Replace("<![CDATA[", "").Replace("]]>", string.Empty) + Environment.NewLine }; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White); ChatText.ScrollToEnd(); })); }
private void SendTextMessage(string toJid, TextBox dialog, string message) { agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(new Jid(toJid), MessageType.chat, message); xmpp.Send(msg); dialog.AppendText(formateString(nickname, message)); addMessageToDB(mainJid.Bare, toJid, message); }
private void IncomingMessage(agsXMPP.protocol.client.Message msg) { if (msg.Type == MessageType.error) { //Handle errors here // we dont handle them in this example return; } if (msg.Subject != null) { txtSubject.Text = msg.Subject; rtfChat.SelectionColor = Color.DarkGreen; // The Nickname of the sender is in GroupChat in the Resource of the Jid rtfChat.AppendText(msg.From.Resource + " изменил тему: "); rtfChat.SelectionColor = Color.Black; rtfChat.AppendText(msg.Subject); rtfChat.AppendText("\r\n"); } else { if (msg.Body == null) { return; } rtfChat.SelectionColor = Color.Blue;//(msg.Nickname.InnerXml == nickname) ? Color.Green : Color.Red; // The Nickname of the sender is in GroupChat in the Resource of the Jid rtfChat.AppendText(msg.From.Resource + " : "); rtfChat.SelectionColor = Color.Black; rtfChat.AppendText(msg.Body); rtfChat.AppendText("\r\n"); } }
void recieveMsg(agsXMPP.protocol.client.Message msg) { if (curUser != null && msg.From.Equals(curUser.Jid)) //Если написал тот пользователь, с кем сейчас диалог { richTextBox1.SelectionColor = Color.Red; richTextBox1.AppendText(curUser.Name + ": "); richTextBox1.SelectionColor = Color.Black; richTextBox1.AppendText(msg.Body + "\n"); } else { xDoc.Load("src.xml"); XmlElement xRoot = xDoc.DocumentElement; XmlNode node = xRoot.SelectSingleNode("user[@JID='" + msg.From + "']"); if (node == null) { XmlElement userElem = xDoc.CreateElement("user"); XmlElement textUser = xDoc.CreateElement("text"); XmlElement rtfUser = xDoc.CreateElement("rtf"); XmlAttribute jidAttr = xDoc.CreateAttribute("JID"); jidAttr.AppendChild(xDoc.CreateTextNode(msg.From.ToString())); userElem.Attributes.Append(jidAttr); newMsgBox.SelectionColor = Color.Red; newMsgBox.AppendText(getNameByJID(msg.From) + ": "); newMsgBox.SelectionColor = Color.Black; newMsgBox.AppendText(msg.Body + "\n"); textUser.InnerText = newMsgBox.Text; rtfUser.InnerText = newMsgBox.Rtf; newMsgBox.Clear(); userElem.AppendChild(textUser); userElem.AppendChild(rtfUser); xRoot.AppendChild(userElem); } else { newMsgBox.Rtf = node.SelectSingleNode("rtf").InnerText; newMsgBox.SelectionColor = Color.Red; newMsgBox.AppendText(getNameByJID(msg.From) + ": "); newMsgBox.SelectionColor = Color.Black; newMsgBox.AppendText(msg.Body + "\n"); node.SelectSingleNode("text").InnerText = newMsgBox.Text; node.SelectSingleNode("rtf").InnerText = newMsgBox.Rtf; newMsgBox.Clear(); } addUnRead(msg.From.ToString()); xDoc.Save("src.xml"); } }
public void IncomingMessage(Message message) { chatRichTextBoxShow.SelectionColor = Color.Indigo; chatRichTextBoxShow.AppendText(_nickName + " said:"); chatRichTextBoxShow.SelectionColor = Color.Olive; chatRichTextBoxShow.AppendText(message.Body); chatRichTextBoxShow.AppendText("\r\n"); }
/// <summary> /// Changing the subject in a chatroom /// in MUC rooms this could return an error when you are a normal user and not allowed /// to change the subject. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdChangeSubject_Click(object sender, EventArgs e) { agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = MessageType.groupchat; msg.To = roomJid; msg.Subject = txtSubject.Text; xmpp.Send(msg); }
private void OutMessage(Message message) { chatRichTextBoxShow.SelectionColor = Color.MidnightBlue; chatRichTextBoxShow.AppendText("Me said:"); chatRichTextBoxShow.SelectionColor = Color.RosyBrown; chatRichTextBoxShow.AppendText(message.Body); chatRichTextBoxShow.AppendText("\r\n"); }
private void cmdSend_Click() { // Send a message agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = agsXMPP.protocol.client.MessageType.chat; msg.To = new Jid(""); msg.Body = ""; }
void JabberClient_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { Log.Debug(String.Format("New jabber message from {0}: {1}", msg.From.ToString(), msg.Body)); if (msg.Type == MessageType.chat && msg.From != null && msg.From != new Jid(_jabberConnection.identity.jabberID.full)) { OnMessage(new Message(msg, DirectionTypes.Incoming, DateTime.Now)); } }
private void OutgoingMessage(agsXMPP.protocol.client.Message msg) { rtfChat.SelectionColor = Color.Blue; rtfChat.AppendText("Me said: "); rtfChat.SelectionColor = Color.Black; rtfChat.AppendText(msg.Body); rtfChat.AppendText("\r\n"); }
public void IncomingMessage(agsXMPP.protocol.client.Message msg) { rtfChat.SelectionColor = Color.Red; rtfChat.AppendText(_nickname + " said: "); rtfChat.SelectionColor = Color.Black; rtfChat.AppendText(msg.Body); rtfChat.AppendText("\r\n"); }
public FurikoMessage(Message _msg) { DateTime now = DateTime.Now; //time = now.ToString("yyyy-MM-dd HH:mm:ss"); time = DateTime.Now; with = _msg.From.Bare; jid = _msg.From.Bare; body = _msg.Body; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="msg"></param> /// <param name="data"></param> private void MessageCallback(object sender, agsXMPP.protocol.client.Message msg, object data) { BeginInvoke(new MethodInvoker(delegate { if (msg.Type == MessageType.groupchat) { IncomingMessage(msg); } })); }
private void MessageCallback(object sender, agsXMPP.protocol.client.Message msg, object data) { if (msg.Body == null) { return; } IncomingMessage(msg); }
private void btnBroadCast_Click(object sender, EventArgs e) { agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Subject = "Mensaje a todos"; msg.To = new Jid(string.Concat("all@broadcast.", Util.storage.StorageObject.Server)); msg.Body = "Hola a todos"; Util.XmppServices.XmppCon.Send(msg); }
private IMessage Create(Message msg) { return new FeedMessage { XmppMessage = msg, Date = DateTime.Now, ClientId = _client.Id }; }
public void OnMessage(object sender, Message msg) { if (msg.Type == MessageType.chat) { messages.Enqueue(msg); messageEvent.Set(); //currentChat = msg.CreateNewThread(); } }
public Message Create(FlowDocument document) { var body = new TextRange(document.ContentStart, document.ContentEnd) .Text .TrimEnd(Environment.NewLine.ToCharArray()); var msg = new Message(); msg.Body = body; return msg; }
private void button2_Click_1(object sender, EventArgs e) { agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = MessageType.groupchat; msg.To = Roomjid; msg.Body = textBox2.Text; dbcon.Send(msg); textBox2.Clear(); }
//Blink and add to notification list if messaged private void XmppConnection_OnMessage(object sender, Message msg) { //If is special message, don't show popup if (msg.Subject != null) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { var subject = (ChatSubjects)Enum.Parse(typeof(ChatSubjects), msg.Subject, true); if ((subject == ChatSubjects.PRACTICE_GAME_INVITE || subject == ChatSubjects.GAME_INVITE) && Client.NotificationContainer.Visibility != Visibility.Visible) { NotificationButton.Content = "."; } })); return; } if (!Client.AllPlayers.ContainsKey(msg.From.User) || string.IsNullOrWhiteSpace(msg.Body)) return; if (msg.Body.ToLower().Contains("elo") && msg.Body.ToLower().Contains("boost")) return; ChatPlayerItem chatItem = Client.AllPlayers[msg.From.User]; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { NotificationChatPlayer player = ChatListView.Items.Cast<object>() .Where(i => i.GetType() == typeof(NotificationChatPlayer)) .Cast<NotificationChatPlayer>() .FirstOrDefault(x => x.PlayerName == chatItem.Username); if (player == null) { player = new NotificationChatPlayer { Tag = chatItem, PlayerName = chatItem.Username, Margin = new Thickness(1, 0, 1, 0), PlayerLabelName = { Content = chatItem.Username } }; Client.ChatListView.Items.Add(player); } if (Client.ChatItem != null) { if ((string)Client.ChatItem.PlayerLabelName.Content != chatItem.Username) { player.BlinkRectangle.Visibility = Visibility.Visible; } } else player.BlinkRectangle.Visibility = Visibility.Visible; })); }
void XmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { if (InvokeRequired) { BeginInvoke(new MessageHandler(XmppCon_OnMessage), new object[] { sender, msg }); return; } Util.XmppServices.SwitchMessage(msg); }
static void HipchatClient_OnMessage(object sender, Message msg) { HipchatRoom room = Rooms.FirstOrDefault(rm => rm.RoomId.Bare.StartsWith(msg.From.Bare, StringComparison.CurrentCultureIgnoreCase)); if (room == null) { return; } Window.AddItem(msg.Body, msg.From.Resource, room.Name); }
/// <summary> /// Changing the subject in a chatroom /// in MUC rooms this could return an error when you are a normal user and not allowed /// to change the subject. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdChangeSubject_Click(object sender, EventArgs e) { agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = MessageType.groupchat; msg.To = m_RoomJid; msg.Subject = txtSubject.Text; m_XmppCon.Send(msg); }
public void ProcessMessage(Message message) { if (!CanProcess(message)) return; string commandString = CommandProcessor.GetCommandFromMessage(message.Body); ICommand command = Array.Find(_commands, c => c.CommandName == commandString.ToLower()); if(command != null) command.Execute(message); }
private void OnMessage(object sender, Message msg) { if (m_listener == null) return; if (msg.From.Bare != Jid) return; m_listener.OnMessage(new ChatMessage(msg.From.Resource, msg.Body)); }
static void MessageCallBack(object sender, agsXMPP.protocol.client.Message msg, object data) { if ((msg.Body != null) && (msg.Body.Contains(Properties.Settings.Default.AllianceGroup) || msg.Body.Contains(Properties.Settings.Default.CorpGroup) || msg.Body.Contains(Properties.Settings.Default.FCGroup))) { var lines = msg.Body.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); var senderLines = lines[0].Replace("**** This was broadcast by ", "").Replace(" EVE ****", "").Replace("@everyone", "").Split(new[] { " at " }, StringSplitOptions.RemoveEmptyEntries); var recipient = lines[lines.Length - 1].Replace("**** Message sent to the ", "").Replace(" Group ****", ""); var sendLines = new List <string>(); //sendLines.Add(string.Format("Timestamp: {0}", senderLines[1])); sendLines.Add(string.Format("From: {0}", senderLines[0])); sendLines.Add(string.Format("To: {0}", recipient)); for (var i = 1; i < lines.Length - 1; i++) { sendLines.Add(lines[i]); } ConsoleWriteLine(string.Format("{0}>> {1}", msg.From.User, msg.Body), ConsoleColor.Red); var payload = new MessagePayload(); payload.Text = "@channel: Alliance Broadcast"; payload.Attachments = new List <MessagePayloadAttachment>(); //if (!msg.Body.Contains("@everyone")) //{ // sendLines.Insert(0, "@everyone"); //} payload.Attachments.Add(new MessagePayloadAttachment() { Text = new Censor().CensorText(string.Join("\n", sendLines)), Title = string.Format("{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), Colour = "#ff0066" }); if (msg.Body.Contains(Properties.Settings.Default.CorpGroup) || msg.Body.Contains(Properties.Settings.Default.AllianceGroup)) { Plugin.SendToRoom(payload, Properties.Settings.Default.Room, Properties.Settings.Default.SlackWebhook, Properties.Settings.Default.BroadcastName); if (msg.Body.Contains(Properties.Settings.Default.AllianceGroup)) { foreach (var webhook in Properties.Settings.Default.SharedWebhooks) { Plugin.SendToRoom(payload, Properties.Settings.Default.Room, webhook, Properties.Settings.Default.BroadcastName); } } } else if (msg.Body.Contains(Properties.Settings.Default.FCGroup)) { Plugin.SendToRoom(payload, Properties.Settings.Default.FCRoom, Properties.Settings.Default.SlackWebhook, Properties.Settings.Default.BroadcastName); } } }
public ChatMessage(XmppClientConnection client, Message message) { this.client = client; Text = message.Body; From = message.From; IsGroupChat = message.Type == MessageType.groupchat; Username = IsGroupChat ? message.From.Resource : message.From.User; }
private static void SendChatMessage() { var msg = new Message { Type = MessageType.chat, To = new Jid("*****@*****.**"), Body = "Тестовое сообщение" }; _xmppCon.Send(msg); }
private void button2_Click(object sender, EventArgs e) // Boton para enviar mensaje. { { agsXMPP.Jid JID = new Jid(ContactoSeleccionado); // Se crea un objeto tipo JID(usuario). agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); // Se crea un objeto tipo mensaje. msg.Type = MessageType.chat; // Se define el tipo de mensaje. msg.To = JID; // Se define el destinatario. msg.Body = richTextBox1.Text; // Se define el mensaje en sí. xmpp.Send(msg); // Se envía el mensaje. } }
public void Setup() { var to = new Jid("*****@*****.**"); var from = new Jid("*****@*****.**"); var msg = new Message(to, from, MessageType.groupchat, "slow clap"); var eventObj = new GroupChatMessageArrived(msg, "testroom"); _notifier = Substitute.For<IEventNotifier>(); var handler = new GroupChatScriptHandler(_notifier); handler.ScriptFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "scripts"); handler.Handle(eventObj); }
public static void RefreshLists() { Trace.WriteLine("[Bot]RefreshList"); var arr = _userList.ToArray(); foreach(var u in arr) { var m = new Message(u , MessageType.normal , "" , "refresh"); Xmpp.Send(m); } Trace.WriteLine("[Bot]RefreshListEnd"); }
private void OnMessage4(object sender, agsXMPP.protocol.client.Message msg) { if (this.InvokeRequired) { this.BeginInvoke((Delegate) new MessageHandler(this.OnMessage4), sender, (object)msg); } else if (msg.Type == MessageType.groupchat && msg.From.Resource == "admin") { this.pictureBox5.Load(msg.Body.Replace("Enter the right answer to start chatting. ", "")); } }
private void cmdSend_Click(object sender, System.EventArgs e) { agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = MessageType.chat; msg.To = m_Jid; msg.Body = rtfSend.Text; _connection.Send(msg); OutgoingMessage(msg); rtfSend.Text = ""; }
private void SendConfMessage(string message) { if (message.Length > 0) { agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = MessageType.groupchat; msg.To = roomJid; msg.Body = message; xmpp.Send(msg); textBoxSend.Clear(); } }
public void XmppConnection_OnMessage(object sender, Message msg, object body) { if (!Client.AllPlayers.ContainsKey(msg.From.User) || string.IsNullOrWhiteSpace(msg.Body)) return; var chatItem = Client.AllPlayers[msg.From.User]; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { if ((string)Client.ChatItem.PlayerLabelName.Content == chatItem.Username) Update(); })); }
public Message(agsXMPP.protocol.client.Message msg, DirectionTypes directionType, DateTime receivedTime) { this.InternalMessage = msg; this.DateTimeReceived = receivedTime; this.DirectionType = directionType; this.Unread = (directionType == DirectionTypes.Incoming); this.MessageID = Guid.NewGuid(); this.InternalMessage = msg; this.Replied = false; base.Path = MessageID.ToString(); UpdateItemInfo(); }
public void Process(Message message) { IMessageHandler[] messageHandlers = Array.FindAll(_messageHandlers, h => h.CanProcess(message)); if (messageHandlers.Length > 0) { foreach (var handler in messageHandlers) { handler.ProcessMessage(message); } } }
public void ProcessMessage(Message message) { MatchCollection matchCollection = _regEx.Matches(message.Body); ChatMember member = _directory.LookUp(message.From.Bare); foreach (var urlMatch in matchCollection) { LinkLog linkLog = new LinkLog {DateLogged = DateTime.Now, Url = urlMatch.ToString(), Sender = member}; _linkLogger.SaveLog(linkLog); } }
private void cmdSend_Click(object sender, System.EventArgs e) { agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = MessageType.chat; msg.To = ownewrJid; msg.Body = rtfSend.Text; Util.XmppServices.XmppCon.Send(msg); OutgoingMessage(msg); rtfSend.Text = ""; }
public void Foo() { LinkLoggerHandler handler = new LinkLoggerHandler(new MemberDirectory(), new LinkLogger()); Assert.IsTrue(handler.CanProcess(new Message("*****@*****.**", "the is a www.google.com match"))); Assert.IsTrue(handler.CanProcess(new Message("*****@*****.**", "the is a http://google.com match"))); Message multiUrlMessage = new Message("*****@*****.**", "the is a http://google.com www.cnn.com https://nyt.com match"); Assert.IsTrue(handler.CanProcess(multiUrlMessage)); Assert.IsFalse(handler.CanProcess(new Message("*****@*****.**", "this is not a processable message"))); handler.ProcessMessage(multiUrlMessage); }