Created
July 21, 2010 09:20
-
-
Save shamun/484257 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// last tested code, but it show me nothing. And skype never stay itself, automatic the skype gets crashed. | |
// Code goes here... | |
using SKYPE4COMLib; | |
using System; | |
namespace Example | |
{ | |
class SkypeExample | |
{ | |
private Skype _skype = new Skype(); | |
public static void Main() | |
{ | |
var skype = new SkypeExample(); | |
string input = string.Empty; | |
while (!input.Equals("close")) | |
{ | |
input = Console.ReadLine(); | |
if (!string.IsNullOrEmpty(input)) | |
skype.MakeFriend(input); | |
} | |
} | |
public SkypeExample() | |
{ | |
//_skype = new Skype(); | |
_skype.MessageStatus += OnMessage; | |
//_skype._ISkypeEvents_Event_AttachmentStatus += OnAttach; | |
_skype.Attach(7, false); | |
} | |
private void OnAttach(TAttachmentStatus status) | |
{ | |
// this app was successfully attached to skype | |
} | |
private void OnMessage(ChatMessage pmessage, TChatMessageStatus status) | |
{ | |
// dont do anything if the message is not received (i.e. we are sending a emssage) | |
if (status != TChatMessageStatus.cmsReceived) | |
return; | |
// simple echo service. | |
_skype.get_Chat(pmessage.ChatName).SendMessage(pmessage.Body); | |
} | |
public bool MakeFriend(string handle) | |
{ | |
for (int i = 1; i <= _skype.Friends.Count; i++) | |
{ | |
if (_skype.Friends[i].Handle == handle) | |
return true; | |
} | |
UserCollection collection = _skype.SearchForUsers(handle); | |
if (collection.Count >= 1) | |
collection[1].BuddyStatus = TBuddyStatus.budPendingAuthorization; | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment