private static void xmpp_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { if (!string.IsNullOrEmpty(msg.Body)) { // This is called for any message received. Console.WriteLine("Received: " + msg.Body); // Get the Gmail username. agsXMPP.Jid JID = new Jid(msg.From.Bare); // Get the context User from the Gmail username (allows our bot to track conversations per user). User user = CommonManager.GetUser(msg.From.Bare, _bot); // Let our chat bot respond to the message. string response = HandleMessage(msg.Body, user); // Setup a response event. _xmppConnection.MessageGrabber.Add(JID, new agsXMPP.Collections.BareJidComparer(), new MessageCB(ChatResponseReceived), null); // Create a new message. agsXMPP.protocol.client.Message newmsg = new agsXMPP.protocol.client.Message(); newmsg.Type = agsXMPP.protocol.client.MessageType.chat; newmsg.To = JID; newmsg.Body = response; // Send response. _xmppConnection.Send(newmsg); } }
//收到消息 void objXmpp_ReciveMsg(agsXMPP.protocol.client.Message msg) { if (msg.From.Bare == this.strMonitorServer) { MsgHandle(msg.Body); } }
void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { try { // ignore empty messages (events) if (msg.Body == null || oldMmsg == msg || msg.Type == agsXMPP.protocol.client.MessageType.error) { return; } oldMmsg = msg; DataSet dsResults = new DataSet(); //Build a List of all Users to identify who is sending the message. dsResults = OSAESql.RunSQL("SELECT DISTINCT(object_name) FROM osae_v_object_property WHERE property_name = 'JabberID' and property_value = '" + msg.From.Bare + "' ORDER BY object_name"); gCurrentUser = dsResults.Tables[0].Rows[0][0].ToString(); OSAEObjectPropertyManager.ObjectPropertySet(gCurrentUser, "Communication Method", "Jabber", gCurrentUser); gCurrentAddress = msg.From.Bare; RecognitionResult rr = oRecognizer.EmulateRecognize(msg.Body); if (rr == null) { if (gDebug) { Log.Debug("INPUT: No Matching Pattern found!"); } } } catch (Exception ex) { Log.Error("Error in _OnMessage!", ex); } }
void conn_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { if (this.IsHandleCreated) { this.Invoke(new OnStanzaDelegate(OnStanza), msg); } }
//public AIMLProcessor Bot { get; set; } public string GetAnswer(agsXMPP.protocol.client.Message msg) { AIMLProcessor.Inputs.Insert(0, msg.Body); string tempCh = bot.FindTemplate(msg.Body, AIMLProcessor.Thats[0], "*"); if (string.IsNullOrEmpty(tempCh)) { Random rand = new Random(); int num = rand.Next(0, 2); switch (num) { case 0: tempCh = "Are you talking about an animal, vegetable or mineral??"; break; case 1: tempCh = "Be more specific"; break; case 2: tempCh = "What is it?"; break; default: tempCh = "Can you say it in other way?"; break; } } AIMLProcessor.Thats.Insert(0, tempCh); //Console.WriteLine(AIMLProcessor.Thats[0]); //chat = Console.ReadLine(); //client.SendMessage(AIMLProcessor.Thats[0], user.name); return(AIMLProcessor.Thats[0]); }
void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { // ignore empty messages (events) if (msg.Body == null) { return; } if (msg.Type == agsXMPP.protocol.client.MessageType.error) { return; } if (gDebug) { Log.Debug(String.Format("OnMessage from: {0} type: {1}", msg.From.Bare, msg.Type.ToString())); } if (gDebug) { Log.Debug("INPUT: " + msg.Body); } string pattern = Common.MatchPattern(msg.Body); if (pattern == string.Empty) { if (gDebug) { Log.Debug("INPUT: No Matching Pattern found!"); } } }
//void BuddyListChanged(object sender, BuddyListEventArgs args) //{ // switch (args.EventType) // { // case EventType.Add: // if (InvokeRequired) // Invoke(new Action(() => AddBuddy(args.Buddy))); // break; // case EventType.Update: // if (InvokeRequired) // Invoke(new Action(() => UpdateBuddy(args.Buddy))); // break; // case EventType.Remove: // if (InvokeRequired) // Invoke(new Action(() => RemoveBuddy(args.Buddy))); // break; // } //} //private void RemoveBuddy(Buddy buddy) //{ // if (BuddyList.Buddies.Contains(buddy)) // BuddyList.Buddies.Remove(buddy); //} //private void UpdateBuddy(Buddy buddy) //{ // var buddyItem = buddyListBox.Controls.OfType<BuddyListboxItem>(). // Where(i => i.Buddy.Equals(buddy)). // SingleOrDefault(); // if (buddyItem != null) // { // buddyItem.UpdateBuddyInformation(); // if (InvokeRequired) // Invoke(new Action(buddyListBox.Invalidate)); // else // buddyListBox.Invalidate(); // } //} private void OpenChatForm(Buddy buddy, Message msg = null) { if (!ChatForm.Singleton.OpenBuddies.Contains(buddy)) ChatForm.Singleton.AddChat(buddy, msg); ChatForm.Singleton.Show(); }
void conn_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { if (msg.To.User.Equals(this.conn.FullUserName)) { OnRecieveMessage(msg as WSMessage); } }
void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { if (msg.Body == null) { return; } }
public static GenericMessage ReadMessage(Message m) { if (!m.HasAttribute("MessageName")) { return(null); } var typeString = m.GetAttribute("MessageName"); var type = MessageTypes.FirstOrDefault(item => item.Name == typeString); if (type == null) { return(null); } var ret = Activator.CreateInstance(type) as GenericMessage; ret.Type = m.Type; ret.To = m.To; ret.From = m.From; ret.Subject = m.Subject; ret.Body = m.Body; ret.ChildNodes.Clear(); foreach (var i in m.ChildNodes) { ret.ChildNodes.Add(i as Node); } return(ret); }
private static agsXMPP.XmppClientConnection CreateClient() { var client = new agsXMPP.XmppClientConnection(); agsXMPP.Jid id = new agsXMPP.Jid("*****@*****.**"); client.Password = "******"; client.Username = id.User; client.Server = id.Server; client.AutoResolveConnectServer = true; client.OnMessage += (o, e) => { Console.WriteLine(e.Value); }; client.OnAuthError += (o, e) => { System.Diagnostics.Trace.TraceError(e.Value); }; client.OnError += (o, e) => { System.Diagnostics.Trace.TraceError(e.Message); }; client.OnLogin += (o) => { int i = 0; while (i<20) { agsXMPP.Jid to = new agsXMPP.Jid("*****@*****.**"); agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(to); msg.Body = "Hi how are you cmyworld"; msg.Type = agsXMPP.protocol.client.MessageType.chat; client.Send(msg); System.Threading.Thread.Sleep(2000); i++; } }; client.Open(); return client; }
private void button1_Click(object sender, EventArgs e) { var touser = textBox2.Text;; if (string.IsNullOrEmpty(textBox2.Text)) { errorMsgLabel.Text = "请输入name"; } else if (string.IsNullOrEmpty(textBox1.Text)) { errorMsgLabel.Text = "请输入发送的消息"; } else { if (xmppClient.IsLongined) { string msgGuid = Guid.NewGuid().ToString().Replace("-", ""); Jid to = new Jid(touser.ToString(), xmppClient.ServerJid.Server, string.Empty); agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.From = xmppClient.LocalJid; msg.To = new Jid(touser.ToString(), xmppClient.ServerJid.Server, string.Empty); msg.Body = EncryptUtil.EncryptBASE64ByGzip(textBox1.Text); msg.Language = "BASE64"; msg.Id = msgGuid; xmppClient.XmppConnection.Send(msg); appendText("send :" + textBox1.Text + "\n"); string sql = string.Format("INSERT INTO [dbo].[record] ([msg] ,[guid]) VALUES ('{0}','{1}')", textBox1.Text, msgGuid); //dbm.ExecuteSql(sql); } else { errorMsgLabel.Text = "未登录或者链接错误"; } } }
public void OnPrivateMessage(agsXMPP.protocol.client.Message msg) { try { agsXMPP.protocol.x.muc.User x = (agsXMPP.protocol.x.muc.User)msg.SelectSingleElement(typeof(agsXMPP.protocol.x.muc.User)); if (x != null && x.Invite != null) { Program.Jabber.muc.handleInvitation(msg, x.Invite); return; } // Ignore Chatstate notifications if no conversation is open if (!msg.HasTag("body") && !this.HasWindow(msg.From)) { return; } Jid relevantJid = msg.From; // XEP-0280, Message Carbons var carbonsSent = msg.SelectSingleElement("sent", JabberService.URN_CARBONS); var carbonsReceived = msg.SelectSingleElement("received", JabberService.URN_CARBONS); if (carbonsSent != null) { msg = (agsXMPP.protocol.client.Message)carbonsSent.SelectSingleElement("message", true); relevantJid = msg.To; } else if (carbonsReceived != null) { msg = (agsXMPP.protocol.client.Message)carbonsReceived.SelectSingleElement("message", true); relevantJid = msg.From; } string dt = JabberService.GetMessageDt(msg); if (msg.HasTag("body")) { Program.db.InsertMessage(relevantJid.Bare, msg.Id, msg.From, msg.Body, dt); } DirectMessageForm dmfrm = GetWindow(relevantJid); dmfrm.onMessage(msg); dmfrm.Show(); if (msg.HasTag("body")) { dmfrm.Activate(); } else { if (!String.IsNullOrEmpty(msg.Subject)) { dmfrm.onNotice("Subject set: " + msg.Subject.Replace("<", "<")); } else if (msg.Error != null) { dmfrm.onNotice("An error occured: " + msg.Error.ToString().Replace("<", "<")); } //else dmfrm.onNotice("Unknown message stanza: " + msg.ToString().Replace("<", "<")); } } catch (Exception ex) { return; } }
void conn_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { WSMessage m = msg as WSMessage; if (m.Delay != null) { } }
public void SendNotification(Receiver receiver,Notification notification) { agsXMPP.Jid to = new agsXMPP.Jid(receiver.Email); agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(to); msg.Body = CreateBody(notification); msg.Type = agsXMPP.protocol.client.MessageType.chat; _jabberClient.Send(msg); }
public void startChat(agsXMPP.protocol.client.Message msg, FacebookUser user) { if (!UserExist(user)) { AddUser(user); } WriteToUser(msg, user); }
private void sendChatstate(agsXMPP.protocol.extensions.chatstates.Chatstate state) { lastChatstate = state; var msg = new agsXMPP.protocol.client.Message(new Jid(this.otherEnd.Bare), Program.Jabber.conn.MyJID); msg.Type = agsXMPP.protocol.client.MessageType.chat; msg.Chatstate = state; Program.Jabber.conn.Send(msg); }
//void BuddyListChanged(object sender, BuddyListEventArgs args) //{ // switch (args.EventType) // { // case EventType.Add: // if (InvokeRequired) // Invoke(new Action(() => AddBuddy(args.Buddy))); // break; // case EventType.Update: // if (InvokeRequired) // Invoke(new Action(() => UpdateBuddy(args.Buddy))); // break; // case EventType.Remove: // if (InvokeRequired) // Invoke(new Action(() => RemoveBuddy(args.Buddy))); // break; // } //} //private void RemoveBuddy(Buddy buddy) //{ // if (BuddyList.Buddies.Contains(buddy)) // BuddyList.Buddies.Remove(buddy); //} //private void UpdateBuddy(Buddy buddy) //{ // var buddyItem = buddyListBox.Controls.OfType<BuddyListboxItem>(). // Where(i => i.Buddy.Equals(buddy)). // SingleOrDefault(); // if (buddyItem != null) // { // buddyItem.UpdateBuddyInformation(); // if (InvokeRequired) // Invoke(new Action(buddyListBox.Invalidate)); // else // buddyListBox.Invalidate(); // } //} private void OpenChatForm(Buddy buddy, Message msg = null) { if (!ChatForm.Singleton.OpenBuddies.Contains(buddy)) { ChatForm.Singleton.AddChat(buddy, msg); } ChatForm.Singleton.Show(); }
void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { try { // ignore empty messages (events) if (msg.Body == null || oldMmsg == msg || msg.Type == agsXMPP.protocol.client.MessageType.error) { return; } oldMmsg = msg; string[] jIDRaw = msg.From.ToString().Split('/'); string jID = jIDRaw[0]; OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByPropertyValue("JabberID", jID); if (objects != null) { foreach (OSAEObject oObj in objects) { if (oObj.Alias.Length > 0) { gCurrentUser = oObj.Alias; } else { gCurrentUser = oObj.Name; } } } else { Log.Info("Message from Unknown address: " + jID); } if (gDebug) { Log.Debug("Current User set to: " + gCurrentUser); } OSAEObjectPropertyManager.ObjectPropertySet(gCurrentUser, "Communication Method", "Jabber", gAppName); gCurrentAddress = jID; if (msg.Body.EndsWith("?") || msg.Body.EndsWith("!") || msg.Body.EndsWith(".")) { msg.Body = msg.Body.Substring(0, msg.Body.Length - 1); } RecognitionResult rr = oRecognizer.EmulateRecognize(msg.Body); if (rr == null) { if (gDebug) { Log.Debug("INPUT: No Matching Pattern found!"); } } } catch (Exception ex) { Log.Error("Error in _OnMessage!", ex); } }
public void _xmppConnection_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { _bot = new AIMLChatBot(); if (!string.IsNullOrEmpty(msg.Body)) { // Get the Jabber username. agsXMPP.Jid JID = new Jid(msg.From.Bare); // Get the context User from the Jabber username (allows our bot to track conversations per user). User user = CommonManager.GetUser(msg.From.Bare, _bot); // Let our chat bot respond to the message. msg.Body = _sanitize(msg.Body) + "\r\n" + DateTime.Now.ToString() + "\r\n"; string response = HandleMessage(msg.Body, user); // Setup a response event. _xmppConnection.MessageGrabber.Add(JID, new agsXMPP.Collections.BareJidComparer(), new MessageCB(ChatResponseReceived), null); // Create a new message. agsXMPP.protocol.client.Message newmsg = new agsXMPP.protocol.client.Message(); newmsg.Type = agsXMPP.protocol.client.MessageType.chat; newmsg.To = JID; newmsg.Body = response; // Send response. //FullName if (newmsg.ToString().IndexOf("$1") > 0) { newmsg.Body = newmsg.Body.ToString().Replace("$1", _getattribute(GetAttribute.FullName, msg.From)); } //FirstName if (newmsg.ToString().IndexOf("$2") > 0) { newmsg.Body = newmsg.Body.ToString().Replace("$2", _getattribute(GetAttribute.FirstName, msg.From)); } //LastName if (newmsg.ToString().IndexOf("$3") > 0) { newmsg.Body = newmsg.Body.ToString().Replace("$3", _getattribute(GetAttribute.LastName, msg.From)); } //Email if (newmsg.ToString().IndexOf("$4") > 0) { newmsg.Body = newmsg.Body.ToString().Replace("$4", _getattribute(GetAttribute.Email, msg.From)); } //Username if (newmsg.ToString().IndexOf("$5") > 0) { newmsg.Body = newmsg.Body.ToString().Replace("$5", _getattribute(GetAttribute.Username, msg.From)); } _xmppConnection.Send(newmsg); // This is called for any message received. log(_getattribute(GetAttribute.FullName, msg.From) + ": " + msg.Body + "\r\n" + "WAHITDesk: " + newmsg.Body + "\r\n" + DateTime.Now.ToString()); } }
private static void Send(string txt, string user) { // Send a message agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = agsXMPP.protocol.client.MessageType.chat; msg.To = new Jid(user); msg.Body = txt; xmppCon.Send(msg); }
public MucMessage(agsXMPP.protocol.client.Message message, MucContact sender) { _message = message; _sender = sender; if (_message.XDelay != null) { DateTime = new RelativeOldness(_message.XDelay.Stamp); } }
private void sendMessage(string name, string address, string message) { Log.Info("-> " + name + ": " + message + " (" + address + ")"); // Send a message agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = agsXMPP.protocol.client.MessageType.chat; msg.To = new Jid(address); msg.Body = message; xmppCon.Send(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(); logger.Info("Message received {0}: {1}", user, content); } }
private void sendMessage(string message, string contact) { osae.AddToLog("Sending message: '" + message + "' to " + contact, false); // Send a message agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = agsXMPP.protocol.client.MessageType.chat; msg.To = new Jid(contact); msg.Body = message; xmppCon.Send(msg); }
private void sendMessage(string message, string contact) { this.Log.Debug("OUTPUT: '" + message + "' to " + contact); // Send a message agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = agsXMPP.protocol.client.MessageType.chat; msg.To = new Jid(contact); msg.Body = message; xmppCon.Send(msg); }
private void cmdSend_Click(object sender, EventArgs e) { // Send a message agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = agsXMPP.protocol.client.MessageType.chat; msg.To = new Jid(txtJabberIdReceiver.Text); msg.Body = txtMessage.Text; xmppCon.Send(msg); txtMessage.Text = ""; }
public void Send(string message, bool urgent) { if (open || urgent) { if (!open) { message = "Sent As Urgent: " + message; } agsXMPP.protocol.client.Message mesg = new agsXMPP.protocol.client.Message(new Jid(expectedUser), agsXMPP.protocol.client.MessageType.chat, message); connection.Send(mesg); } }
private void cmdSend_Click(object sender, EventArgs e) { // Send a message agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = agsXMPP.protocol.client.MessageType.chat; msg.To = new Jid(txtJabberIdReceiver.Text); msg.Body = txtMessage.Text; xmppCon.Send(msg); txtMessage.Text = ""; }
private void WriteToUser(agsXMPP.protocol.client.Message msg, FacebookUser user) { FacebookDoChat ch = FindChat(user); if (ch == null) { return; // it cant be that user is not found } string answer = ch.GetAnswer(msg); client.SendMessage(answer, user.name); }
void XmppClient_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { var body = ""; var subject = ""; if (msg != null) { if ("BASE64".Equals(msg.Language) && !string.IsNullOrEmpty(msg.Body)) { body = FoxundermoonLib.Encrypt.EncryptUtil.DecryptBASE64ByGzip(msg.Body); } else { body = msg.Body; } subject = msg.Subject; Message msgEntity = new Message(); try { if (!string.IsNullOrEmpty(body)) { msgEntity.SetJsonMessage(body); } if (!string.IsNullOrEmpty(subject)) { msgEntity.SetJsonCommand(subject); } if (OnMessage != null) { OnMessage(msgEntity); } } catch (Exception e) { var err = new ErrorEvent(e.Message); err.ErrT = ErrorEvent.ErrorType.ParseMessageFailed; if (OnError != null) { OnError(err); } } if (msgEntity.Command.NeedResponse) { Message response = new Message(); response.Command.Name = Cmd.Response; response.ToUser = msgEntity.FromUser; response.FromUser = msgEntity.ToUser; SendMessage(response); } } }
void xmppClient_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { //Invoke(new MethodInvoker(delegate() //{ // richTextBox1.AppendText(msg.From + "\n" + msg.Body); //})); string received = EncryptUtil.DecryptBASE64ByGzip(msg.Body); string sql = string.Format(@"UPDATE [dbo].[record] SET [status] ={0} where [guid]='{1}'", 1, msg.Id); //dbm.ExecuteSql(sql); this.SafeInvoke(() => { richTextBox1.AppendText(msg.From + "\n\r" + received + "\n"); }); }
private string sendMessage(string text) { //if (checkBox1.Checked) { // otr_ses.EncryptMessage(this.otherEnd.ToString(), text); //} else { var msg = new agsXMPP.protocol.client.Message(this.otherEnd.Bare, Program.Jabber.conn.MyJID, agsXMPP.protocol.client.MessageType.chat, text); msg.Id = Guid.NewGuid().ToString(); msg.Chatstate = agsXMPP.protocol.extensions.chatstates.Chatstate.active; Program.Jabber.conn.Send(msg); //} Program.db.InsertMessage(room.RoomName, msg.Id, msg.From, msg.Body, ChatDatabase.GetNowString()); messageView1.addMessageToView(msg.From, msg.Body, DateTime.Now, null, msg.From, msg.Id); return(msg.Id); }
void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { // ignore empty messages (events) if (msg.Body == null) { return; } this.Log.Debug(String.Format("OnMessage from:{0} type:{1}", msg.From.Bare, msg.Type.ToString())); this.Log.Debug("Message: " + msg.Body); string pattern = Common.MatchPattern(msg.Body); // if (pattern != string.Empty) // { //OSAEScriptManager.RunPatternScript(pattern, msg.From.Bare, "Jabber"); // } }
void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { // ignore empty messages (events) if (msg.Body == null) { return; } osae.AddToLog(String.Format("OnMessage from:{0} type:{1}", msg.From.Bare, msg.Type.ToString()), false); osae.AddToLog("Message: " + msg.Body, false); string pattern = osae.MatchPattern(msg.Body); if (pattern != "") { osae.MethodQueueAdd("Script Processor", "NAMED SCRIPT", pattern, msg.From.Bare); } }
private string GetUser(Message msg) { string user; if (msg.Type == MessageType.groupchat) { user = msg.From.Resource; } else { if (!_roster.TryGetValue(msg.From.User, out user)) { user = "******"; } } return(user); }
public void SendMessage(Message m) { agsXMPP.protocol.client.Message xmppMsg = new agsXMPP.protocol.client.Message(); xmppMsg.Language = "BASE64"; xmppMsg.Subject = m.GetJsonCommand(); xmppMsg.Body = FoxundermoonLib.Encrypt.EncryptUtil.EncryptBASE64ByGzip(m.ToJson()); if (null == m.FromUser || string.IsNullOrEmpty(m.FromUser.Name)) { m.FromUser = new User(XmppClient.Name, Resource); } if (null == m.ToUser || string.IsNullOrEmpty(m.ToUser.Name)) { m.ToUser = new User("0", "server"); } xmppMsg.From = new agsXMPP.Jid(m.FromUser.Name + "@" + MessageServerHost + ":" + MessageServerPort + "/" + m.FromUser.Resource); xmppMsg.To = new agsXMPP.Jid(m.ToUser.Name + "@" + MessageServerHost + ":" + MessageServerPort + "/" + m.ToUser.Resource); XmppClient.XmppConnection.Send(xmppMsg); }
public void AddMessage(Message message) { this.Resource = message.From.Resource; SetThread(message.Thread ?? message.CreateNewThread()); AddConvoMessage(message.Body); }
private void sendMessage(string message, string contact) { logging.AddToLog("Sending message: '" + message + "' to " + contact, false); // Send a message agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = agsXMPP.protocol.client.MessageType.chat; msg.To = new Jid(contact); msg.Body = message; xmppCon.Send(msg); }
void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { try { // ignore empty messages (events) if (msg.Body == null || oldMmsg == msg || msg.Type == agsXMPP.protocol.client.MessageType.error) return; oldMmsg = msg; string[] jIDRaw = msg.From.ToString().Split('/'); string jID = jIDRaw[0]; OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByPropertyValue("JabberID", jID); if (objects != null) { foreach (OSAEObject oObj in objects) { if (oObj.Alias.Length > 0) gCurrentUser = oObj.Alias; else gCurrentUser = oObj.Name; } } else Log.Info("Message from Unknown address: " + jID); if (gDebug) Log.Debug("Current User set to: " + gCurrentUser); OSAEObjectPropertyManager.ObjectPropertySet(gCurrentUser, "Communication Method", "Jabber", gAppName); gCurrentAddress = jID; if (msg.Body.EndsWith("?") || msg.Body.EndsWith("!") || msg.Body.EndsWith(".")) msg.Body = msg.Body.Substring(0, msg.Body.Length -1); RecognitionResult rr = oRecognizer.EmulateRecognize(msg.Body); if (rr == null) if (gDebug) Log.Debug("INPUT: No Matching Pattern found!"); } catch (Exception ex) { Log.Error("Error in _OnMessage!", ex); } }
private void sendMessage(string name, string address, string message) { Log.Info("-> " + name + ": " + message + " (" + address + ")"); // Send a message agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = agsXMPP.protocol.client.MessageType.chat; msg.To = new Jid(address); msg.Body = message; xmppCon.Send(msg); }
public void sendmessage(string to, string mesg) { agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = agsXMPP.protocol.client.MessageType.chat; msg.To = new Jid(to); msg.Body = mesg; Form1.staticVar.xmpp.Send(msg); }
void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { try { // ignore empty messages (events) if (msg.Body == null || oldMmsg == msg || msg.Type == agsXMPP.protocol.client.MessageType.error) return; oldMmsg = msg; DataSet dsResults = new DataSet(); //Build a List of all Users to identify who is sending the message. dsResults = OSAESql.RunSQL("SELECT DISTINCT(object_name) FROM osae_v_object_property WHERE property_name = 'JabberID' and property_value = '" + msg.From.Bare + "' ORDER BY object_name"); gCurrentUser = dsResults.Tables[0].Rows[0][0].ToString(); OSAEObjectPropertyManager.ObjectPropertySet(gCurrentUser, "Communication Method", "Jabber", gCurrentUser); gCurrentAddress = msg.From.Bare; RecognitionResult rr = oRecognizer.EmulateRecognize(msg.Body); if (rr == null) if (gDebug) Log.Debug("INPUT: No Matching Pattern found!"); } catch (Exception ex) { Log.Error("Error in _OnMessage!", ex); } }
private void SendNotification(Notification data) { agsXMPP.Jid to = new agsXMPP.Jid("*****@*****.**"); agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(to); msg.Body = RenderPartialViewToString("NotificationMessage", data); msg.Type = agsXMPP.protocol.client.MessageType.chat; JabberClient.Open(); JabberClient.Send(msg); }
private void sendMessage(string message, string contact) { if (gDebug) Log.Debug("OUTPUT: '" + message + "' to " + contact); // Send a message agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.Type = agsXMPP.protocol.client.MessageType.chat; msg.To = new Jid(contact); msg.Body = message; xmppCon.Send(msg); }
private static void xmpp_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { // This is called for any message received. Console.WriteLine("Received: " + msg.Body); // Get the Gmail username. agsXMPP.Jid JID = new Jid(msg.From.Bare); // Get the context User from the Gmail username (allows our bot to track conversations per user). User user = CommonManager.GetUser(msg.From.Bare, _bot); // Let our chat bot respond to the message. string response = HandleMessage(msg.Body, user); // Setup a response event. _xmppConnection.MessageGrabber.Add(JID, new agsXMPP.Collections.BareJidComparer(), new MessageCB(ChatResponseReceived), null); // Create a new message. agsXMPP.protocol.client.Message newmsg = new agsXMPP.protocol.client.Message(); newmsg.Type = agsXMPP.protocol.client.MessageType.chat; newmsg.To = JID; newmsg.Body = response; // Send response. _xmppConnection.Send(newmsg); }
private void OnMessage(object sender, Message msg) { if (String.IsNullOrEmpty(msg.Body)) return; var adapterUser = GetUser(msg); if (MessageIsFromRobot(adapterUser)) return; var user = new User(msg.Id, adapterUser, msg.From.Bare, Name); Robot.Receive(new TextMessage(user, msg.Body)); }
private string GetUser(Message msg) { string user; if (msg.Type == MessageType.groupchat) { user = msg.From.Resource; } else { if (!_roster.TryGetValue(msg.From.User, out user)) { user = "******"; } } return user; }