Advertisement
Tripy998

LuckBot

Jul 25th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    
  2.  
  3.     var io = require('socket.io-client');
  4.     socket = io.connect("http://192.155.86.153:8888");
  5.      
  6.     var username = "feelinglucky";
  7.     var outputBuffer = [];
  8.      
  9.     socket.on('connect', function(){
  10.                     //Your session key (aka API key)
  11.                     //Get this from your browser's cookies.
  12.         socket.emit('login', {session: "Mlbyf1xY6Qq0STt9FlFZBFajlcJV02GtYOHdfhvLszDPrwvRXb4mZMbKG8KvUz7F"});
  13.         socket.on('loggedin', function(data){
  14.             username = data.username;
  15.             setTimeout(function(){
  16.                             socket.emit("getcolors", {});
  17.                            
  18.                             socket.on('chat', function(data){
  19.                                                     if(contains(data.message, ["!gettip"]) && data.user == "highonquack"){
  20.             socket.emit("tip", {user: "Tripy998", room: "feelinglucky", tip: 0.3, message: "You're Welcome!"});
  21.     }
  22.                                                     if(contains(data.message, ["!help"])){
  23.                                                             outputBuffer.push({room: "feelinglucky", color: "000", message: 'Tip LuckBot to gamble, there is a 50/50 chance you will win 2x your payment! You can also donate, by tipping LuckBot with the message donation (/tip LuckBot amount donation).'});
  24.                                                     }
  25.                                                     if(contains(data.message, ["hi", username])){
  26.                                                             outputBuffer.push({room: data.room, color: "000", message: 'Feeling Lucky? Tip me!'});
  27.                                                     }
  28.                                                     if(contains(data.message, ["<span class='label label-success'>has tipped " + username, "donation"])){
  29.                                                             outputBuffer.push({room: data.room, color: "000", message: "Thank you for the tip, " + data.user + "!"})
  30.                                                     }
  31.                                                     if(contains(data.message, ["slaps", "ccbot"])){
  32.                                                             outputBuffer.push({room: data.room, color: "000", message: "/me slaps " + data.user + " around a bit with a large trout."});
  33.                                                     }
  34.                                                     if(contains(data.message, ["<span class='label label-success'>has tipped " + username]) && !contains(data.message, ["donation"])){
  35.                                                             var amount = data.message.split("<span class='label label-success'>has tipped " + username + " ")[1].split(" ")[0];
  36.      
  37.                                                     var random = Math.ceil(Math.random() * 100);
  38.                                                     if(random > 50) {
  39.                                                             var randomtwo = Math.ceil(Math.random() * 3);
  40.                                                             var earned = 2 * amount
  41.      
  42.                                                             if(randomtwo == 1){
  43.                                                                     outputBuffer.push({room: "feelinglucky", color: "000", message: data.user + " placed his/her bet and just as he was about to lose luck smiled over him! " + data.user + " wins 2 times his bet! (2 * " + amount + " = " + earned + ")! " + random + "/100"});
  44.                                                             }
  45.      
  46.                                                             if(randomtwo == 2){
  47.                                                                     outputBuffer.push({room: "feelinglucky", color: "000", message: data.user + " placed his bet bet and just at the right time his luck decided to show up. " + data.user + " wins 2 times his bet! (2 * " + amount + " = " + earned + ")! " + random + "/100"});
  48.                                                             }
  49.      
  50.                                                             if(randomtwo == 3){
  51.                                                                     outputBuffer.push({room: "feelinglucky", color: "000", message: data.user + " has rigged this to win! Well he wins! " + data.user + " wins 2 times his bet! (2 * " + amount + " = " + earned + ")! " + random + "/100"});
  52.                                                             }
  53.                                                             socket.emit("tip", {user: data.user, room: "feelinglucky", tip: earned, message: "You're a lucky man!"});
  54.                                                     }
  55.                                                     if(random < 51) {
  56.                                                             var randomtwo = Math.ceil(Math.random() * 2);
  57.                                                            
  58.                                                             if(randomtwo == 1){
  59.                                                                     outputBuffer.push({room: "feelinglucky", color: "000", message: data.user + " Aims their gun straight at the dealer " + data.user + " is out of luck and the gun backfires! " + data.user + " "dies! " + random + "/100"});
  60.                                                            }
  61.                                                          
  62.                                                            if(randomtwo == 2){
  63.                                                                    outputBuffer.push({room: "feelinglucky", color: "000", message: data.user + " placed his bet, but the dealer shot " + data.user + "! " + data.user + " is dead. " + random + "/100"});
  64.                                                            }
  65.                                                    }
  66.                                                    }
  67.                                                    if(contains(data.message, ["!flip"])){
  68.                                                            var res = (Math.random() > 0.5 ? "heads" : "tails");
  69.                                                            socket.emit("chat", {room: data.room, message: "Flipping coin: " + res + "!", color: "000"});
  70.                                                    }
  71.                                            });
  72.                          
  73.                    }, 1000);
  74.            setInterval(function(){
  75.                    //CoinChat has a 550ms anti spam prevention. You can't send a chat message more than once every 550ms.
  76.                    if(outputBuffer.length > 0){
  77.                            var chat = outputBuffer.splice(0,1)[0];
  78.                            socket.emit("chat", {room: chat.room, color: "000", message: chat.message});
  79.                    }
  80.            }, 600);
  81.        });
  82.        socket.on('disconnect', function(){});
  83.    });
  84.    
  85.    function contains(string, terms){
  86.            for(var i=0; i<terms.length; i++){
  87.                    if(string.toLowerCase().indexOf(terms[i].toLowerCase()) == -1){
  88.                            return false;
  89.                    }
  90.            }
  91.            return true;
  92.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement