Home > C > Skype – Getting started with C#

Skype – Getting started with C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SKYPE4COMLib;

namespace SkypeBing
public partial class Form1 : Form
private Skype skype;
private const string trigger = "!"; // say help
private const string nick = "BOT";

public Form1()

private void Form1_Load(object sender, EventArgs e)
skype = new Skype();
// use skype protocol 7
skype.Attach(7, false);
// listen
skype.MessageStatus += new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);

void skype_MessageStatus(ChatMessage pMessage, TChatMessageStatus Status)
// proceed only if the incoming message is a trigger
if (pMessage.Body.IndexOf(trigger) == 0)
// remove trigger string and make lower case
string command = pMessage.Body.Remove(0, trigger.Length).ToLower();

// send processed message back to skype chat window
skype.SendMessage(pMessage.Sender.Handle, nick +
" Says: " + ProcessCommand(command));

private string ProcessCommand(string str)
string result;
switch (str)
case "hello":
result = "Hello!";
case "help":
result = "Sorry no help";
result = "default....";



return result;
Categories: C
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: