Advertisement
Guest User

Whole Code

a guest
Dec 1st, 2015
750
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using SKYPE4COMLib;
  11.  
  12. namespace TutorialOne
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         private Skype MySkype = new Skype();
  17.         public Form1()
  18.         {
  19.             InitializeComponent();
  20.            
  21.         }
  22.  
  23.         void MySkype_MessageStatus(ChatMessage pMessage, TChatMessageStatus Status)
  24.         {
  25.             if (pMessage.Body[0].ToString() == "@") // Check if it is a command, @ can be anything that you want.
  26.             {
  27.                 string Command = pMessage.Body.Substring(1, pMessage.Body.Length - 1); // Basicaly remove @ from it.
  28.                 if (pMessage.Sender.Handle != MySkype.CurrentUserHandle) // Check if the sender is not yourself.
  29.                     MySkype.SendMessage(pMessage.Sender.Handle, ProcessCommand(Command)); // Send the message back.
  30.                 else
  31.                     MessageBox.Show("Message not sent.");
  32.             }
  33.         }
  34.  
  35.         private string ProcessCommand(string cmd)
  36.         {
  37.             switch (cmd)
  38.             {
  39.                 case "help":
  40.                     return "The commands are: blablabla...";
  41.                 case "LOL":
  42.                     return "(chuckle)";
  43.                 default:
  44.                     return "This is not a command.\nSend '@help' for help.";
  45.             }
  46.         }
  47.  
  48.         private void ConnectButton_Click(object sender, EventArgs e)
  49.         {
  50.             MySkype.Attach(5, false);
  51.             MessageBox.Show("Hello " + MySkype.CurrentUserHandle);
  52.             MySkype.MessageStatus += MySkype_MessageStatus;
  53.         }
  54.  
  55.         private void SendMessageButton_Click(object sender, EventArgs e)
  56.         {
  57.             MySkype.SendMessage("guibbsbr", "I am using your source :)");
  58.             // You could also use a TextBox to get both variables,
  59.             // just make sure to check if them are not empty/null.
  60.         }
  61.  
  62.         private void Form1_Load(object sender, EventArgs e)
  63.         {
  64.            
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement