rosaage

TS3 bot

Jun 10th, 2015
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. function onTextMessageEvent(serverConnectionHandlerID, targetMode, toID, fromID, fromName, fromUniqueIdentifier, message, ffIgnored)
  2.  
  3.     -- Get own client ID
  4.     local myClientID, error = ts3.getClientID(serverConnectionHandlerID)
  5.     if error ~= ts3errors.ERROR_ok then
  6.         print("Error getting own client ID: " .. error)
  7.         return
  8.     end
  9.     --JSON = (loadfile "JSON.lua")()
  10.     if myClientID == 0 then
  11.         ts3.printMessageToCurrentTab("Not connected")
  12.         return
  13.     end
  14.  
  15.         -- Get which channel we are in
  16.     local myChannelID, error = ts3.getChannelOfClient(serverConnectionHandlerID, myClientID)
  17.     if error ~= ts3errors.ERROR_ok then
  18.         print("Error getting own channel: " .. error)
  19.         return
  20.     end
  21.     function string.starts(String,Start)
  22.         return string.sub(String,1,string.len(Start))==Start
  23.     end
  24.         -- Reply to person messaging ANYTHING to you when you are in channel
  25.     function onTextMessageEvent(serverConnectionHandlerID, targetMode, toID, fromID, fromName, fromUniqueIdentifier, message, ffIgnored)
  26.         myID = ts3.getClientID(serverConnectionHandlerID)
  27.         if fromID ~= myID then
  28.             if string.starts(message, "!yt play") then
  29.                 new = string.sub(message, 15, -7)
  30.                 --new = "https://www.youtube.com/watch?v=y6120QOlsfU"
  31.                 --   [=[Playing: [URL]]=] .. new .. [=[[/URL]]=]
  32.                 ts3.requestSendPrivateTextMsg(serverConnectionHandlerID,[[""C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" --http-port=8080 "]] .. new .. [[""]], fromID)
  33.                 os.execute([[""C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" --http-port=8080 "]] .. new .. [[""]])
  34.             end
  35.         end
  36.     end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment