Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- This script was coded by 12GaugeNick - ROBLOX.
- Anyone who wants to try fixing this. Go for it.
- I never could get this fully functioning correctly, if you figure it out; please let me know. I would like to understand how you fixed it.
- It was fun coding this. (Only a couple hours)
- I wish you call luck and have fun!
- vvvvvvvvvvvvvvvv
- [Error-Message]: Check to make sure the hash was encoded correctly with your apiSecret.
- ^^^^^^^^^^^^^^^^
- PHP doc used for the 'web_host'
- <html>
- <?php
- $apiSecret = $_GET['key'];
- $message = array(
- 'message' => array(
- 'message' => $_GET['usermessage'],
- 'chatBotID' => $_GET['botid'],
- 'timestamp' => $_GET['timestamp'],
- ),
- 'user' => array(
- 'firstName' => $_GET['fname'],
- 'lastName' => $_GET['lname'],
- 'gender' => $_GET['gender'], // m or f
- 'externalID' => $_GET['externalid']
- )
- );
- $messageJSON = json_encode($message);
- $hash = hash_hmac('sha256', $messageJSON, $apiSecret);
- echo $hash
- ?>
- </html>
- --]]
- local api_host = "http://www.personalityforge.com/api/chat/"
- local web_host = "" -- Removed by 12GaugeNick
- local Players = game:GetService("Players")
- local Http = game:GetService("HttpService")
- local UrlEncode = function(...) return Http:UrlEncode(...) end
- local JSONEncode = function(...) return Http:JSONEncode(...) end
- local JSONDecode = function(...) return Http:JSONDecode(...) end
- local _GET = function(...) return Http:GetAsync(...) end
- local _POST = function(...) return Http:PostAsync(...) end
- local BotId = 0 -- Removed by 12GaugeNick
- local apiKey = "" -- Removed by 12GaugeNick
- local botSecret = "" -- Removed by 12GaugeNick
- local FirstName = "N" -- Removed by 12GaugeNick
- local LastName = "M"
- local Gender = "m"
- local UserKeys = {
- ['12gaugenick'] = "A1";
- ['MessorAdmin'] = "A2";
- ['Player1'] = "A3";
- ['Player'] = "A4";
- }
- local Hash = function(Message, externalId)
- local Url = "?key="..botSecret.."&usermessage="..Message.."&botid="..BotId.."×tamp="..os.time().."&fname="..FirstName.."&lname="..LastName.."&gender="..Gender.."&externalid="..externalId
- local WebsiteResult = _GET(web_host..Url):sub(10)
- local SubFinder = WebsiteResult:find("</html>")
- local Subbed = WebsiteResult:sub(1,tonumber(SubFinder)-1)
- print(Subbed)
- return Subbed
- end
- ---------------------------------------------------------------------------------
- ---------------------------------------------------------------------------------
- ---------------------------------------------------------------------------------
- local CreateMessageJSON = function(BotSpeechRequest, PlayerNameChatted)
- if UserKeys[tostring(PlayerNameChatted)] == nil then
- return false
- end
- local Table = {
- ['message'] = {
- ['message'] = BotSpeechRequest,
- ['chatBotID'] = BotId,
- ['timestamp'] = os.time()
- },
- ['user'] = {
- ['firstName'] = FirstName,
- ['lastName'] = LastName,
- ['gender'] = Gender,
- ['externalID'] = UserKeys[tostring(PlayerNameChatted)]
- }
- }
- return Table
- end
- local Update = function(UserName, Message)
- local ResponceStart = tick()
- local messageJSON = CreateMessageJSON(Message, UserName)
- local message = messageJSON.message['message']
- local chatbotID = messageJSON.message['chatBotID']
- local timestamp = messageJSON.message['timestamp']
- local externalID = messageJSON.user['externalID']
- local firstName = messageJSON.user['firstName']
- local lastName = messageJSON.user['lastName']
- local gender = messageJSON.user['gender']
- local messageJSON = JSONEncode(messageJSON)
- local msgJSON = UrlEncode(messageJSON)
- local HashKey = Hash(message, externalID)
- local Url = api_host.."?apiKey="..apiKey.."&hash="..tostring(HashKey).."&message="..msgJSON
- local Result = JSONDecode( _GET(Url) )
- warn("[Error-Message]: ", Result.errorMessage)
- print("Website responded in "..tostring(ResponceStart-tick()):sub(2,5).." seconds")
- end
- Players.PlayerAdded:connect(function(p)
- p.Chatted:connect(function(m)
- Update(p.Name, m)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement