Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.on("a", msg => {
- // Showing chat in console
- console.log("> " + msg.p.name + " in " + self.proxy.client.channel._id + ": ");
- console.log(msg.a);
- console.log("");
- // Chat buffer
- if(msg.p._id == self.proxy.client.getOwnParticipant()._id){
- let found = false;
- for(let i=0; i<self.proxy.outbox.length; i++){
- if(self.proxy.outbox[i].message.replace(/[^\x00-\x7F\\]+| /gm, "").includes(msg.a.replace(/[^\x00-\x7F]+| /gm, ""))){
- self.proxy.outbox.splice(i, 1);
- found = true;
- break;
- }
- }
- if(!found) self.proxy.outbox = []; // Fixing spamming message
- else return; // The bot can't toggle commands
- }
- // Chat buffer checking loop
- setInterval(() => {
- for(let i=0; i<self.proxy.outbox.length; i++){
- if(Date.now() - self.proxy.outbox[i].time >= 500){
- let message = self.proxy.outbox[i].message;
- self.proxy.outbox.splice(i, 1);
- self.say(message);
- }else if(self.proxy.outbox[i].message.length == 0){
- self.proxy.outbox.splice(i, 1);
- }
- }
- }, 500);
- say(string){
- if(typeof string == "string"){
- if(string.length > 512){
- let self = this;
- let messages = [];
- string.match(/.{0,512}/g).forEach((str, i) => {
- if(str.length > 0) messages.push(str);
- });
- for(let msg of messages) self.say(msg);
- }else{
- this.outbox.push({"message": string, "time": Date.now()});
- this.client.sendArray([{ m:'a', message:string }]);
- }
- }else{
- this.say("Error: Argument given is not a string.");
- }
- }
- this.outbox = [];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement