Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using SKYPE4COMLib;
- namespace TutorialOne
- {
- public partial class Form1 : Form
- {
- private Skype MySkype = new Skype();
- public Form1()
- {
- InitializeComponent();
- }
- void MySkype_MessageStatus(ChatMessage pMessage, TChatMessageStatus Status)
- {
- if (pMessage.Body[0].ToString() == "@") // Check if it is a command, @ can be anything that you want.
- {
- string Command = pMessage.Body.Substring(1, pMessage.Body.Length - 1); // Basicaly remove @ from it.
- if (pMessage.Sender.Handle != MySkype.CurrentUserHandle) // Check if the sender is not yourself.
- MySkype.SendMessage(pMessage.Sender.Handle, ProcessCommand(Command)); // Send the message back.
- else
- MessageBox.Show("Message not sent.");
- }
- }
- private string ProcessCommand(string cmd)
- {
- switch (cmd)
- {
- case "help":
- return "The commands are: blablabla...";
- case "LOL":
- return "(chuckle)";
- default:
- return "This is not a command.\nSend '@help' for help.";
- }
- }
- private void ConnectButton_Click(object sender, EventArgs e)
- {
- MySkype.Attach(5, false);
- MessageBox.Show("Hello " + MySkype.CurrentUserHandle);
- MySkype.MessageStatus += MySkype_MessageStatus;
- }
- private void SendMessageButton_Click(object sender, EventArgs e)
- {
- MySkype.SendMessage("guibbsbr", "I am using your source :)");
- // You could also use a TextBox to get both variables,
- // just make sure to check if them are not empty/null.
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement