VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsPlugin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True

Option Base 0
Option Explicit
Option Compare Text
Private MainForm As Object
Private Bot As Object
Private BotIndex As Integer
Private iTunes As iTunesApp
Private Loaded As Boolean

Private Sub Class_Terminate()
    Set Bot = Nothing
    Set MainForm = Nothing
End Sub

Public Sub RunPlugin(ByVal frmMain As Object, ByRef Info() As String)
    Set MainForm = frmMain
    ReDim Info(2)
    Info(0) = "Author: l2k-Shadow"
    Info(1) = "Plugin: iTunes Plugin"
    Info(2) = "Please NOTE: You must load iTunes and set a song playing before attempting to Get Song."
End Sub

Public Sub AddToUserMenu(ByRef ChildMenus() As String)
'
End Sub

Public Sub AddToPluginsMenu(ByRef ChildMenus() As String)
    ReDim ChildMenus(8)
    ChildMenus(0) = "Get Song"
    ChildMenus(1) = "Load iTunes"
    ChildMenus(2) = "Quit iTunes"
    ChildMenus(3) = "Play"
    ChildMenus(4) = "Pause"
    ChildMenus(5) = "Stop"
    ChildMenus(6) = "Next"
    ChildMenus(7) = "Previous"
    ChildMenus(8) = "-"
End Sub

Public Sub ProfileSwitch(ByVal objBot As Object, ByVal Index As Integer)
    Set Bot = objBot
    BotIndex = Index
End Sub

Public Sub MenuClicked(ByVal MenuName As String, Optional ByVal UserClicked As String)
    Select Case MenuName
        Case "Get Song"
            If Not Loaded Then Set iTunes = New iTunesApp: DoEvents
            Bot.AddChat vbGreen, iTunes.CurrentTrack.Artist & " - " & iTunes.CurrentTrack.Name
        Case "Load iTunes"
            Set iTunes = New iTunesApp: DoEvents
            Loaded = True
        Case "Quit iTunes"
            Set iTunes = Nothing
            Loaded = False
        Case "Play"
            If Not Loaded Then Set iTunes = New iTunesApp: DoEvents
            iTunes.Play
        Case "Pause"
            If Not Loaded Then Set iTunes = New iTunesApp: DoEvents
            iTunes.Pause
        Case "Stop"
            If Not Loaded Then Set iTunes = New iTunesApp: DoEvents
            iTunes.Stop
        Case "Next"
            If Not Loaded Then Set iTunes = New iTunesApp: DoEvents
            iTunes.NextTrack
        Case "Previous"
            If Not Loaded Then Set iTunes = New iTunesApp: DoEvents
            iTunes.PreviousTrack
    End Select
End Sub

Public Function MessageSend(ByVal Index As Integer, ByVal Message As String, Optional ByRef ReturnMessage As String) As Boolean
Dim splt() As String
    splt = Split(Message, Space(1), 2)
    Select Case LCase$(splt(0))
        Case "/litunes"
            Set iTunes = New iTunesApp
            Loaded = True
            MessageSend = True
        Case "/play"
            If Not Loaded Then Set iTunes = New iTunesApp: DoEvents
            iTunes.Play
            MessageSend = True
        Case "/stop"
            If Not Loaded Then Set iTunes = New iTunesApp: DoEvents
            iTunes.Stop
            MessageSend = True
        Case "/pause"
            If Not Loaded Then Set iTunes = New iTunesApp: DoEvents
            iTunes.Pause
            MessageSend = True
        Case "/next"
            If Not Loaded Then Set iTunes = New iTunesApp: DoEvents
            iTunes.NextTrack
            MessageSend = True
        Case "/previous", "/prev"
            If Not Loaded Then Set iTunes = New iTunesApp: DoEvents
            iTunes.PreviousTrack
            MessageSend = True
        Case "/qitunes", "/quit"
            Set iTunes = Nothing
            Loaded = False
            MessageSend = True
        Case "/volume", "/vol", "/setvol"
            If UBound(splt) = 1 Then
                iTunes.SoundVolume = CLng(splt(1))
            End If
        Case "/mp3", "/song"
            Bot.AddChat vbGreen, iTunes.CurrentTrack.Artist & " - " & iTunes.CurrentTrack.Name
            MessageSend = True
        Case "/sendmp3"
            ReturnMessage = iTunes.CurrentTrack.Artist & " - " & iTunes.CurrentTrack.Name
            MessageSend = True
    End Select
End Function

Public Sub MessageReceive(ByVal Index As Integer, ByVal EventID As Long, Optional ByVal Username As String, Optional ByVal Message As String, Optional ByVal Ping As Long, Optional ByVal Flags As Long, Optional ByVal Statstring As String)
'
End Sub
