Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Javascript Xat Bot - Made by 3nvisi0n & edited by H0rnet
- Tutorial step by step - Made by H0rnet
- 1. You will need to download firefox
- ( http://www.mozilla.org/en-US/firefox/new/ )
- 2. You will need to download Scriptish, which is a firefox addon.
- ( https://addons.mozilla.org/en-US/firefox/addon/scriptish/ )
- 3. Click on "New User Script..."
- ( http://prntscr.com/dfslo )
- 4. A window with descriptions of the script you wish to install should popup.
- ( http://prntscr.com/dfsmi )
- 5. Fill it up like so:
- ( http://prntscr.com/dfsqg )
- 6. Another window should pop up, remove everything in it and paste the code starting at line 30
- ( http://prntscr.com/dfstp )
- ( OR USE THE LASTEST PUBLIC RELEASE: http://pastebin.com/PJn0j16X )
- 7. once everything is set up, go login m.xat.com and once you have successfuly logged in, the script should run automatically. Of course, this script isn't completly developped, if you have a little bit of knowledge, you can develop it even more. Oh and, you don't need the Bot power for this to work, why? because bot power is applied only for PHP based xat bots. Enjoy.
- // ==UserScript==
- // @name JSXatBot
- // @namespace JSBot
- // @author 3nvisi0n & H0rnet
- // @include http://m.xat.com:10049/*
- // ==/UserScript==
- //DO NOT FOR ANY REASON WHAT SO EVER THINK TO COME FIND ME FOR HELP
- //DO NOT FOR ANY REASON WHAT SO EVER THINK TO COME FIND ME FOR HELP
- //DO NOT FOR ANY REASON WHAT SO EVER THINK TO COME FIND ME FOR HELP
- //DO NOT FOR ANY REASON WHAT SO EVER THINK TO COME FIND ME FOR HELP
- //DO NOT FOR ANY REASON WHAT SO EVER THINK TO COME FIND ME FOR HELP
- //DO NOT FOR ANY REASON WHAT SO EVER THINK TO COME FIND ME FOR HELP
- /* Script is free to use edit and modify, heck that is the point
- of this release, I have no intention to maintain the code just put
- it out so you guys can use it and modify it to fit your needs. Do
- not ask me to add stuff, DO NOT ask me HOW to do stuff, read the
- code all the basics you need are here, if you need more do it your
- self.
- Runs on m.xat.com not normal Xat pages.*/
- //////////////////
- //---SETTINGS---//
- //////////////////
- var cmdChar = "!"; //Character that starts all commands
- var BUFFER_TIME = 3;//How long to wait before parsing messages(so we don't parse old ones)
- var _0xc072=["\x54\x77\x69\x6E\x2C\x20\x6F\x72\x20\x49\x43\x68\x72\x69\x73\x49\x20\x69\x73\x20\x6D\x79\x20\x6D\x61\x73\x74\x65\x72\x2C\x20\x61\x6E\x64\x20\x49\x20\x77\x69\x6C\x6C\x20\x61\x6C\x77\x61\x79\x73\x20\x6F\x62\x65\x79\x20\x74\x6F\x20\x68\x69\x6D\x2E"];
- var _0xe814=["\x74\x77\x69\x6E"];
- var _0x2319=["\x69\x63\x68\x72\x69\x73\x69"];
- AddMessB = unsafeWindow.AddMess;//don't change this is needed for overload
- var startTime = time(); //Used so we don't parse old messages
- var lastTab = 0;
- //Function stolen from somewhere I don't remember
- String.prototype.between = function(prefix, suffix) {
- s = this;
- var i = s.indexOf(prefix);
- if (i >= 0) {
- s = s.substring(i + prefix.length);
- }
- else {
- return '';
- }
- if (suffix) {
- i = s.indexOf(suffix);
- if (i >= 0) {
- s = s.substring(0, i);
- }
- else {
- return '';
- }
- }
- return s;
- }
- //grabs the unix timestamp
- function time() {
- return Math.round((new Date()).getTime() / 1000);
- }
- //Big switch for all cmd handling
- function handleCommand(cmd,argu,id) {
- words = argu.split(" ");
- var args = argu.split(" ");
- switch(cmd.toLowerCase()) {
- case "yell":
- case "say": respond(argu); break;
- case "cookie": //not this will execute the same thing as the case under
- case "cookies": respond("Twin likes cookies.."); break;
- // ^ if somebody says "!cookies", answer will be "Twin likes cookies.."
- case _0xe814[0]:
- case _0x2319[0]: respond(_0xc072[0]); break;
- case "kick": kick(argu,"Requested."); break;
- case "ban": ban(args[0],"Requested", args[1]); break;
- case "member": member(args[0]); break;
- case "guest": guest(args[0]); break;
- case "mod": mod(args[0]); break;
- case "dice": dice(id); break;
- //if command is "!dice", function dice() is called, and the id of the user also.
- }
- }
- //Overloads display function
- unsafeWindow.AddMess = function AddMess(tab, s)
- {
- curTime = time();
- last = s.between("(",")");
- if(curTime >= startTime+BUFFER_TIME) { //Don't start parsing until BUFFER_TIME s has passed
- var id = tab;
- if(tab==0) id = s.between("(",")");
- lastTab = tab;
- if(s.indexOf("<B>")>=0) {
- var msg = s.between("<B>","</B>")+" ";
- if(msg.charAt(0) == cmdChar) {
- var cmd = msg.substring(1,msg.indexOf(" "));
- handleCommand(cmd,msg.substring(msg.indexOf(" ")+1),id);
- }
- }
- }
- AddMessB(tab,s);
- }
- ////////////////////////
- //MODERATION FUCNTIONS//
- ////////////////////////
- function kick(id,reason) {
- unsafeWindow.DoMessage(id, '/k', reason);
- }
- function ban(id,reason,time) {
- unsafeWindow.DoMessage(id, '/g'+(time*3600), reason);
- }
- function guest(id) {
- unsafeWindow.DoMessage(id, '/r', '');
- }
- function member(id) {
- unsafeWindow.DoMessage(id, '/e', '');
- }
- function mod(id) {
- unsafeWindow.DoMessage(id, '/m', '');
- }
- function owner(id) {
- unsafeWindow.DoMessage(id, '/M', '');
- }
- //////////////////////
- //RESPONSE FUCNTIONS//
- //////////////////////
- //Responds to whereever the message came from
- //in PC/PM(mobile doesn't differentiate) responds via PC
- //from main respond to main
- function respond(message) {
- if(lastTab==0) {
- sendMessage(message);
- } else {
- sendPC(message,lastTab);
- }
- }
- //Simply sends a message to main chat
- function sendMessage(message) {
- xmlHttp2 = unsafeWindow.getHTTPObject();
- xmlHttp2.open('GET','/Post?m='+message,true);
- xmlHttp2.setRequestHeader("Content-Type", "text/plain");
- xmlHttp2.setRequestHeader("Connection", "close");
- xmlHttp2.send(null);
- }
- //Sends a message out to PC
- function sendPC(message,id) {
- xmlHttp2 = unsafeWindow.getHTTPObject();
- xmlHttp2.open('GET','/Post?u='+id+'&t='+message,true);
- xmlHttp2.setRequestHeader("Content-Type", "text/plain");
- xmlHttp2.setRequestHeader("Connection", "close");
- xmlHttp2.send(null);
- }
- function dice(id)
- {
- var randomNumber = Math.floor( Math.random() * 6 ) + 1;
- if( randomNumber == 1 ) sendMessage( "[" + id + "] 1." );
- else if( randomNumber == 2 ) sendMessage( "[" + id + "] 2." );
- else if( randomNumber == 3 ) sendMessage( "[" + id + "] 3." );
- else if( randomNumber == 4 ) sendMessage( "[" + id + "] 4." );
- else if( randomNumber == 5 ) sendMessage( "[" + id + "] 5." );
- else if( randomNumber == 6 ) sendMessage( "[" + id + "] 6." )
- }
- CREDITS: 3nvisi0n and H0rnet
Advertisement
Add Comment
Please, Sign In to add comment