Advertisement
nicopow

Untitled

Jun 20th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. wait(1)
  2. local WebHookUrl = "https://discordapp.com/api/webhooks/326825729914306560/wroC2nxgN9Qz_7YmMjbGkdpMslLrnOjYqPjC0rUpRI-Cp07uV20nHSrJYNJSeDb78KnQ"
  3. local RetrieveMessageUrl = "https://canary.discordapp.com/api/v6/channels/326825710675034119/messages"
  4. local BotAuth = "Bot MzI2ODIxODA2MzgxOTg5ODk4.DCsYCg.TOLnzSYMjcmSKy3Tm4GJ9Ij_8Zg"
  5. local RetrievedMessageIds = {}
  6.  
  7. local Players, Http = game:service'Players', game:service'HttpService'
  8.  
  9. spawn(function()
  10. Chat = game:GetService("ServerScriptService")
  11. Chat = Chat:WaitForChild("ChatServiceRunner")
  12. Chat = Chat:WaitForChild("ChatService")
  13. Chat = require(Chat)
  14. GetSpeaker = Chat.GetSpeaker;
  15. AddSpeaker = Chat.AddSpeaker;
  16. end)
  17.  
  18. function PostToDiscord(Content, WebHook)
  19. local Data = game:GetService("HttpService"):PostAsync(WebHook, game:GetService("HttpService"):JSONEncode(Content)) do
  20. Data = game:GetService("HttpService"):JSONDecode(Data)
  21. RetrievedMessageIds[Data.id]= true
  22. end
  23. end
  24.  
  25. function RetrieveMessages(doCallback, callBack)
  26. local Rtn = game:GetService("HttpService"):GetAsync(RetrieveMessageUrl, false, {
  27. authorization = BotAuth
  28. })
  29. Rtn = game:GetService("HttpService"):JSONDecode(Rtn)
  30. for i,Message in next, Rtn do
  31. if (RetrievedMessageIds[Message.id] == nil) then
  32. RetrievedMessageIds[Message.id] = true
  33. if (doCallback) then
  34. delay(0, function()
  35. callBack(Message.author.username, Message.content, Message.author.bot == true)
  36. end)
  37. end
  38. end
  39. end
  40. end
  41.  
  42. RetrieveMessages(false)
  43.  
  44. spawn(function()
  45. while wait(1) do
  46. RetrieveMessages(true, function(Speaker, Message, isBot)
  47. if (Chat and AddSpeaker and GetSpeaker) then
  48. local speakerObj,botPrefix do
  49. botPrefix = isBot and "Server: "
  50. pcall(function()
  51. speakerObj = GetSpeaker(Chat, botPrefix .. Speaker)
  52. end)
  53. if (not speakerObj) then
  54. AddSpeaker(Chat, botPrefix .. Speaker)
  55. speakerObj = GetSpeaker(Chat, botPrefix .. Speaker)
  56. speakerObj:JoinChannel("All")
  57. end
  58. speakerObj:SayMessage(Message, "All")
  59. end
  60. else
  61. warn("Chat not found!", Chat == nil and "No chat" or "", AddSpeaker == nil and "No AddSpeaker" or "", GetSpeaker == nil and "No GetSpeaker" or "" )
  62. end
  63.  
  64. if (isBot) then return 0; end;
  65. end)
  66. end
  67. end)
  68.  
  69. for i,v in next, game:GetService("Players"):GetPlayers() do
  70. v.Chatted:connect(function(Msg)
  71. PostToDiscord({
  72. username = "HighMessageHandler";
  73. content = "**" .. v.Name .. ":** " .. Msg;
  74. }, WebHookUrl)
  75. end)
  76. end
  77.  
  78. game:GetService("Players").PlayerAdded:connect(function(v)
  79. v.Chatted:connect(function(Msg)
  80. PostToDiscord({
  81. username = "HighMessageHandler";
  82. content = "**" .. v.Name .. ":** " .. Msg;
  83. }, WebHookUrl)
  84. end)
  85. end)
  86.  
  87. return nil;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement