|
Post by shyrana on Feb 27, 2012 15:26:01 GMT -8
I would like to extend the auto friendship offer example in the Demo plugin in a way that it sends a thank you IM to the sender. How can I get access to the FromAgentName?
void Notification_OnNotificationDisplayed(object sender, NotificationEventArgs e) { // Example: auto accept friendship offers after 2 seconds of "thinking" ;) if (e.Type == NotificationType.FriendshipOffer) { Thread.Sleep(2000); // Execute on GUI thread Instance.MainForm.BeginInvoke( new MethodInvoker(() => {e.Buttons[0].PerformClick(); }) );
// Here I would like to get the FromAgentName // How can this be done?
} }
I'm not interested in implementation details regarding the IM to be sent. I'm only interested in how I can get the FromAgentName inside the Notification_OnNotificationDisplayed method.
Note: I'm not totally new to C# but havent written any code the last 4 years.
|
|
|
Post by Latif Khalifa on Feb 29, 2012 19:50:13 GMT -8
That bit deals with the GUI of the notification. Better place to do what you wanted would be to do it in the IM handler. There are a couple of lines that read
// We need to filter out all sorts of things that come in as a instante message if (e.IM.Dialog == InstantMessageDialog.MessageFromAgent // Message is not notice, inv. offer, etc etc
You can insert immediately before that:
if (e.IM.Dialog == InstantMessageDialog.FriendshipOffered) { // e.IM.FromAgentID and e.IM.FromAgentName availabe here return; }
|
|
|
Post by shyrana on Mar 1, 2012 4:46:19 GMT -8
Got it Thank you.
|
|