Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Windows.Forms
- Imports SKYPE4COMLib
- ' Our COM library
- Public Class Form1
- Dim Skype As New Skype
- Dim i As Integer
- Private Const trigger As String = "!"
- ' Say !help
- Private Const nick As String = "smuuuuuuu's Bot"
- Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
- Dim Skype = New SKYPE4COMLib.Skype
- Dim Skype_ As New Skype
- Skype.Attach(7, False)
- AddHandler Skype.MessageStatus, AddressOf skype_MessageStatus
- End Sub
- Private Sub skype_MessageStatus(ByVal msg As ChatMessage, ByVal status As TChatMessageStatus)
- ' Proceed only if the incoming message is a trigger
- If msg.Body.IndexOf(trigger) = 0 Then
- ' Remove trigger string and make lower case
- Dim command As String = msg.Body.Remove(0, trigger.Length).ToLower()
- ' Send processed message back to skype chat window
- Skype.SendMessage(msg.Sender.Handle, Convert.ToString(nick & Convert.ToString(" Says: ")) & ProcessCommand(command))
- End If
- End Sub
- Private Function ProcessCommand(ByVal str As String) As String
- Dim result As String
- Select Case str
- Case "hello"
- result = "Hello!"
- Case "help"
- result = "!help " & vbLf & " !hello " & vbLf & " !date " & vbLf & " !time " & vbLf & " !who"
- Case "date"
- result = "My Current Date is: " + DateTime.Now.ToLongDateString()
- Case "time"
- result = "My Current Time is: " + DateTime.Now.ToLongTimeString()
- Case "who"
- result = "I'm a magical piece of smuuuuuuu's code which became alive and want's to be your friend!"
- Case Else
- result = "Sorry, I do not recognize your command"
- End Select
- Return result
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement