MSN robot

xiaoxiao2021-03-06  41

Suddenly I want to be a MSN robot, in http://www.hypothetic.org/docs/msn/resources/projects.php? There are a lot of examples, but not all have source code, can only look at the eyes. Dotmsn? Find a library written by .NET. The call is very simple.

// Log in

Private void startmsn ()

{

IF ((TXTemail.Text! = ") || (txtpsw.text! =" "))

{

Msn.connect (txtemail.text, txtpsw.text);

IF (msn.connected)

{

// setup callback function

Msn.contactonline = new dotmsn.Messenger.contactonlineHandler (msn_contactonline);

Msn.contactoffline = new dotmsn.Messenger.ContactofflineHandler (onContactoffline);

Msn.synchronizationCompleted = new dotmsn.Messenger.synchronizationCompletedHandler (OnsynchronizationCompleted);

Msn.MessageReceived = new dotmsn.Messenger.MessageReceivedHandler (OnMessageReceive);

Msn.conversationCreated = new dotmsn.Messenger.conversationCreated;

Msn.synchronizelist ();

TXTLOG.TEXT = "MSN Connected / R / N" TXTLOG.TEXT;

}

}

}

// Logout

Private void endmsn ()

{

IF (msn.connected)

{

Msn.closeConnection ();

IF (! msn.connected)

{

TXTLOG.TEXT = "MSN Disconnected / R / N" txtLog.Text;

}

}

}

// Successfully Synchronize Contact List

Private Void OnsynchronizationCompleted (Messenger Sender, Eventargs E)

{

Msn.setstatus (msnstatus.online);

TXTLOG.TEXT = "set status: online / r / n" txtlog.text;

FillListView (Lservefl, Msn.getlistence (Msnlist.Forwardlist);

FillListView (Lstviewrl, Msn.reverselist);

FillListView (Lstviewbl, Msn.blockedList);

FillListView (Lstviewal, msn.allowedlist);

}

/ / Contact launch

Private void MSN_Contactonline (Messenger Sender, ContactEventArgs E)

{

TXTLOG.TEXT = E.Contact.name "Status:" E.Contact.status.tostring () "/ r / n" txtlog.text; refreshlistView (LstviewFL, E.CONTACT);

RefreshlistView (Lstviewrl, E.Contact);

RefreshlistView (Lstviewbl, E.Contact);

RefreshlistView (Lstviewal, E.CONTACT);

}

/ / Contact Late

Private void oncontactoffline (Messenger Sender, ContactEventArgs E)

{

TXTLOG.TEXT = E.Contact.name "status:" E.Contact.status.tostring () "/ r / n" txtlog.text;

RefreshlistView (LstviewFL, E.CONTACT);

RefreshlistView (Lstviewrl, E.Contact);

RefreshlistView (Lstviewbl, E.Contact);

RefreshlistView (Lstviewal, E.CONTACT);

}

// Initialize the contact list

Private Void FillListView (ListView Lst, Messenger.ContactList.Listence "

{

Lst.clear ();

Foreach (Contact Contact in ContactList)

{

ListViewItem item = new listviewItem (Contact.Name "status:" contact.status.tostring ());

Item.tag = contact;

Lst.Items.Add (item);

}

}

// Refresh the contact list

Private Void RefreshlistView (ListView LST, Contact Contact)

{

Foreach (ListViewItem Item in Lst.Items)

{

Contact itemtag = (contact) item.tag;

IF (itemtag.mail.equals (contact.mail))

{

Item.text = contact.name "status:" contact.status.tostring ();

Return;

}

}

// listviewitem newItem = new listviewItem (Contact.Name "status:" contact.status.tostring ());

// newItem.tag = contact;

// Lst.Items.Add (newItem);

}

// Add to dialogue

Private Void OnConversationCreated (Messenger Sender, ConversationEventArgs E)

{

TXTLOG.TEXT = "ConversationCreated / R / N" txtlog.text;

E.Conversation.contactJoin = new dotmsn.conversation.contactjoinhandler (ContactJoin); E.Conversation.MessageReceid = new dotmsn.conversation.MessageReceiveDHandler (MessageReceIved);

E.Conversation.UserTyping = new dotmsn.conversation.UserTypingHandler

}

#Region In the title bar Show contact email

Private void LstviewFl_selectedIndexchanged (Object Sender, System.EventArgs E)

{

Displaymail (ListView) Sender;

}

Private void LstviewRl_selectedIndexchanged (Object Sender, System.EventArgs E)

{

Displaymail (ListView) Sender;

}

Private void Lstviewal_selectedIndexchanged (Object Sender, System.EventArgs E)

{

Displaymail (ListView) Sender;

}

Private void LstviewBl_selectedIndexchanged (Object Sender, System.EventArgs E)

{

Displaymail (ListView) Sender;

}

Private Void Displaymail (ListView LST)

{

IF (Lst.SelectedItems.count == 1)

{

Contact Contact = (contact) Lst.SelectedItems [0] .tag;

THIS.TEXT = Contact.mail;

}

}

#ndregion

// Add to dialogue

Private Void ContactJoin (Conversation Sender, ContactEventArgs E)

{

TXTLOG.TEXT = E.Contact.name " E.Contact.mail " "ContactJoin / R / N" txtlog.text;

}

//Received the news

Private void MessageReceived (Conversation Sender, MessageEventArgs E)

{

TXTLOG.TEXT = E.Sender.Name " E.SENDER.MAIL " " E.MESSAGE.TEXT " / R / N " TXTLOG.TEXT;

Sender.sendMessage (E.MESSAGE.TEXT);

}

// Extunction input

Private Void UserTyping (Conversation Sender, ContactEventArgs E)

{

TXTLOG.TEXT = E.Contact.name " E.Contact.mail " " " IS type / r / n " txtLog.Text;

}

转载请注明原文地址:https://www.9cbs.com/read-116281.html

New Post(0)