-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.js
261 lines (261 loc) · 8.46 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
const snooze=(ms,obj=null)=>new Promise(resolve=>setTimeout(obj==null?resolve:function(){resolve(obj)},ms));
function ranint(t,o){return t=Math.ceil(t),o=Math.floor(o),Math.floor(Math.random()*(o-t)+t)}
const {setIntervalAsync}=require("set-interval-async/dynamic");
const request=require("request").defaults({encoding:null});
const {clearIntervalAsync}=require("set-interval-async");
const Discord=require("discord.js-selfbot");
const rootocrapi="84aeee189a88957";
const bot="574652751745777665";
const client=new Discord.Client();
const args=process.argv.slice(2);
var Running=false;
var Channel=null;
var timer=null;
var me=null;
var System={
xp:0,
loot:{},
fished:0,
prefix:"%",
seconds:3.5,
holdRun:false,
ocrapi:"84aeee189a88957"
};
var Account={
tag:"",
token:"",
username:""
};
function ocr(url,callback)
{
const URI="https://api.ocr.space/parse/imageurl?apikey="+encodeURI(System.ocrapi)+"&url="+encodeURI(url);
request.get(URI,{json:true},function(err,res,R){
if(err){
callback(null);
return;
}
if(res.statusCode!=200){
callback(null);
return;
}
callback(R.ParsedResults[0].ParsedText.replace("\r\n",""));
})
}
async function sendAsync(msg,chn=null,min=2700,max=4200){return(send(msg,chn,min,max));}
function send(msg,chn=null,min=2700,max=4200)
{
if(chn==null)chn=Channel;
if(msg.trim()=="")return;
if(chn==null)return;
chn.startTyping(1200);
chn.send(msg.toString())
.then((message)=>{setTimeout(function(){chn.stopTyping(true);message.delete()},ranint(min,max))})
.catch(console.error);
return;
}
function edit(msg,chn=null,min=2700,max=4200)
{
if(msg.trim()=="")return;
if(chn==null)return;
chn.edit(msg.toString())
.then((message)=>{setTimeout(function(){message.delete()},ranint(min,max))})
.catch(console.error);
return;
}
function notify(msg,chn=null,min=6000,max=12000)
{
if(chn==null)return;
edit("`"+msg+"`",chn,min,max);
}
String.prototype.alphabetic=function(){
var R=/^[A-Za-z]+$/;
var reg=new RegExp(R);
return(reg.test(this));
}
String.prototype.numeric=function(){
var R=/^\d+$/;
var reg=new RegExp(R);
return(reg.test(this));
}
String.prototype.timeFormat=function(){
const s=parseInt((this).trim());
var STR="0 seconds";
if(s<1)return(STR);
var L=[
Math.floor(s/60/60/24),///DAYS
Math.floor(s/60/60)%24,///HOURS
Math.floor(s/60)%60,///MINUTES
s%60///SECONDS
];
var R=[];
if(L[0]>0)R.push(L[0]+" day"+(L[0]==1?"":"s"));
if(L[1]>0)R.push(L[1]+" hour"+(L[1]==1?"":"s"));
if(L[2]>0)R.push(L[2]+" minute"+(L[2]==1?"":"s"));
if(L[3]>0)R.push(L[3]+" second"+(L[3]==1?"":"s"));
if(R!=[])STR=R.join(", ");
return(STR);
}
String.prototype.addslashes=function(){return(this+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&");}
String.prototype.replaceAll=function(src,who){
var str=this;
while(str.includes(src)){str=str.replace(src,who);}
return(str);
/*
var reg=new RegExp("/"+src.addslashes()+"/g");
return(this.replace(reg,who));
*/
}
String.prototype.capitalize=function(){return(this.charAt(0).toUpperCase()+this.slice(1).toLowerCase());}
client.on("ready",()=>{
me=client.user;
Account.tag=me.tag;
me.setStatus("online");
Account.token=AUTH_TOKEN;
Account.username=me.tag.split("#")[0];
if(timer!=null){clearTimer(timer).then(()=>{console.log(me.tag+" logged in!")})}
else{console.log(me.tag+" logged in!")}
});
const clearTimer=async(t)=>{await clearIntervalAsync(t)};
if(process.env.NODE_ENV!=="production")require("dotenv").config();
const startBot=async(msg)=>{
if(msg==null)return;
if(Running)return;
Running=true;
Channel=msg.channel;
notify("[!] Initializing with prefix "+System.prefix,msg);
timer=setIntervalAsync(()=>{doFish().then();},(System.seconds*1000)+ranint(300,666));
}
const doFish=async()=>{
if(Channel==null){
if(timer!=null)clearTimer(timer).then();
return;
}
if(System.holdRun)return;
send(System.prefix+"f",Channel);
}
client.on("message",async msg=>{
try{
if(msg.author.id==me.id){
var R=msg.content.trim();
if(!R.toLowerCase().startsWith("f."))return;
R=R.substr(2);
var L=R.split(" ");
var length=L.length;
L[0]=L[0].toLowerCase();
if(L[0]=="start"){
if(Running){
notify("[!] I am already fishing",msg);
return;
}
System.seconds=3.5;
if(length==2)System.seconds=L[1].replaceAll(".","").trim().numeric()?parseFloat(L[1]):3.5;
if(timer!=null){clearTimer(timer).then(()=>{startBot(msg).then()})}else{startBot(msg).then()}
}else
if(L[0]=="stop"){
if(!Running){
notify("[!] I am not fishing lmao",msg);
return;
}
Channel=null;
System.holdRun=Running=false;
if(timer!=null)clearTimer(timer).then(()=>{notify("[!] Stopped",msg);});
}else
if(L[0]=="prefix"){
if(Running){
notify("[!] I cannot do this while fishing",msg);
return;
}
if(length>1)System.prefix=R.substr(6).trim().toLowerCase();
notify("[!] Current prefix is "+System.prefix,msg);
}else
if(L[0]=="loot"){
var STR="`"+(System.xp>=0?"+":"-")+money(System.xp)+"` **XP**";
for(var fish in System.loot){STR+="\n`"+money(System.loot[fish])+"` **"+fish+"**";}
edit(STR,msg,60000,120000);
}else
if(L[0]=="ocr"){
if(length>1&&R[1].trim()!="")System.ocrapi=R[1].trim();
notify("[!] Current OCR.SPACE API KEY is "+System.ocrapi,msg);
}else
if(L[0]=="info"||L[0].startsWith("fish")){notify("[!] I have caught fish for a total of "+System.fished+" times which took me "+Math.ceil(System.fished*System.seconds).toString().timeFormat(),msg)}
}else
if(msg.author.id==bot&&msg.channel==Channel){
const forme=msg.content.includes(Account.username);
if(msg.content.includes("User "+me.tag+" banned")){
console.log(me.tag+" has been temporary banned from Virtual Fisher!");
process.exit(333);
return;
}
if(msg.content.includes("/bot/captcha.php")&&forme){
System.holdRun=true;
///console.log("CAPTCHA");
const url="https"+msg.content.split("https")[1];
ocr(url,function(R){
if(R===null){
console.log("CAPTCHA RESULT = NULL");
process.exit(123);
return;
}
msg.channel.startTyping();
snooze(ranint(9000,60000),{a:R,chn:msg.channel,p:System.prefix})
.then((T)=>{
send(T.p+"verify "+T.a,T.chn,30000,60000);
System.holdRun=false;
})
});
return;
}
if(msg.content.includes("adding the following 2 numbers and subtracting the third number")&&forme){
///console.log("MATH");
System.holdRun=true;
const LST=msg.content.trim().split(": ");
var n3=parseInt(LST[3].replace(".",""));
var n2=parseInt(LST[2]);
var n1=parseInt(LST[1]);
var answer=(n1+n2)-n3;
msg.channel.startTyping();
snooze(ranint(6000,18000),{a:answer,chn:msg.channel,p:System.prefix}).then((T)=>{send(T.p+"verify "+T.a,T.chn);System.holdRun=false})
return;
}
const e=msg.embeds[0];
if(!e)return;
if(e.type!="rich")return;
if(e.author===null)return;
if(e.author.name!=Account.username)return;
if(e.title.includes("You caught:")){
++System.fished;
const caught=e.description.split("\n");
for(var x in caught){
var c=caught[x];
var row=c.split(" ");
if(row.length>2){
if(row[0].numeric()&&row[1].startsWith("<:fb")){
var name=c.substr(row[0].length+row[1].length+2).trim();
if(!System.loot.hasOwnProperty(name))System.loot[name]=0;
System.loot[name]=System.loot[name]+parseInt(row[0]);
}else
if(row[2]==="XP"&&row[0]==="-"){System.xp+=parseInt(row[1].replaceAll(",","").trim());}
}else
if(row.length>1){
if(row[1]==="XP"){if(row[0].startsWith("+")){System.xp+=parseInt(row[0].substr(1).replaceAll(",",""))}else{System.xp+=parseInt(row[0].substr(1).replaceAll(",",""))}}
}
}
}else
if(e.title.startsWith("Anti-bot")){
System.holdRun=true;
msg.channel.startTyping();
///console.log("SIMPLE MATH");
const L=eval(e.description.split("**")[1]).toString();
snooze(ranint(6000,18000),{a:L,chn:msg.channel,p:System.prefix}).then((T)=>{send(T.p+"verify "+T.a,T.chn);System.holdRun=false;})
}
}
}catch(e){console.log(e);}
});
function money(s){return(Number(s).toLocaleString("en"))}
const ARG_TOKEN=args.length>0?args[0]:"";
var AUTH_TOKEN=ARG_TOKEN!=""?ARG_TOKEN:process.env.TOKEN;
if(AUTH_TOKEN!=""){client.login(AUTH_TOKEN);}
else{
console.log("Please define an authorization token!");
process.exit(666);
}