Advertisement
buesingniklas

Untitled

Jul 12th, 2015
2,584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.91 KB | None | 0 0
  1. Imports System.Windows.Forms
  2. Imports SKYPE4COMLib
  3. ' Our COM library
  4.  
  5. Public Class Form1
  6.     Dim Skype As New Skype
  7.     Dim i As Integer
  8.  
  9.     Private Const trigger As String = "!"
  10.     ' Say !help
  11.     Private Const nick As String = "smuuuuuuu's Bot"
  12.  
  13.  
  14.  
  15.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
  16.         Dim Skype = New SKYPE4COMLib.Skype
  17.         Dim Skype_ As New Skype
  18.         Skype.Attach(7, False)
  19.         AddHandler Skype.MessageStatus, AddressOf skype_MessageStatus
  20.     End Sub
  21.     Private Sub skype_MessageStatus(ByVal msg As ChatMessage, ByVal status As TChatMessageStatus)
  22.         ' Proceed only if the incoming message is a trigger
  23.         If msg.Body.IndexOf(trigger) = 0 Then
  24.             ' Remove trigger string and make lower case
  25.             Dim command As String = msg.Body.Remove(0, trigger.Length).ToLower()
  26.  
  27.             ' Send processed message back to skype chat window
  28.             Skype.SendMessage(msg.Sender.Handle, Convert.ToString(nick & Convert.ToString(" Says: ")) & ProcessCommand(command))
  29.         End If
  30.  
  31.     End Sub
  32.  
  33.     Private Function ProcessCommand(ByVal str As String) As String
  34.         Dim result As String
  35.         Select Case str
  36.             Case "hello"
  37.                 result = "Hello!"
  38.  
  39.             Case "help"
  40.                 result = "!help " & vbLf & " !hello " & vbLf & " !date " & vbLf & " !time " & vbLf & " !who"
  41.  
  42.             Case "date"
  43.                 result = "My Current Date is: " + DateTime.Now.ToLongDateString()
  44.  
  45.             Case "time"
  46.                 result = "My Current Time is: " + DateTime.Now.ToLongTimeString()
  47.  
  48.             Case "who"
  49.                 result = "I'm a magical piece of smuuuuuuu's code which became alive and want's to be your friend!"
  50.  
  51.             Case Else
  52.                 result = "Sorry, I do not recognize your command"
  53.  
  54.         End Select
  55.  
  56.         Return result
  57.     End Function
  58. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement