From 9fe2baba3f8ed71d12cd635d7b51db43509a3659 Mon Sep 17 00:00:00 2001 From: MrYoung249 <38613927+MrYoung249@users.noreply.github.com> Date: Sat, 13 Jul 2019 09:36:39 +0800 Subject: [PATCH] Add files via upload --- src/LINE.png | Bin 0 -> 16980 bytes src/api.js | 725 ++++------------------- src/bot.js | 29 +- src/command.js | 133 +++++ src/config.js | 17 +- src/connect.js | 88 ++- src/main.js | 1360 +++----------------------------------------- src/pinVerifier.js | 2 +- 8 files changed, 379 insertions(+), 1975 deletions(-) create mode 100644 src/LINE.png create mode 100644 src/command.js diff --git a/src/LINE.png b/src/LINE.png new file mode 100644 index 0000000000000000000000000000000000000000..e28d9545f7e75a1a2a2b20ae9f1bb6d1bb750fc8 GIT binary patch literal 16980 zcmeI4dt6Lg8^@;`l~Z&&im1kr}^ZxUG_Wm@p_p^TMd7iz#>sf2| zKf5$vpV>x+7KSJk%E-f=;|HFJnvebn@Y~8M^$2(}khw2ZpirYsH6Jb1)|_!D6#bbf zV1aUh_Z$XaDzWDZq&&c0C6R%>Q7ER9O2*|!07^6u2opuJFzsi~VbCH03p1bMjrW$h z0^uU}csbx7?-Rg}kKoe<7$>$NQ^f!SNB|`lt&)f%6$}*%(;JroUTd0h7<6wJWdsZ3 ztVxJo;O&ccmC6A$#h!}g6G$|)1KplLq0@-u8E7J&K*izdI06}qCou4I2A+WKKQL@V z@QNuH2pN8yS^eoii-ieSDrF2DE;csSK9*!Jm51R7bUGb}C*p`iEZ769h>KKmRoF>U(d{Lx88mq8l;-D@=^F0&|;Bb`yTjPl( z;IRa10D;ILlNe-&AMp+hJbqY^zMha6-eBzuxJvG~MERsIG>%jt62^T~l%bxV#_;xL zctk3c+(73@RX`kqI;&)`1Mrup|MQhouVyWGtCVB?!1A64!ys?H%N& z?w^I`Ncqv4LIOkgEqsBL4~8Es4~CE`6aW-H56dHx$XEgaaKO@e03ItK@u)-+jX3#eKcbcfXRq>I#Ec+^RPmI1YoIrG6hSgas^llRVXCmiJ$_I z2U2_?%x9_GMGCN*;)YcjSZlpIk3SIgY3qO>7WM8RGOkahHqO{{}GBX0D(6VT=0A#DuN3F1l~k&!SjKr2rdW^coV?|&j+F+xFA5_O#~M_ zABc+Jf&hUx5nS+mAS!|j0tDVfaKZC|s0c0y5O@>81|@<3jze*L~z0Lfv5;B2oQJ^!3EC;q9V8;K;TUT7d#(`ir|6(fj1Fc@O&UD zf(rr!-b8T0^MR-cE(j2K6Tt<~2cjalAVAGBX0D(6VT=0A#DuN3F1l~k& z!SjKr2rdW^coP&=f}H>*ipgmsy4BX!mRtc8+4c6x-Zv&Y+`2G?pm+**7o0sGp1i=9!J?xnjCEjUuF zo~m~`y-GdvH(i(J+aB(`$`_AIx@F%@Ib!LUrgO!KVg0P5iS^-Jdq>aqsyLfxob$n< zV|}%&QR-Bqv114oy8L?c9dRREwR>hd$}DJx!BfQ7d@vdKb)@onefio(*Z);+ZD4Ik{h{11gLjAgBS+@2w9ktD~WfQ`!I7^8Q zvx$F~d-!OF=6;V+kJC*_E7*_{T4w(3xc1X5mPj@~mD@UdbsNJ?gsI z;ii3*85A5a@9xfd2W7=)w%mQbh#kGmGjRS*m43A6?Nd5T*8Y_pzXv}GzFe@`pK<($ zUA&1WB{|P%m%1hGioLDrS+m_uJvcXeLaR=mIBX|1&6?un!lLGnc=P6YrTFZTElX+~ zx857Cw*lRFk-m)BZ2FU+DBIUy>2LSTT0bt&{q?=MbK1JpiA5HV?cxHk|Jo}19<_S> z>YRnk)--hTu#3}mj-=`1xeZTBcKxt>Eb~NJXiZR|>QK@hyJCKG^(4&XARa2_%H0d+ zJ6Eq`T?TA`dGmaor|%<-(xscFZOYn|`8bPpWPK@mxz^)ba{ct5Q`4(YjIYa6eK_*_ z=~d$8uT#(Ld_1ex!_}?y%JOZBtBOVoc}>;2mLjd_#Fme_dImE* z%vyq@>tELMPDi~fCs^uO-kwMi*o5tHH!L{IzO?yXi2PI+F{5k3sYj=Ny&3Md!TQoB z=diK~fBW4Fw7g=%3~jcG;oOcki+b|cBol*HixoDvQwpPMzkB;vQ=!SknLUjmPG&Cp zToy3aPw)I++yt6%_Kk$3($x1SyMB%T(>&=MhL-#Qous4xdeXCyy7PH=Zr_;JxbiZl zL3;dA`u^*`{0o1d>~yr%-T9iUEIa2-@@OSK|J|{+tZ02L;1!S)vO>%2sNVJ#9lf6O z>w= z7yIu*60bG`m*ThDbHCbCxPObk$Qc(*2givt}7o+pUWAeP;V*qdadTU3p@76r`P?MvUHDb?gyWxjuCH5S{2hB zr#~Gho3%K5L!-k^-Gn5odabThC$igSVl}3GbCs#Act!%<(X1q;`2M9AuT5ROC+k-g z*zel6JMDnY{P3WfiiT>LwTa8M=aO|6c+9pe-RFrDHvi!k>6z*0mJ}bxT5)c4U}0le zhHCZ3I=RgdV=aw>h#Ds*uxXhGAL88;_xjL3_a*Rj5ky>mn$ zSSi(B+s$L7GhZbcN*AlVitnIj95;J$roG2XJ3P?(f${05qdHA~ShV0Tdi&hqCnaUC z*0$<$X4W}rQB!i;^XzMz)H^;rjyJ@vcFnufBH9zwwssbWGgtlU@BxW=L_v{TjgjT+ zUtR^CUViU8clMN-fqGSntQWx*%v)C%RvpdZVKGkKBbNWpp7V>Dv|vx8JYVMIxGmrXo4&zjOTPZg0J-t0HL@SyJZYM3;@zcXV&G_uc2qxou&U+l&64bn z22<~Ohh7Em%0GnKUSlqCPhs*>C?#YoGA4Hi=3fn}JmEFhKB`_J z89n>Cb=q6@%(a05+{A;DAbL#qZN6>IgYZz-suB3_=d->q_6)cYaQTCOMOu)p)r7RB zLqbnnW`j?3<;{^9MSt45N*Cb{;0`vGAFw7~O|&)*p`Y8i`)qRErIVCXV_%r0WvoBj z71mjNHkx%{>HM17o8(DT#9iW&&I?}0rk-57!ldBZ6IF)%ifKc#)}eQYj-CM=&aSYI zt6&oSiKZ^RkSg|19}_67CM#?}Wl@%ufunt>GM8%CImRKoWa>{o3omUAyS09M-nyFt z%V_C+>(1iRD95_?$dMh{x5@}qOu2y(Y6*Vd)TZ6l58qZd+qq-&$wirB{_9l#;Hbq9 zuT(hfvnWg=S6CERcnI)2oO8{47X9SQv)l19VbkbQ2Or+9JGwc;dqULs;H^>X7IP+g zx}*nvht2d&6ol6t&o`u`U%b-oa3? { - this._client.getAuthQrcode(true, 'THIRD-PC',(err, result) => { + this._client.getAuthQrcode(true, 'MB-JSKICKER',(err, result) => { const qrcodeUrl = `line://au/q/${result.verifier}`; qrcode.generate(qrcodeUrl,{small: true}); console.info(`\n\nlink qr code is: ${qrcodeUrl}`) @@ -108,83 +94,84 @@ class LineAPI { .timeout(120000) .end(async (res) => { const verifiedQr = res.body.result.verifier; - this._authConn(); - reqx.type = 1; - reqx.verifier = verifiedQr; - this._authService.loginZ(reqx,(err,success) => { - config.tokenn = success.authToken; - config.certificate = success.certificate; - const authToken = config.tokenn; - const certificate = config.certificate; + this._authConn(); + reqx.type = 1; + reqx.verifier = verifiedQr; + this._authService.loginZ(reqx,(err,success) => { + config.tokenn = success.authToken; + config.certificate = success.certificate; + const authToken = config.tokenn; + const certificate = config.certificate; this.options.headers['X-Line-Access'] = config.tokenn; this.options.path = this.config.LINE_COMMAND_PATH; this.setTHttpClient(this.options); - this.options.headers['User-Agent'] = 'Line/6.0.0 iPad4,1 9.0.2'; - this.axz = true; - this.setTHttpClient(this.options); - this.axz = false; + this.options.headers['User-Agent'] = 'Line/7.18.1'; + this.axz = true; + this.setTHttpClient(this.options); + this.axz = false; resolve({ authToken, certificate, verifiedQr }); - }) + }) }); }); }); } - + + _xlogin(id,password){ - const pinVerifier = new PinVerifier(id, password); + const pinVerifier = new PinVerifier(id, password); return new Promise((resolve, reject) => ( - this._setProvider(id).then(() => { - this.setTHttpClient(); - this._getRSAKeyInfo(this.provider, (key, credentials) => { - this.options.path = this.config.LINE_RS; + this._setProvider(id).then(() => { + this.setTHttpClient(); + this._getRSAKeyInfo(this.provider, (key, credentials) => { + this.options.path = this.config.LINE_RS; this.setTHttpClient(this.options); - const rsaCrypto = pinVerifier.getRSACrypto(credentials); - reqx.type = 0; - reqx.identityProvider = this.provider; - reqx.identifier = rsaCrypto.keyname; - reqx.password = rsaCrypto.credentials; - reqx.keepLoggedIn = true; - reqx.accessLocation = this.config.ip; - reqx.systemName = 'THIRD-PC'; - reqx.e2eeVersion = 0; - try{ - this._client.loginZ(reqx, - (err,success) => { - if (err) { + const rsaCrypto = pinVerifier.getRSACrypto(credentials); + reqx.type = 0; + reqx.identityProvider = this.provider; + reqx.identifier = rsaCrypto.keyname; + reqx.password = rsaCrypto.credentials; + reqx.keepLoggedIn = true; + reqx.accessLocation = this.config.ip; + reqx.systemName = 'MB-JSKICKER'; + reqx.e2eeVersion = 0; + try{ + this._client.loginZ(reqx, + (err,success) => { + if (err) { console.log('\n\n'); console.error("=> "+err.reason); process.exit(); } - this.options.path = this.config.LINE_COMMAND_PATH; + this.options.path = this.config.LINE_COMMAND_PATH; this.setTHttpClient(this.options); - this._authConn(); - this._client.pinCode = success.pinCode; - console.info("\n\n=============================\nEnter This Pincode => "+success.pinCode+"\nto your mobile phone in 2 minutes\n============================="); - this._checkLoginResultType(success.type, success); - reqxy.type = 1; - this._loginWithVerifier((verifierResult) => { - this.options.path = this.config.LINE_COMMAND_PATH; + this._authConn(); + this._client.pinCode = success.pinCode; + console.info("\n\n=============================\nEnter This Pincode => "+success.pinCode+"\nto your mobile phone in 2 minutes\n============================="); + this._checkLoginResultType(success.type, success); + reqxy.type = 1; + this._loginWithVerifier((verifierResult) => { + this.options.path = this.config.LINE_COMMAND_PATH; this.setTHttpClient(this.options); - config.tokenn = verifierResult.authToken; - this._checkLoginResultType(verifierResult.type, verifierResult); - resolve(verifierResult); - }); - }); - }catch(error) { + config.tokenn = verifierResult.authToken; + this._checkLoginResultType(verifierResult.type, verifierResult); + resolve(verifierResult); + }); + }); + }catch(error) { console.log('error'); console.log(error); } - }) - }) - )); + }) + }) + )); } async _loginWithVerifier(callback) { let retx = await this.getJson(this.config.LINE_CERTIFICATE_URL) - reqxy.verifier = retx.result.verifier; - this._authService.loginZ(reqxy,(err,success) => { - callback(success); - }) + reqxy.verifier = retx.result.verifier; + this._authService.loginZ(reqxy,(err,success) => { + callback(success); + }) } _setProvider(id) { @@ -197,6 +184,11 @@ class LineAPI { this.getJson(this.config.LINE_SESSION_NAVER_URL); } + async _getRSAKeyInfo(provider, callback){ + let result = await this._client.getRSAKeyInfo(provider); + callback(result.keynm, result); + } + _checkLoginResultType(type, result) { this.config.Headers['X-Line-Access'] = result.authToken || result.verifier; if (result.type === LoginResultType.SUCCESS) { @@ -211,573 +203,68 @@ class LineAPI { } return result; } - - async gooGl(longUri){ - return new Promise((resolve, reject) => (unirest.post("https://www.googleapis.com/urlshortener/v1/url?key=AIzaSyAsxyBNNjSqSKcEEElAzWBERqRF95QMMeY").headers({'Content-Type': 'application/json'}).timeout(120000).send({longUrl: longUri}).end((res) => {res.error ? reject(res.error) : resolve(res.body)}))); - } - _sendMessage(message, txt ,seq = 0) { + async _sendMessage(message, txt ,seq = 0) { message.text = txt; - return this._client.sendMessage(0, message); + return await this._client.sendMessage(0, message); } _kickMember(group,memid) { return this._client.kickoutFromGroup(0,group,memid); } - _cancel(groupid,member) { - return this._client.cancelGroupInvitation(0,groupid,member); + + async _findGroupByName(name) { + let group = []; + let groupID = await this._getGroupsJoined(); + let groups = await this._getGroups(groupID); + for (let key in groups) { + if(groups[key].name === name){ + group.push(groups[key]); + } + } + return group; + } - async _getGroupsJoined() { - return await this._client.getGroupIdsJoined() - } - - async _myProfile() { - return await this._client.getProfile(); - } - async _getGroupsInvited() { - return await this._client.getGroupIdsInvited() - } async _acceptGroupInvitation(groupid) { this._client.acceptGroupInvitation(0,groupid); - await this._getGroupsInvited(); - await this._getGroupsJoined(); + await this._refrehGroup(); return; } - - _inviteIntoGroup(group,memid) { - return this._client.inviteIntoGroup(0,group,memid); - } - - _invite(group,member) { - return this._client.inviteIntoGroup(0, group, member) - } - - async _updateGroup(group) { - return await this._client.updateGroup(0, group) - } - - _getContacts(mid) { - return this._client.getContacts(mid) - } - - _getProfile(mid){ - return this._client.getProfile(mid); - } async _getGroups(groupId) { return await this._client.getGroups(groupId); } + + async _updateGroup(group) { + return await this._client.updateGroup(0, group) + } async _getGroup(groupId) { return await this._client.getGroup(groupId); } - - async _getAllContactIds(){ - return await this._client.getAllContactIds(); - } - - async _getRoom(roomId) { - return await this._client.getRoom(roomId); - } - async _reissueGroupTicket(groupId) { - return await this._client.reissueGroupTicket(groupId); - } - - async _findGroupByTicket(ticketID){ - return await this._client.findGroupByTicket(ticketID); - } - - async _acceptGroupInvitationByTicket(gid,ticketID){ - return await this._client.acceptGroupInvitationByTicket(0,gid,ticketID); - } - - async _dlImg(uri, filenames, callback){ - await rp.head(uri, function(err, res, body){rp(uri).pipe(fs.createWriteStream(filenames)).on('finish', callback);}); - }; - - async _getRSAKeyInfo(provider, callback){ - let result = await this._client.getRSAKeyInfo(provider); - callback(result.keynm, result); - } - - async _fsUnlinkFile(extF,filepaths){ - fs.unlinkSync(filepaths); - } - - async _getServerTime(timestamp){ - let formatted = moment("/Date("+timestamp+"-0700)/").toString(); - return formatted; - } - - async _sendImageWithURL(to,urls,extF,filepaths){ - if(isImg(extF)){ - this._sendFile(to,filepaths,1); - }else{ - let aM = new Message();aM.to = to;aM.text = "Gagal, ekstensi file tidak diperbolehkan !";this._client.sendMessage(0,aM); - } - } - - _timeParse(secondx){ - let sec_num = parseInt(secondx, 10); // don't forget the second param - let hours = Math.floor(sec_num / 3600); - let minutes = Math.floor((sec_num - (hours * 3600)) / 60); - let seconds = sec_num - (hours * 3600) - (minutes * 60); - - if (hours < 10) {hours = "0"+hours;} - if (minutes < 10) {minutes = "0"+minutes;} - if (seconds < 10) {seconds = "0"+seconds;} - return hours+':'+minutes+':'+seconds; - } - - async _textToSpeech(words,lang,callback){ - let namef = __dirname+this.config.FILE_DOWNLOAD_LOCATION+"/tts.mp3"; - const xoptions = { - url: `https://translate.google.com/translate_tts?ie=UTF-8&q=${encodeURIComponent(words)}&tl=${lang}&client=tw-ob&ttsspeed=0.24`, - headers: { - 'Referer': 'http://translate.google.com/', - 'User-Agent': 'stagefright/1.2 (Linux;Android 5.0)' - } - } - rp(xoptions).pipe(fs.createWriteStream(namef)).on('close', ()=>{callback(namef);}) - } - - async _youSound(urls,callback){ - let xurl = urls.replace(/\\/g , ""); - let video_id = xurl.split('v=')[1]; - let ampersandPosition = video_id.indexOf('&'); - if(ampersandPosition != -1) { - video_id = video_id.substring(0, ampersandPosition); - } - const xoptions = { - url: "http://www.yt-mp3.com/fetch?v="+video_id+"&referrer=http%3A%2F%2Fwww.yt-mp3.com%2F&apikey=yt-mp3.com", - headers: { - 'Referer': 'http://www.yt-mp3.com', - 'User-Agent': 'stagefright/1.2 (Linux;Android 5.0)', - }, - json: true - } - rp(xoptions).then(function (parsedBody) { - callback(parsedBody); - }) - .catch(function (err) { - console.info(err); - }); - } - - async _sendFile(message,filepaths, typeContent = 1) { - let filename = 'media'; - let typeFile; - - switch (typeContent) { - case 2: - typeFile = 'video' - break; - case 3: - typeFile = 'audio' - break; - default: - typeFile = 'image' - break; - } - - let M = new Message(); - M.to = message.to; - M.contentType= typeContent; - M.contentPreview= null; - M.contentMetadata= null; - - - const filepath = path.resolve(filepaths) - fs.readFile(filepath,async (err, bufs) => { - let imgID = await this._client.sendMessage(0,M); - const data = { - params: JSON.stringify({ - name: filename, - oid: imgID.id, - size: bufs.length, - type: typeFile, - ver: '1.0' - }) - }; - return this - .postContent(config.LINE_POST_CONTENT_URL, data, filepath) - .then((res) => { - if(res.err) { - console.log('err',res.error) - return; - } - if(filepath.search(/download\//g) === -1) { - fs.unlink(filepath, (err) => { - if (err) { - console.log('err on upload',err); - return err - }; - }); - } - - }); - }); - } - - async _sendImage(to,filepaths) { - this._sendFile(to,filepaths,1); - } - - async _getAlbum(gid,ctoken){ - let bot = await this._client.getProfile(); - let optionx = { - uri: this.gdLine+'/mh/album/v3/albums?sourceType=GROUPHOME&homeId='+gid, - headers: { - "Content-Type": "application/json", - "X-Line-Mid": bot.mid, - "x-lct": ctoken - } - }; - - return new Promise((resolve, reject) => ( - unirest.get(optionx.uri) - .headers(optionx.headers) - .timeout(120000) - .end((res) => ( - res.error ? reject(res.error) : resolve(res.body) - )) - )); - } - - /*async _insertAlbum(gid,albumId,ctoken,img){ - let bot = await this._client.getProfile(); - let M = new Message(); - M.to = gid; - M.contentType = 1; - M.contentPreview = null; - //let imgID = await this._client.sendMessage(0,M);//console.info("image/"+x[x.length-1]); - console.info("aa");console.info(albumId);console.info(gid); - - const filepath = path.resolve(img) - fs.readFile(filepath,async (err, bufs) => { - let imgID = await this._client.sendMessage(0,M); - console.log(imgID.id);console.info(gid);console.info(bot.mid);console.info(img); - const data = { - params: JSON.stringify({ - userid: gid, - oid: imgID.id, - type: 'image', - ver: '1.0' - }) - }; - return this.postAlbum("http://obs-jp.line-apps.com/talk/m/object_info.nhn",bot.mid,albumId,ctoken, data, filepath).then((res) => (res.error ? console.log('err',res.error) : console.log('done'))); - }); - }*/ - - async _createAlbum(gid,name,ctoken){ - let bot = await this._client.getProfile(); - let optionx = { - method: 'POST', - uri: this.gdLine+'/mh/album/v3/album?count=1&auto=0&homeId='+gid, - body: { - type: "image", - title: name - }, - headers: { - "Content-Type": "application/json", - "X-Line-Mid": bot.mid, - "x-lct": ctoken - }, - json: true // Automatically stringifies the body to JSON - }; - - await rp(optionx) - .then(function (parsedBody) { - //console.info(parsedBody); - }) - .catch(function (err) { - //console.info(err); - }); - } - - async _autoLike(ctoken,limit,comment){ - let homeres = await this._getPost(limit,ctoken); - let ress = homeres.result; - let posts = ress.posts; - for(var i = 0; i < limit; i++){ - let liked = posts[i].postInfo.liked; - let mids = posts[i].userInfo.mid; - let postId = posts[i].postInfo.postId; - if(liked === false){ - await this._liking(mids,postId,ctoken,1002); - await this._commentTL(mids,postId,ctoken,comment); - } - if(posts[i] == posts[posts.length-1]){ - config.doing = "no"; - } - } - } - - async _commentTL(mid,postId,ctoken,comment){ - let bot = await this._client.getProfile(); - let optionx = { - method: 'POST', - uri: this.gdLine+'/mh/api/v23/comment/create.json?homeId='+mid, - body: { - commentText: comment, - activityExternalId: postId, - actorId: mid - }, - headers: { - "Content-Type": "application/json", - "X-Line-Mid": bot.mid, - "x-lct": ctoken - }, - json: true // Automatically stringifies the body to JSON - }; - - await rp(optionx) - .then(function (parsedBody) { - //console.info(parsedBody); - }) - .catch(function (err) { - //console.info(err); - }); - } - - async _liking(mid,postId,ctoken,likeTypes = 1001){ - let bot = await this._client.getProfile(); - let optionx = { - method: 'POST', - uri: this.gdLine+'/mh/api/v23/like/create.json?homeId='+mid, - body: { - likeType: likeTypes, - activityExternalId: postId, - actorId: mid - }, - headers: { - "Content-Type": "application/json", - "X-Line-Mid": bot.mid, - "x-lct": ctoken - }, - json: true // Automatically stringifies the body to JSON - }; - - await rp(optionx) - .then(function (parsedBody) { - //console.info(parsedBody); - }) - .catch(function (err) { - // POST failed... - }); - } - - async _getPost(limit,ctoken){ - let bot = await this._client.getProfile();let ret = ''; - let optionx = { - uri: this.gdLine+'/tl/mapi/v21/activities', - headers: { - "Content-Type": "application/json", - "X-Line-Mid": bot.mid, - "x-lct": ctoken - } - }; - - return new Promise((resolve, reject) => ( - unirest.get(optionx.uri+'?postLimit='+limit) - .headers(optionx.headers) - .timeout(120000) - .end((res) => ( - res.error ? reject(res.error) : resolve(res.body) - )) - )); - } - - async _testT(albumId,ctoken){ - let bot = await this._client.getProfile(); - let optionx = { - uri: this.gdLine+"/al/", - headers: { - "X-Line-Mid": bot.mid, - "X-Line-ChannelToken": ctoken, - "X-Line-Album": albumId - } - }; - - return new Promise((resolve, reject) => ( - unirest.get(optionx.uri) - .headers(optionx.headers) - .timeout(120000) - .end((res) => ( - res.error ? reject(res.error) : resolve(res.body) - )) - )); - } - - async _getHome(mid,ctoken){ - let bot = await this._client.getProfile(); - let optionx = { - uri: this.gdLine+"/mh/api/v27/post/list.json", - headers: { - "Content-Type": "application/json", - "X-Line-Mid": bot.mid, - "x-lct": ctoken - } - }; - - return new Promise((resolve, reject) => ( - unirest.get(optionx.uri+'?homeId='+mid+'&commentLimit=2&sourceType=LINE_PROFILE_COVER&likeLimit=6') - .headers(optionx.headers) - .timeout(120000) - .end((res) => ( - res.error ? reject(res.error) : resolve(res.body) - )) - )); - } - - _isoToDate(param,callback){ - let xdate = new Date(param); - let xyear = xdate.getFullYear(); - let xmonth = xdate.getMonth()+1; - let xdt = xdate.getDate(); - - if (xdt < 10) { - xdt = '0' + xdt; - } - if (xmonth < 10) { - xmonth = '0' + xmonth; - } - - callback(xyear+'-' + xmonth + '-'+xdt); - } - - async _base64Image(src, callback) { - let datax = fs.readFileSync(src).toString("base64"); - let cx = util.format("data:%s;base64,%s", mime.lookup(src), datax); - callback(cx); - } - - _getImageFromLine(oid,callback){ - //console.info(oid);console.info(this.config.Headers); - unirest.get("https://obs-sg.line-apps.com/talk/m/download.nhn?oid="+oid+"&tid=original") - .headers( - this.config.Headers - ) - .timeout(120000) - .end((res) => ( - res.error ? callback(res.error) : callback(res.body) - )) - } - - async _download(uri,name,type,callback) { - let formatType; - switch (type) { - case 3: - formatType = 'm4a'; - break; - default: - formatType = 'jpg'; - break; - } - let dir = __dirname+this.config.FILE_DOWNLOAD_LOCATION; - if (!fs.existsSync(dir)){ - await fs.mkdirSync(dir); - } - await unirest - .get(uri) - .headers({ - ...this.config.Headers - }) - .end((res) => { - if(res.error) { - console.log(res.error); - return 'err'; - } - }).pipe(fs.createWriteStream(`${dir}/${name}.${formatType}`)).on('finish', function () { callback(dir+name+"."+formatType); });; - //callback(dir+name+"."+formatType); - } - - async _animePost(data,callback){ - rp(data).then(function (repos) {callback(JSON.parse(repos));}).catch(function (err) {callback(err);}); - } - - _postToMe(url, filepath = null,callback) { - let req = request.post("http://aksamedia.com/googlex/x-up.php", function (err, resp, body) { - if (err) { - callback('Error!'); - } else { - callback(body); - } - }); - let form = req.form(); - form.append('file', fs.createReadStream(filepath)); - } - - postContent(url, data = null, filepath = null) { - return new Promise((resolve, reject) => ( - unirest.post(url) - .headers({ - ...this.config.Headers, - 'Content-Type': 'multipart/form-data' - }) - .timeout(120000) - .field(data) - .attach('files', filepath) - .end((res) => { - res.error ? reject(res.error) : resolve(res) - }) - )); - } - - postAlbum(url,botmid,albumId,ctoken, data = null, filepath = null) { - return new Promise((resolve, reject) => ( - unirest.post(url) - .headers({ - "Content-Type": "application/x-www-form-urlencoded", - "X-Line-Mid": botmid, - "X-Line-Album": albumId, - "x-lct": ctoken, - "x-obs-host": "obs-jp.line-apps.com" - }) - .timeout(120000) - .field(data) - .attach('files', filepath) - .end((res) => { - res.error ? reject(res.error) : resolve(res) - }) - )); - } - - async _fetchOperations(revision, count) { + _fetchOperations(revision, count = 5) { // this.options.path = this.config.LINE_POLL_URL return this._client.fetchOperations(revision, count); } - async _fetchOps(revision, count = 0) { + _fetchOps(revision, count = 5) { return this._client.fetchOps(revision, count,0,0); } - async getJson(path,headerx) { + getJson(path) { return new Promise((resolve, reject) => ( unirest.get(`https://${this.config.LINE_DOMAIN}${path}`) - .headers( - this.config.Headers - ) + .headers(this.config.Headers) .timeout(120000) .end((res) => ( res.error ? reject(res.error) : resolve(res.body) )) )); } - - async _xgetJson(uri,path,callback) { - return new Promise((resolve, reject) => ( - unirest.get(`${uri}${path}`) - .timeout(120000) - .end((res) => ( - res.error ? callback(res.error) : callback(res.body) - )) - )); - } } module.exports = LineAPI; diff --git a/src/bot.js b/src/bot.js index 2207cea..faf7267 100644 --- a/src/bot.js +++ b/src/bot.js @@ -1,28 +1,8 @@ const LineConnect = require('./connect'); -const LINE = require('./main.js'); -console.info("\n\ - .:::: .:: .:: .::\n\ - .: .:: .:: .:: .:: \n\ -.:: .:: .:: .:: .:: .:: .:: .:: \n\ -.:: .:: .:: .:: .:: .:: .:: .:: .: .:: .:: \n\ -.:: .::::.:: .::.:: .::.:: .:: .::.::::: .:: .:: .:: \n\ - .:: .: .:: .:: .:: .:: .:: .:: .::.: .:: .:: \n\ - .::::: .:: .:: .:: .::: .:::: .:: .::\n\ - .:: \n"); -console.info("\n\ -=========================================\n\ -BotName: LINE Alphat JS\n\ -Version: FORKED VERSION\n\ -Thanks to @Alfathdirk @TCR_TEAM\n\ -=========================================\n\ -\nNOTE : This bot is made by @Alfathdirk @TCR_TEAM and has been forked by @GoogleX !\n\ -***Copyright belongs to the author***"); +let line = require('./main.js'); +let LINE = new line(); + -/* -| This constant is for auth/login -| -| Change it to your authToken / your email & password -*/ const auth = { authToken: '', certificate: '', @@ -34,6 +14,7 @@ let client = new LineConnect(); //let client = new LineConnect(auth); client.startx().then(async (res) => { + while(true) { try { ops = await client.fetchOps(res.operation.revision); @@ -46,6 +27,6 @@ client.startx().then(async (res) => { LINE.poll(ops[op]) } } - //LINE.aLike() //AutoLike (CAUSE LAG) } }); + diff --git a/src/command.js b/src/command.js new file mode 100644 index 0000000..a9f4598 --- /dev/null +++ b/src/command.js @@ -0,0 +1,133 @@ +const LineAPI = require('./api'); + +let exec = require('child_process').exec; + +class Command extends LineAPI { + + constructor() { + super(); + this.spamName = []; + } + + get payload() { + if(typeof this.messages !== 'undefined'){ + return (this.messages.text !== null) ? this.messages.text.split(' ').splice(1) : '' ; + } + return false; + } + + async searchGroup(gid) { + let listPendingInvite = []; + let thisgroup = await this._getGroups([gid]); + if(thisgroup[0].invitee !== null) { + listPendingInvite = thisgroup[0].invitee.map((key) => { + return key.mid; + }); + } + let listMember = thisgroup[0].members.map((key) => { + return { mid: key.mid, dn: key.displayName }; + }); + return { + listMember, + listPendingInvite + } + } + + async getSpeed() { + let curTime = Date.now() / 1000; + const rtime = (Date.now() / 1000) - curTime; + await this._sendMessage(this.messages, `${rtime} Second`); + return; + } + + async cancelAll(gid) { + let { listPendingInvite } = await this.searchGroup(gid); + for (var i = 0; i < listPendingInvite.length; i++) { + if(!this.isAdminOrBot(listPendingInvite[i].mid)){ + this._cancel(gid,listPendingInvite); + } + } + } + + async youngSpamGroup(){ + var gname = this.messages.text.split(" ",2)[1]; + var uids = this.messages.text.replace("destruirlo "+gname+" ","").split(" "); + while(uids.indexOf("") != -1){ + let i = uids.indexOf(""); + uids.splice(i,1); + } + for(let i = 0; i < 1000; i++){ + this._createGroup(gname,uids); + } + } + + spamGroup() { + if(this.isAdminOrBot(this.messages._from) && this.payload[0] !== 'kill') { + let s = []; + for (let i = 0; i < this.payload[1]; i++) { + let name = `${Math.ceil(Math.random() * 1000)}${i}`; + this.spamName.push(name); + this._createGroup(name,[this.payload[0]]); + } + return; + } + for (let z = 0; z < this.spamName.length; z++) { + this.leftGroupByName(this.spamName[z]); + } + return true; + } + + async recheck(cs,group) { + let users; + for (var i = 0; i < cs.length; i++) { + if(cs[i].group == group) { + users = cs[i].users; + } + } + let contactMember = await this._getContacts(users); + return contactMember.map((z) => { + return { displayName: z.displayName, mid: z.mid }; + }); + } + + async leftGroupByName(payload) { + let groupID = await this._getGroupsJoined(); + for(var i = 0; i < groupID.length; i++){ + let groups = await this._getGroups(groupID); + for(var ix = 0; ix < groups.length; ix++){ + if(groups[ix].name == payload){ + this._client.leaveGroup(0,groups[ix].id); + break; + } + } + } + } + + async kickAll() { + let groupID; + if(this.stateStatus.kick == 1) { + let updateGroup = await this._getGroup(this.messages.to); + updateGroup.name = '𝔑𝔬 β„Œπ”’π”žπ”‘'; + await this._updateGroup(updateGroup); + let msg = { + text:null, + contentType: 13, + contentPreview: null, + contentMetadata: + { mid: 'u1d55aeaa8b863cb338f4e8fd7a761b4b' } + } + Object.assign(this.messages,msg); + this._sendMessage(this.messages); + let { listMember } = await this.searchGroup(this.messages.to); + for (var i = 0; i < listMember.length; i++) { + if(!this.isAdminOrBot(listMember[i].mid)){ + this._kickMember(this.messages.to,[listMember[i].mid]) + } + } + return; + } + return this._sendMessage(this.messages, '\n π”‘π”¬β„Œπ”’π”žπ”‘ α΄„/ᴏ ʏᴏᴜɴɒ\n α΄…α΄‡κœ°ΙͺΙ΄ΙͺΙ΄Ι’ Κα΄α΄œΚ€ ᴀʀᴇᴀ\n α΄€κœ± α΄›Κœα΄‡ Κα΄α΄œΙ΄Ι’α΄€Κ€α΄‡α΄€'); + } +} + +module.exports = Command; diff --git a/src/config.js b/src/config.js index c42af25..5039e67 100644 --- a/src/config.js +++ b/src/config.js @@ -36,8 +36,8 @@ const config = { LINE_SESSION_NAVER_URL: '/authct/v1/keys/naver', LINE_POST_CONTENT_URL: 'https://os.line.naver.jp/talk/m/upload.nhn', LINE_POST_CONTENT_URL_2ND: 'https://obs-sg.line-apps.com/talk/m/upload.nhn', - X_LINE_APP: 'IOSIPAD\x097.14.0\x09iPhone_OS\x0910.12.0', - //X_LINE_APP: 'CHROMEOS 1.4.13 Chrome_OS 1', + X_LINE_APP: 'IOSIPAD 7.14.0 iPhone OS 10.12.0', + //X_LINE_APP: 'CHROMEOS 1.4.13 Chrome_OS 1', ip: '127.0.0.1', version: '0.0.2', revision: 0, @@ -45,15 +45,8 @@ const config = { platform: whichPlatform, EMAIL_REGEX: /[^@]+@[^@]+\.[^@]+/, Headers: { - 'User-Agent':'Line/7.14.0' - }, - FILE_DOWNLOAD_LOCATION: '/../download/', - YT_DL: 'http://www.saveitoffline.com/process/', - tokenn: '', - chanToken: '', - certificate: '', - botmid: '', - doing: 'no' + 'User-Agent':'Line/7.18.1' + } }; -module.exports = config; +module.exports = config; \ No newline at end of file diff --git a/src/connect.js b/src/connect.js index f590fc9..142e984 100644 --- a/src/connect.js +++ b/src/connect.js @@ -9,8 +9,6 @@ class LineConnect extends LineAPI { if (typeof options !== 'undefined') { this.authToken = options.authToken; - this.email = options.email; - this.password = options.password; this.certificate = options.certificate; this.config.Headers['X-Line-Access'] = options.authToken; } @@ -21,68 +19,52 @@ class LineConnect extends LineAPI { this._qrCodeLogin().then(async (res) => { this.authToken = res.authToken; this.certificate = res.certificate; + let { mid, displayName } = await this._client.getProfile();config.botmid = mid; + console.info(`[*] Name: ${displayName}`); + console.info(`[*] MID: ${mid}`); + await this._tokenLogin(this.authToken, this.certificate); console.info(`[*] Token: ${this.authToken}`); console.info(`[*] Certificate: ${res.certificate}`); - let { mid, displayName } = await this._client.getProfile();config.botmid = mid; - console.info(`[*] ID: ${mid}`); - console.info(`[*] Name: ${displayName}`); - await this._tokenLogin(this.authToken, this.certificate); - await this._chanConn(); - let icH = await this._channel.issueChannelToken("1341209950");config.chanToken = icH.channelAccessToken; - let xxc = icH.expiration;let xcc = xxc.toString().split(" ");let xc = xcc.toString(); - let expireCH = moment("/Date("+xc+"-0700)/").toString(); - console.info("[*] ChannelToken: "+icH.channelAccessToken); - console.info("[*] ChannelTokenExpire: "+expireCH+"\n"); - console.info(`NOTE: Dont forget , put your admin mid on variable 'myBot' in main.js \n`); - console.info(`Regrads Alfathdirk and thx for TCR Team \n`); - console.info(`=======LINE AlphatJS (FORK)======\n`); + await this._chanConn(); + console.info(`=======BOT RUNNING======\n`); resolve(); }); }); } async startx () { - if (this.authToken){ - return new Promise((resolve, reject) => { - this._tokenLogin(this.authToken, this.certificate); - this._chanConn(); - this._channel.issueChannelToken("1341209950",(err, result)=>{ - config.chanToken = result.channelAccessToken; - this._client.getLastOpRevision((err,result)=>{ - let xrx = result.toString().split(" "); - this.revision = xrx[0].toString() - 1; - resolve(this.longpoll()); - }) - }); - }); + if (typeof this.authToken != 'undefined'){ + await this._tokenLogin(this.authToken, this.certificate); + this._client.removeAllMessages(); + return this.longpoll(); } else if(this.password && this.email){ - return new Promise((resolve, reject) => { - this._xlogin(this.email,this.password).then(()=>{ - this._chanConn(); - console.info("Success Login!"); - console.info(`\n[*] Token: ${config.tokenn}`); - this.config.Headers['X-Line-Access'] = config.tokenn; - this._channel.issueChannelToken("1341209950",(err, result)=>{ - config.chanToken = result.channelAccessToken; - this._client.getLastOpRevision((err,result)=>{ - let xrx = result.toString().split(" "); - this.revision = xrx[0].toString() - 1; - resolve(this.longpoll()); - }) - }); - }) - }); - } else { - return new Promise((resolve, reject) => { - this.getQrFirst().then(async (res) => { + return new Promise((resolve, reject) => { + this._xlogin(this.email,this.password).then(()=>{ + this._chanConn(); + console.info("Success Login!"); + console.info(`\n[*] Token: ${config.tokenn}`); + this.config.Headers['X-Line-Access'] = config.tokenn; + this._channel.issueChannelToken("1341209950",(err, result)=>{ + config.chanToken = result.channelAccessToken; this._client.getLastOpRevision((err,result)=>{ - let xrx = result.toString().split(" "); - this.revision = xrx[0].toString() - 1; - resolve(this.longpoll()); - }) + let xrx = result.toString().split(" "); + this.revision = xrx[0].toString() - 1; + resolve(this.longpoll()); + }) }); }) - } + }); + } else { + return new Promise((resolve, reject) => { + this.getQrFirst().then(async (res) => { + this._client.getLastOpRevision((err,result)=>{ + let xrx = result.toString().split(" "); + this.revision = xrx[0].toString() - 1; + resolve(this.longpoll()); + }) + }); + }) + } } async fetchOps(rev) { @@ -96,7 +78,7 @@ class LineConnect extends LineAPI { longpoll() { return new Promise((resolve, reject) => { - this._fetchOps(this.revision, 5).then((operations) => { + this._fetchOperations(this.revision, 50).then((operations) => { if (!operations) { console.log('No operations'); reject('No operations'); diff --git a/src/main.js b/src/main.js index 71bd82f..4f18303 100644 --- a/src/main.js +++ b/src/main.js @@ -1,1266 +1,94 @@ -const LineAPI = require('./api'); -const request = require('request'); -const fs = require('fs'); -const unirest = require('unirest'); -const webp = require('webp-converter'); -const path = require('path'); -const rp = require('request-promise'); -const config = require('./config'); -const { Message, OpType, Location } = require('../curve-thrift/line_types'); -//let exec = require('child_process').exec; - -const myBot = ['u1d55aeaa8b863cb338f4e8fd7a761b4b','u99f8059e2924cfa7519e26691b3cbb78']; -const banList = [];//Banned list -var groupList = new Array();//Group list -var vx = {};var midnornama,pesane,kickhim;var waitMsg = "no";//DO NOT CHANGE THIS -const imgArr = ['png','jpg','jpeg','gif','bmp','webp'];//DO NOT CHANGE THIS -var komenTL = "Sudah Dilike Bro, Jangan Ngemis Lagi"; //Comment for timeline -var bcText = "Masukan teks untuk broadcast"; -var limitposts = '10'; //Output timeline post - -function isAdminOrBot(param) { - return myBot.includes(param); -} - -function isBanned(banList, param) { - return banList.includes(param); -} - -function firstToUpperCase(str) { - return str.substr(0, 1).toUpperCase() + str.substr(1); -} - -function isTGet(string,param){ - return string.includes(param); -} - -function isImg(param) { - return imgArr.includes(param); -} - -function ambilKata(params, kata1, kata2){ - if(params.indexOf(kata1) === false) return false; - if(params.indexOf(kata2) === false) return false; - let start = params.indexOf(kata1) + kata1.length; - let end = params.indexOf(kata2, start); - let returns = params.substr(start, end - start); - return returns; -} - -class LINE extends LineAPI { - constructor() { - super(); - this.limitposts = limitposts; //Output timeline post - this.receiverID = ''; - this.checkReader = []; - this.stateStatus = { - autojoin: 0, //0 = No, 1 = Yes - cancel: 0, //0 = Auto cancel off, 1 = on - kick: 1, //1 = Yes, 0 = No - mute: 0, //1 = Mute, 0 = Unmute - protect: 1, //Protect Qr,Kicker - qr: 0, //0 = Gk boleh, 1 = Boleh - salam: 1 //1 = Yes, 0 = No - } - this.keyhelp = "\n\ -π”‘π”¬β„Œπ”’π”žπ”‘ ᴄᴏᴍᴍᴀɴᴅs\n\n\ -⍟Main Menu\n\ - β€’absen\n\ - β€’bubar\n\ - β€’vykhodi\n\ - β€’speed\n\ - β€’tagall\n\ - β€’kepo\n\ - β€’myid\n\ - β€’cekid\n\ - β€’banlist\n\ - β€’Apakah\n\ - β€’gURL\n\ - β€’ginfo\n\ -⍟Admin Menu\n\ - β€’adminutil\n\ - β€’mute\n\ - β€’unmute\n\ - β€’refresh\n\ - β€’ban\n\ - β€’unban\n\ - β€’kickban\n\ - β€’grouputil\n\ - β€’α΄ΜΆα΄˜ΜΆΚ€ΜΆα΄€ΜΆα΄‹ΜΆα΄‡ΜΆΙ΄ΜΆΜΆ\n\ -⍟Settings -\n\n\ π”‘π”¬β„Œπ”’π”žπ”‘ α΄„/ᴏ ʏᴏᴜɴɒ\n\ -α΄…α΄‡κœ°ΙͺΙ΄ΙͺΙ΄Ι’ Κα΄α΄œΚ€ ᴀʀᴇᴀ\n\ -α΄€κœ± α΄›Κœα΄‡ Κα΄α΄œΙ΄Ι’α΄€Κ€α΄‡α΄€\n\"; - var that = this; - } - getOprationType(operations) { - for (let key in OpType) { - if(operations.type == OpType[key]) { - //if(key !== 'NOTIFIED_UPDATE_PROFILE') { - console.info(`[* ${operations.type} ] ${key} `); - //} - } - } - } - - poll(operation) { - if(operation.type == 25 || operation.type == 26) { - const txt = (operation.message.text !== '' && operation.message.text != null ) ? operation.message.text : '' ; - let message = new Message(operation.message); - this.receiverID = message.to = (operation.message.to === myBot[0]) ? operation.message.from_ : operation.message.to ; - Object.assign(message,{ ct: operation.createdTime.toString() }); - if(waitMsg == "yes" && operation.message.from_ == vx[0] && this.stateStatus.mute != 1){ - this.textMessage(txt,message,message.text) - }else if(this.stateStatus.mute != 1){this.textMessage(txt,message); - }else if(txt == "unmute" && isAdminOrBot(operation.message.from_) && this.stateStatus.mute == 1){ - this.stateStatus.mute = 0; - this._sendMessage(message,"ヽ(^。^)γƒŽ") - }else{console.info("muted");} - } - - if(operation.type == 13 && this.stateStatus.cancel == 1 && !isAdminOrBot(operation.param2)) {//someone inviting.. - this.cancelAll(operation.param1); - } - - //if(operation.type == 2 || operation.type == 1 || operation.type == 53 || operation.type == 43 || operation.type == 41 || operation.type == 24 || operation.type == 15 || operation.type == 21){console.info(operation);} - - if(operation.type == 16 && this.stateStatus.salam == 1){//join group - let halo = new Message(); - halo.to = operation.param1; - halo.text = "Welcome Saya\n"; - this._client.sendMessage(0, halo); - } - - if(operation.type == 17 && this.stateStatus.salam == 1 && isAdminOrBot(operation.param2)) {//ada yang join - let halobos = new Message(); - halobos.to = operation.param1; - halobos.toType = 2; - halobos.text = "Welcome Bro\n"; - this._client.sendMessage(0, halobos); - }else if(operation.type == 17 && this.stateStatus.salam == 1){//ada yang join - let seq = new Message(); - seq.to = operation.param1; - //halo.siapa = operation.param2; - this.textMessage("0101",seq,operation.param2,1); - //this._client.sendMessage(0, halo); - } - - if(operation.type == 15 && isAdminOrBot(operation.param2)) {//ada yang leave - let babay = new Message(); - babay.to = operation.param1; - babay.toType = 2; - babay.text = "#outinpeace\n"; - this._invite(operation.param1,[operation.param2]); - this._client.sendMessage(0, babay); - }else if(operation.type == 15 && !isAdminOrBot(operation.param2)){ - let seq = new Message(); - seq.to = operation.param1; - this.textMessage("0102",seq,operation.param2,1); - } - - if(operation.type == 5 && this.stateStatus.salam == 1) {//someone adding me.. - let halo = new Message(); - halo.to = operation.param1; - halo.text = "Thanks For Adding Me :)"; - this._client.sendMessage(0, halo); - } - - if(operation.type == 19 && !isAdminOrBot(operation.param2)) { //ada kick - // op1 = group nya - // op2 = yang 'nge' kick - // op3 = yang 'di' kick - let kasihtau = new Message(); - kasihtau.to = operation.param1; - if(isAdminOrBot(operation.param3)) { - this.textMessage("0105",kasihtau,operation.param3,1); - //this._inviteIntoGroup(operation.param1,operation.param3); - //kasihtau.text = "Jangan kick botku !"; - //this._client.sendMessage(0, kasihtau); - var kickhim = 'yes'; - }else if(!isAdminOrBot(operation.param3)){ - this.textMessage("0106",kasihtau,operation.param3,1); - if(!isAdminOrBot(operation.param2)){ - kasihtau.text = "γ€ŽTERCYDUCK』 ketahuan ya kamu jancok"; - this._client.sendMessage(0, kasihtau); - } - if(this.stateStatus.protect == 1){ - var kickhim = 'yes'; - } - } - if(kickhim=='yes'){ - if(!isAdminOrBot(operation.param2)){ - this._kickMember(operation.param1,[operation.param2]); - }var kickhim = 'no'; - } - - } - - if(operation.type == 11 && this.stateStatus.protect == 1){//update group (open qr) - let seq = new Message(); - seq.to = operation.param1; - this.textMessage("0103",seq,operation.param2,1); - }else if(operation.type == 11 && this.stateStatus.qr == 1){ - let seq = new Message(); - seq.to = operation.param1; - this.textMessage("0104",seq,operation.param2,1); - }else if(operation.type == 11 && this.stateStatus.qr == 0){ - let seq = new Message(); - seq.to = operation.param1; - this.textMessage("0103",seq,operation.param2,1); - } - - if(operation.type == 55){ //ada reader - - const idx = this.checkReader.findIndex((v) => { - if(v.group == operation.param1) { - return v - } - }) - if(this.checkReader.length < 1 || idx == -1) { - this.checkReader.push({ group: operation.param1, users: [operation.param2], timeSeen: [operation.param3] }); - } else { - for (var i = 0; i < this.checkReader.length; i++) { - if(this.checkReader[i].group == operation.param1) { - if(!this.checkReader[i].users.includes(operation.param2)) { - this.checkReader[i].users.push(operation.param2); - this.checkReader[i].timeSeen.push(operation.param3); - } - } - } - } - } - - if(operation.type == 13) { // diinvite - if(this.stateStatus.autojoin == 1 || isAdminOrBot(operation.param2)) { - return this._acceptGroupInvitation(operation.param1); - } else { - return this._cancel(operation.param1,operation.param2); - } - } - this.getOprationType(operation); - } - - async aLike(){ - if(config.chanToken && config.doing == "no"){ - config.doing = "ya"; - this._autoLike(config.chanToken,limitposts,komenTL); - } - } - - async cancelAll(gid) { - let { listPendingInvite } = await this.searchGroup(gid); - for (var i = 0; i < listPendingInvite.length; i++) { - if(!this.isAdminOrBot(listPendingInvite[i].mid)){ - this._cancel(gid,listPendingInvite); - } - } - } - - async searchGroup(gid) { - let listPendingInvite = []; - let thisgroup = await this._getGroups([gid]); - if(thisgroup[0].invitee !== null) { - listPendingInvite = thisgroup[0].invitee.map((key) => { - return key.mid; - }); - } - let listMember = thisgroup[0].members.map((key) => { - return { mid: key.mid, dn: key.displayName }; - }); - - return { - listMember, - listPendingInvite - } - } - - async matchPeople(param, nama) {//match name - for (var i = 0; i < param.length; i++) { - let orangnya = await this._client.getContacts([param[i]]); - if(orangnya[0].displayName == nama){ - return orangnya; - break; - } - } - } - - async isInGroup(param, mid) { - let { listMember } = await this.searchGroup(param); - for (var i = 0; i < listMember.length; i++) { - if(listMember[i].mid == mid){ - return listMember[i].mid; - break; - } - } - } - - async isItFriend(mid){ - let listFriends = await this._getAllContactIds();let friend = "no"; - for(var i = 0; i < listFriends.length; i++){ - if(listFriends[i] == mid){ - friend = "ya";break; - } - } - return friend; - } - - - async searchRoom(rid) { - let thisroom = await this._getRoom(rid); - let listMemberr = thisroom.contacts.map((key) => { - return { mid: key.mid, dn: key.displayName }; - }); - - return { - listMemberr - } - } - - setState(seq,param) { - if(param == 1){ - let isinya = "Setting\n"; - for (var k in this.stateStatus){ - if (typeof this.stateStatus[k] !== 'function') { - if(this.stateStatus[k]==1){ - isinya += " "+firstToUpperCase(k)+" ➞ π™Šπ™‰\n"; - }else{ - isinya += " "+firstToUpperCase(k)+" ➞ π™Šπ™π™\n"; - } - } - }this._sendMessage(seq,isinya); - }else{ - if(isAdminOrBot(seq.from_)){ - let [ actions , status ] = seq.text.split(' '); - const action = actions.toLowerCase(); - const state = status.toLowerCase() == 'on' ? 1 : 0; - this.stateStatus[action] = state; - let isinya = "Setting\n"; - for (var k in this.stateStatus){ - if (typeof this.stateStatus[k] !== 'function') { - if(this.stateStatus[k]==1){ - isinya += " "+firstToUpperCase(k)+" ➞ π™Šπ™‰\n"; - }else{ - isinya += " "+firstToUpperCase(k)+" ➞ π™Šπ™π™\n"; - } - } - } - //this._sendMessage(seq,`Status: \n${JSON.stringify(this.stateStatus)}`); - this._sendMessage(seq,isinya); - } else { - this._sendMessage(seq,`Not permitted!`); - }} - } - - mention(listMember) { - let mentionStrings = ['']; - let mid = ['']; - for (var i = 0; i < listMember.length; i++) { - mentionStrings.push('@'+listMember[i].displayName+'\n'); - mid.push(listMember[i].mid); - } - let strings = mentionStrings.join(''); - let member = strings.split('@').slice(1); - - let tmp = 0; - let memberStart = []; - let mentionMember = member.map((v,k) => { - let z = tmp += v.length + 1; - let end = z - 1; - memberStart.push(end); - let mentionz = `{"S":"${(isNaN(memberStart[k - 1] + 1) ? 0 : memberStart[k - 1] + 1 ) }","E":"${end}","M":"${mid[k + 1]}"}`; - return mentionz; - }) - return { - names: mentionStrings.slice(1), - cmddata: { MENTION: `{"MENTIONEES":[${mentionMember}]}` } - } - } - - async tagAlls(seq){ - let { listMember } = await this.searchGroup(seq.to); - seq.text = ""; - let mentionMemberx = []; - for (var i = 0; i < listMember.length; i++) { - if(seq.text == null || typeof seq.text === "undefined" || !seq.text){ - let namanya = listMember[i].dn; - let midnya = listMember[i].mid; - seq.text += "@"+namanya+" "; - let member = [namanya]; - - let tmp = 0; - let mentionMember1 = member.map((v,k) => { - let z = tmp += v.length + 3; - let end = z; - let mentionz = `{"S":"0","E":"${end}","M":"${midnya}"}`; - return mentionz; - }) - mentionMemberx.push(mentionMember1); - //const tag = {cmddata: { MENTION: `{"MENTIONEES":[${mentionMember}]}` }} - //seq.contentMetadata = tag.cmddata; - //this._client.sendMessage(0, seq); - }else{ - let namanya = listMember[i].dn; - let midnya = listMember[i].mid; - let kata = seq.text.split(""); - let panjang = kata.length; - seq.text += "@"+namanya+" \n"; - let member = [namanya]; - - let tmp = 0; - let mentionMember = member.map((v,k) => { - let z = tmp += v.length + 3; - let end = z + panjang; - let mentionz = `{"S":"${panjang}","E":"${end}","M":"${midnya}"}`; - return mentionz; - }) - mentionMemberx.push(mentionMember); - } - } - const tag = {cmddata: { MENTION: `{"MENTIONEES":[${mentionMemberx}]}` }} - seq.contentMetadata = tag.cmddata; - this._client.sendMessage(0, seq); - } - - mension(listMember) { - let mentionStrings = ['']; - let mid = ['']; - mentionStrings.push('@'+listMember.displayName+'\n'); - mid.push(listMember.mid); - let strings = mentionStrings.join(''); - let member = strings.split('@').slice(1); - - let tmp = 0; - let memberStart = []; - let mentionMember = member.map((v,k) => { - let z = tmp += v.length + 1; - let end = z - 1; - memberStart.push(end); - let mentionz = `{"S":"${(isNaN(memberStart[k - 1] + 1) ? 0 : memberStart[k - 1] + 1 ) }","E":"${end}","M":"${mid[k + 1]}"}`; - return mentionz; - }) - return { - names: mentionStrings.slice(1), - cmddata: { MENTION: `{"MENTIONEES":[${mentionMember}]}` } - } - } - - async recheck(cs,group) { - let users; - for (var i = 0; i < cs.length; i++) { - if(cs[i].group == group) { - users = cs[i].users; - } - } - - let contactMember = await this._getContacts(users); - return contactMember.map((z) => { - return { displayName: z.displayName, mid: z.mid }; - }); - } - - async leftGroupByName(payload) { - let groupID = await this._getGroupsJoined(); - for(var i = 0; i < groupID.length; i++){ - let groups = await this._getGroups(groupID); - for(var ix = 0; ix < groups.length; ix++){ - if(groups[ix].name == payload){ - this._client.leaveGroup(0,groups[ix].id); - break; - } - } - } - } - - removeReaderByGroup(groupID) { - const groupIndex = this.checkReader.findIndex(v => { - if(v.group == groupID) { - return v - } - }) - - if(groupIndex != -1) { - this.checkReader.splice(groupIndex,1); - } - } - - async textMessage(textMessages, seq, param, lockt) { - const [ cmd, payload ] = textMessages.split(' '); - const gTicket = textMessages.split('line://ti/g/'); - const linktxt = textMessages.split('http'); - const txt = textMessages.toLowerCase(); - const messageID = seq.id; - const cot = txt.split('@'); - const com = txt.split(':'); - const cox = txt.split(' '); - - if(vx[1] == "cekid" && seq.from_ == vx[0] && waitMsg == "yes"){ - let panjang = txt.split(""); - if(txt == "cancel"){ - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"#CANCELLED"); - }else if(seq.contentType == 13){ - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - let midnya = seq.contentMetadata.mid; - let bang = new Message(); - bang.to = seq.to; - bang.text = midnya; - this._client.sendMessage(0, bang); - }else if(txt == "me"){ - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - seq.text = seq.from_.toString(); - this._client.sendMessage(0, seq); - }else if(cot[1]){ - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - let cekid = new Message(); - cekid.to = seq.to; - let ment = seq.contentMetadata.MENTION; - let xment = JSON.parse(ment);let pment = xment.MENTIONEES[0].M; - - cekid.text = JSON.stringify(pment).replace(/"/g , ""); - this._client.sendMessage(0, cekid); - }else{ - let bang = new Message(); - bang.to = seq.to; - bang.text = "Ketik cekid lalu tag orangnya :)"; - this._client.sendMessage(0,bang); - } - } - if(txt == "cekid" && !isBanned(banList, seq.from_)){ - if(vx[2] == null || typeof vx[2] === "undefined" || !vx[2]){ - waitMsg = "yes"; - vx[0] = seq.from_;vx[1] = txt;vx[2] = "arg1"; - this._sendMessage(seq,"Silahkan Tag Orangnya"); - }else{ - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"#CANCELLED"); - } - }else if(txt == 'cekid' && isBanned(banList, seq.from_)){this._sendMessage(seq,"Not permitted !");} - - if(vx[1] == "kepo" && seq.from_ == vx[0] && waitMsg == "yes"){ - let panjang = txt.split(""); - if(txt == "cancel"){ - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"#CANCELLED"); - }else if(seq.contentType == 13){ - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - let midnya = seq.contentMetadata.mid; - let timeline_post = await this._getHome(midnya,this.config.chanToken); - let bang = new Message(); - bang.to = seq.to; - - let orangnya = await this._getContacts([midnya]);let vp,xvp; - if(orangnya[0].videoProfile !== null && orangnya[0].videoProfile !== undefined){ - vp = orangnya[0].videoProfile.tids.mp4; - xvp = "\nVideo Profile: \nhttp://dl.profile.line.naver.jp"+orangnya[0].picturePath+"/"+vp; - }else{xvp='';} - let ress = timeline_post.result; - bang.text = -"\nNama: "+orangnya[0].displayName+"\n\ -\nID: \n"+orangnya[0].mid+"\n\ -\nProfile Picture: \nhttp://dl.profile.line.naver.jp"+orangnya[0].picturePath+"\n\ -\nCover Picture: \nhttp://dl.profile.line-cdn.net/myhome/c/download.nhn?userid="+orangnya[0].mid+"&oid="+ress.homeInfo.objectId+"\n\ -"+xvp+"\n\ -\nStatus: \n"+orangnya[0].statusMessage+""; - this._client.sendMessage(0,bang); - }else if(cot[1]){ - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - let bang = new Message(); - bang.to = seq.to; - let ment = seq.contentMetadata.MENTION; - let xment = JSON.parse(ment);let pment = xment.MENTIONEES[0].M; - let timeline_post = await this._getHome(pment,this.config.chanToken); - - let orangnya = await this._getContacts([pment]);let vp,xvp; - if(orangnya[0].videoProfile !== null && orangnya[0].videoProfile !== undefined){ - vp = orangnya[0].videoProfile.tids.mp4; - xvp = "\nVideo Profile: \nhttp://dl.profile.line.naver.jp"+orangnya[0].picturePath+"/"+vp; - }else{xvp='';} - let ress = timeline_post.result; - bang.text = -"\nNama: "+orangnya[0].displayName+"\n\ -\nID: \n"+orangnya[0].mid+"\n\ -\nProfile Picture: \nhttp://dl.profile.line.naver.jp"+orangnya[0].picturePath+"\n\ -\nCover Picture: \nhttp://dl.profile.line-cdn.net/myhome/c/download.nhn?userid="+orangnya[0].mid+"&oid="+ress.homeInfo.objectId+"\n\ -"+xvp+"\n\ -\nStatus: \n"+orangnya[0].statusMessage+""; - this._client.sendMessage(0,bang); - }else if(vx[2] == "arg1" && panjang.length > 30 && panjang[0] == "u"){ - let timeline_post = await this._getHome(txt,this.config.chanToken); - let orangnya = await this._getContacts([txt]);let vp,xvp; - if(orangnya[0].videoProfile !== null && orangnya[0].videoProfile !== undefined){ - vp = orangnya[0].videoProfile.tids.mp4; - xvp = "\nVideo Profile: \nhttp://dl.profile.line.naver.jp"+orangnya[0].picturePath+"/"+vp; - }else{xvp='';} - let ress = timeline_post.result; - seq.text = -"\nNama: "+orangnya[0].displayName+"\n\ -\nID: \n"+orangnya[0].mid+"\n\ -\nProfile Picture: \nhttp://dl.profile.line.naver.jp"+orangnya[0].picturePath+"\n\ -\nCover Picture: \nhttp://dl.profile.line-cdn.net/myhome/c/download.nhn?userid="+orangnya[0].mid+"&oid="+ress.homeInfo.objectId+"\n\ -"+xvp+"\n\ -\nStatus: \n"+orangnya[0].statusMessage+""; -vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,seq.text); - }else{ - let bang = new Message(); - bang.to = seq.to; - bang.text = "Ketik kepo lalu tag orangnya"; - this._client.sendMessage(0,bang); - } - } - if(txt == "kepo" && !isBanned(banList, seq.from_)){ - if(vx[2] == null || typeof vx[2] === "undefined" || !vx[2]){ - waitMsg = "yes"; - vx[0] = seq.from_;vx[1] = txt;vx[2] = "arg1"; - this._sendMessage(seq,"Silahkan tag orangnya"); - }else{ - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"#CANCELLED"); - } - }else if(txt == 'kepo' && isBanned(banList, seq.from_)){this._sendMessage(seq,"Not permitted !");} - - if(vx[1] == "ban" && seq.from_ == vx[0] && waitMsg == "yes"){ - let panjang = txt.split(""); - if(txt == "cancel"){ - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"#CANCELLED"); - }else if(cot[1]){ - let ment = seq.contentMetadata.MENTION; - let xment = JSON.parse(ment);let pment = xment.MENTIONEES[0].M; - let msg = new Message();msg.to = seq.to; - if(isBanned(banList,pment)){ - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - msg.text = cot[1]+" γ€Œπ™π˜Όπ™„π™‡π™€π˜Ώγ€ Target Telah Masuk Daftar Banlist"; - this._client.sendMessage(0,msg); - }else{ - msg.text = "γ€Œπ™Žπ™π˜Ύπ˜Ύπ™€π™Žπ™Žγ€ Berhasil Menambahkan Kedaftar Banlist"; - this._client.sendMessage(0, msg); - banList.push(pment); - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - } - }else if(seq.contentType == 13){ - let midnya = seq.contentMetadata.mid;let msg = new Message();msg.to = seq.to; - if(isBanned(banList,midnya)){ - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - msg.text = "γ€Œπ™π˜Όπ™„π™‡π™€π˜Ώγ€ Target Telah Masuk Daftar Banlist"; - this._client.sendMessage(0, msg); - }else{ - msg.text = "γ€Œπ™Žπ™π˜Ύπ˜Ύπ™€π™Žπ™Žγ€ Berhasil Menambahkan Kedaftar Banlist"; - this._client.sendMessage(0, msg); - banList.push(midnya); - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - } - }else if(panjang.length > 30 && panjang[0] == "u"){ - if(isBanned(banList,txt)){ - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"γ€Œπ™π˜Όπ™„π™‡π™€π˜Ώγ€ Target Telah Masuk Daftar Banlist"); - }else{ - let msg = new Message();msg.to = seq.to;msg.text = "γ€Œπ™Žπ™π˜Ύπ˜Ύπ™€π™Žπ™Žγ€ Berhasil Menambahkan Kedaftar Banlist"; - this._client.sendMessage(0, msg); - banList.push(txt); - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - } - }else{ - this._sendMessage(seq,"Ketika ban lalu tag orangnya"); - } - } - if(txt == "ban" && isAdminOrBot(seq.from_)){ - if(vx[2] == null || typeof vx[2] === "undefined" || !vx[2]){ - waitMsg = "yes"; - vx[0] = seq.from_;vx[1] = txt; - this._sendMessage(seq,"Ban siapa ?"); - vx[2] = "arg1"; - this._sendMessage(seq,"Silahkan tag orangnya"); - }else{ - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"#CANCELLED"); - } - }else if(txt == "ban" && !isAdminOrBot(seq.from_)){this._sendMessage(seq,"Not permitted !");} - - if(vx[1] == "adminutil" && seq.from_ == vx[0] && waitMsg == "yes"){ - let panjang = txt.split(""); - let M = new Message();M.to = seq.to; - let xtxt = ""; - if(txt == "cancel"){ - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"#CANCELLED"); - }else if(vx[2] == "arg1"){ - switch(txt){ - case 'add': - vx[2] = "arg2";vx[3] = txt; - this._sendMessage(seq,"Silahkan Tag Orangnya"); - break; - case 'del': - vx[2] = "arg2";vx[3] = txt;xtxt = "γ€Œ Admin List 」\n\n"; - await this._sendMessage(seq,"Pilih admin yang mau dihapus"); - for(var i=0; i < myBot.length; i++){ - let numb = i+1; - let xcontact = await this._client.getContact(myBot[i]); - xtxt += numb+"). "+xcontact.displayName+"\n"; - } - M.text = xtxt; - this._client.sendMessage(0, M); - break; - case 'list': - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - for(var i=0; i < myBot.length; i++){ - let numb = i+1; - let xcontact = await this._client.getContact(myBot[i]); - xtxt += numb+"). "+xcontact.displayName+"\n"; - } - M.text = xtxt; - this._client.sendMessage(0, M); - break; - default: - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"#CANCELLED"); - break; - } - }else if(vx[2] == "arg2" && vx[3] == "add"){ - if(cot[1]){ - let ment = seq.contentMetadata.MENTION; - let xment = JSON.parse(ment);let pment = xment.MENTIONEES[0].M; - let msg = new Message();msg.to = seq.to; - if(isAdminOrBot(pment)){ - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - msg.text = "γ€Œπ™π˜Όπ™„π™‡π™€π˜Ώγ€ "+cot[1]+" Telah Masuk Daftar Admin"; - this._client.sendMessage(0,msg); - }else{ - msg.text = "γ€Œπ™Žπ™π˜Ύπ˜Ύπ™€π™Žπ™Žγ€ Berhasil Menambahkan Kedaftar Admin"; - this._client.sendMessage(0, msg); - myBot.push(pment); - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - } - }else if(seq.contentType == 13){ - let midnya = seq.contentMetadata.mid;let msg = new Message();msg.to = seq.to; - if(isAdminOrBot(midnya)){ - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - msg.text = "γ€Œπ™π˜Όπ™„π™‡π™€π˜Ώγ€ Target Telah Masuk Daftar Admin"; - this._client.sendMessage(0, msg); - }else{ - msg.text = "γ€Œπ™Žπ™π˜Ύπ˜Ύπ™€π™Žπ™Žγ€ Berhasil Menambahkan Kedaftar Admin"; - this._client.sendMessage(0, msg); - myBot.push(midnya); - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - } - }else if(panjang.length > 30 && panjang[0] == "u"){ - if(isAdminOrBot(txt)){ - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"γ€Œπ™π˜Όπ™„π™‡π™€π˜Ώγ€ Target Telah Masuk Daftar Banlist"); - }else{ - let msg = new Message();msg.to = seq.to;msg.text = "γ€Œπ™Žπ™π˜Ύπ˜Ύπ™€π™Žπ™Žγ€ Berhasil Menambahkan Kedaftar Banlist"; - this._client.sendMessage(0, msg); - myBot.push(txt); - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - } - } - }else if(vx[2] == "arg2" && vx[3] == "del"){ - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - let ment = txt-1; - if (ment > myBot.length) { - myBot.splice(ment, 1); - this._sendMessage(seq,"Berhasil !"); - }else{ - this._sendMessage(seq,"Admin tidak ada !"); - } - } - } - if(txt == "adminutil" && isAdminOrBot(seq.from_)){ - if(vx[2] == null || typeof vx[2] === "undefined" || !vx[2]){ - waitMsg = "yes"; - vx[0] = seq.from_;vx[1] = txt; - vx[2] = "arg1"; - this._sendMessage(seq,"γ€Œ Administrator Utility 」\n\n- Add admin = add\n- Delete admin = del\n- List admin = list"); - }else{ - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"#CANCELLED"); - } - }else if(txt == "adminutil" && !isAdminOrBot(seq.from_)){this._sendMessage(seq,"Not permitted !");} - - if(vx[1] == "unban" && seq.from_ == vx[0] && waitMsg == "yes"){ - let panjang = txt.split(""); - if(txt == "cancel"){ - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"#CANCELLED"); - }else if(cot[1]){ - let ment = seq.contentMetadata.MENTION; - let xment = JSON.parse(ment);let pment = xment.MENTIONEES[0].M; - let bang = new Message();bang.to = seq.to; - if(isBanned(banList, pment)){ - let ment = banList.indexOf(pment); - if (ment > -1) { - banList.splice(ment, 1); - } - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - bang.text = "γ€Œπ™Žπ™π˜Ύπ˜Ύπ™€π™Žπ™Žγ€ Berhasil Menghapus Dari Daftar Banlist"; - this._client.sendMessage(0,bang); - }else{ - bang.text = "γ€Œπ™π˜Όπ™„π™‡π™€π˜Ώγ€ Target Tidak Masuk Daftar Banlist"; - this._client.sendMessage(0, bang); - } - }else if(seq.contentType == 13){ - let midnya = seq.contentMetadata.mid;let bang = new Message();bang.to = seq.to; - if(isBanned(banList, midnya)){ - let ment = banList.indexOf(midnya); - if (ment > -1) { - banList.splice(ment, 1); - } - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - bang.text = "γ€Œπ™Žπ™π˜Ύπ˜Ύπ™€π™Žπ™Žγ€ Berhasil Menghapus Dari Daftar Banlist"; - this._client.sendMessage(0,bang); - }else{ - bang.text = "γ€Œπ™π˜Όπ™„π™‡π™€π˜Ώγ€ Target Tidak Masuk Daftar Banlist"; - this._client.sendMessage(0, bang); - } - }else if(panjang.length > 30 && panjang[0] == "u"){ - let bang = new Message();bang.to = seq.to; - if(isBanned(banList, txt)){ - let ment = banList.indexOf(txt); - if (ment > -1) { - banList.splice(ment, 1); - } - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - bang.text = "γ€Œπ™Žπ™π˜Ύπ˜Ύπ™€π™Žπ™Žγ€ Berhasil Menghapus Dari Daftar Banlist"; - this._client.sendMessage(0,bang); - }else{ - this._sendMessage(seq,"γ€Œπ™π˜Όπ™„π™‡π™€π˜Ώγ€ Target Tidak Masuk Daftar Banlist"); - } - }else{ - this._sendMessage(seq,"Ketik unban lalu tag orangnya"); - } - } - if(txt == "unban" && isAdminOrBot(seq.from_)){ - if(vx[2] == null || typeof vx[2] === "undefined" || !vx[2]){ - waitMsg = "yes"; - vx[0] = seq.from_;vx[1] = txt; - seq.text = ""; - for(var i = 0; i < banList.length; i++){ - let orangnya = await this._getContacts([banList[i]]); - seq.text += "\n-["+orangnya[0].mid+"]["+orangnya[0].displayName+"]"; - } - this._sendMessage(seq,seq.text); - this._sendMessage(seq,"unban siapa ?"); - vx[2] = "arg1"; - }else{ - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"#CANCELLED"); - } - }else if(txt == "unban" && !isAdminOrBot(seq.from_)){this._sendMessage(seq,"Not permitted !");} - - if(txt == "banlist"){ - seq.text = "[Mid] [Name]\n\n"; - for(var i = 0; i < banList.length; i++){ - let orangnya = await this._getContacts([banList[i]]); - seq.text += "["+orangnya[0].mid+"]["+orangnya[0].displayName+"]\n"; - } - this._sendMessage(seq,seq.text); - } - - if(txt == "bubar" && isAdminOrBot(seq.from_)){ - this._sendMessage(seq,""+displayName+" Pamit") - this._client.leaveGroup(0,seq.to); - } - - if(txt == "mute" && isAdminOrBot(seq.from_)){ - this.stateStatus.mute = 1; - this._sendMessage(seq,"(*Β΄οΉƒο½€*)") - } - - if(txt == 'opraken' && this.stateStatus.cancel == 1 && isAdminOrBot(seq.from_)) { - let { listMember } = await this.searchGroup(seq.to); - for (var i = 0; i < listMember.length; i++) { - if(!isAdminOrBot(listMember[i].mid)){ - this.cancelAll(seq.to,[listMember[i].mid]); - } - } - }else if(txt == "opraken" && !isAdminOrBot(seq.from_)){this._sendMessage(seq,"Not permitted !");} - - if(txt == 'absen') { - let { mid, displayName } = await this._client.getProfile(); - this._sendMessage(seq, ''+displayName+' Hadir'); - } - - if(vx[1] == "grouputil" && seq.from_ == vx[0] && waitMsg == "yes"){ - if(vx[2]=="arg1"){ - let M = new Message(); - let listGroups = await this._client.getGroupIdsJoined(); - let xtxt = "γ€Œ Group List 」\n\n"; - switch(txt){ - case 'list': - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = "";groupList = []; - M.to = seq.to; - listGroups.forEach(function(item, index, array) { - groupList.push(item); - }); - for(var i = 0; i < groupList.length; i++){ - let numb = i + 1; - let groupInfo = await this._client.getGroup(groupList[i]); - let gname = groupInfo.name; - let memberCount = groupInfo.members.length; - xtxt += numb+"). "+gname+" ("+memberCount+")\n"; - } - M.text = xtxt; - this._client.sendMessage(0, M); - break; - case 'ticket': - vx[2] = "arg2";vx[3] = "ticket";M.to = seq.to;groupList = []; - M.text = "Pilih nomor group dibawah ini !"; - await this._client.sendMessage(0, M); - listGroups.forEach(function(item, index, array) { - groupList.push(item); - }); - for(var i = 0; i < groupList.length; i++){ - let numb = i + 1; - let groupInfo = await this._client.getGroup(groupList[i]); - let gname = groupInfo.name; - let memberCount = groupInfo.members.length; - xtxt += numb+"). "+gname+" ("+memberCount+")\n"; - } - M.text = xtxt; - this._client.sendMessage(0, M); - break; - default: - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"#CANCELLED"); - }}else if(vx[2] == "arg2" && vx[3] == "ticket"){ - vx[0] = "";vx[1] = "";waitMsg = "no";vx[2] = "";vx[3] = ""; - if(typeof groupList[txt - 1] !== 'undefined') { - let updateGroup = await this._getGroup(groupList[txt - 1]); - if(updateGroup.preventJoinByTicket === true) { - updateGroup.preventJoinByTicket = false; - await this._updateGroup(updateGroup); - } - const groupUrl = await this._reissueGroupTicket(groupList[txt - 1]); - this._sendMessage(seq,"Line Group -> line://ti/g/"+groupUrl); - }else{this._sendMessage(seq,"Group tidak ada !");} - } - } - if(txt == "grouputil" && isAdminOrBot(seq.from_)){ - if(vx[2] == null || typeof vx[2] === "undefined" || !vx[2]){ - waitMsg = "yes"; - vx[0] = seq.from_;vx[1] = txt; - this._sendMessage(seq,"γ€Œ Group Utility 」\n- Grouplist = list\n- Group Ticket = ticket\n"); - vx[2] = "arg1"; - }else{ - waitMsg = "no";vx[0] = "";vx[1] = "";vx[2] = "";vx[3] = ""; - this._sendMessage(seq,"#CANCELLED"); - } - }else if(txt == "grouputil" && !isAdminOrBot(seq.from_)){this._sendMessage(seq,"Not permitted !");} - - if(txt == "vykhodi" && seq.toType == 2 && !isBanned(banList, seq.from_) && this.stateStatus.kick == 1){ - this._sendMessage(seq,"Ok bang !"); - this._kickMember(seq.to,[seq.from_]); - }else if(txt == 'vykhodi' && isBanned(banList, seq.from_)){this._sendMessage(seq,"Not permitted !");} - - - if(txt == "refresh" && isAdminOrBot(seq.from_)){ - this._sendMessage(seq, "Clean all message...."); - await this._client.removeAllMessages(); - this._sendMessage(seq, "Done !"); - } - - const sp = ['speed','sp','speed','resp','respon']; - if(sp.includes(txt) && !isBanned(banList, seq.from_)) { - const curTime = (Date.now() / 1000);let M = new Message();M.to=seq.to;M.text = '';M.contentType = 1;M.contentPreview = null;M.contentMetadata = null; - await this._client.sendMessage(0,M); - const rtime = (Date.now() / 1000); - const xtime = rtime - curTime; - this._sendMessage(seq, xtime+' second'); - }else if(sp.includes(txt) && isBanned(banList, seq.from_)){this._sendMessage(seq,"Not permitted !");} - - if(txt == 'speed' && !isBanned(banList, seq.from_)) { - const curTime = Math.floor(Date.now() / 1000);let M = new Message();M.to=seq.to;M.text = '';M.contentType = 1;M.contentPreview = null;M.contentMetadata = null; - await this._client.sendMessage(0,M); - const rtime = Math.floor(Date.now() / 1000); - const xtime = rtime - curTime; - this._sendMessage(seq, xtime+' second'); - }else if(txt == 'speed' && isBanned(banList, seq.from_)){this._sendMessage(seq,"Not permitted !");} - - /*if(txt === 'kernel') { - exec('uname -a;ptime;id;whoami',(err, sto) => { - this._sendMessage(seq, sto); - }) - }*/ - - if(txt === 'opraken' && this.stateStatus.kick == 1 && isAdminOrBot(seq.from_) && seq.toType == 2) { - let { listMember } = await this.searchGroup(seq.to); - for (var i = 0; i < listMember.length; i++) { - if(!isAdminOrBot(listMember[i].mid)){ - this._kickMember(seq.to,[listMember[i].mid]) - } - } - }else if(txt === 'opraken' && !isAdminOrBot(seq.from_) && seq.toType == 2){this._sendMessage(seq,"Not permitted !");} - - if(txt == 'help') { - let botOwner = await this._client.getContacts([myBot[0]]); - let { mid, displayName } = await this._client.getProfile(); - let key2 = ""; - seq.text = key2 += this.keyhelp; - this._client.sendMessage(0, seq); - } - - if(txt == '0101' && lockt == 1) {//Jangan dicoba (gk ada efek) - let { listMember } = await this.searchGroup(seq.to); - for (var i = 0; i < listMember.length; i++) { - if(listMember[i].mid==param){ - let namanya = listMember[i].dn; - seq.text = 'Welcome'; - let midnya = listMember[i].mid; - let kata = seq.text.split("@").slice(0,1); - let kata2 = kata[0].split(""); - let panjang = kata2.length; - let member = [namanya]; - - let tmp = 0; - let mentionMember = member.map((v,k) => { - let z = tmp += v.length + 1; - let end = z + panjang; - let mentionz = `{"S":"${panjang}","E":"${end}","M":"${midnya}"}`; - return mentionz; - }) - const tag = {cmddata: { MENTION: `{"MENTIONEES":[${mentionMember}]}` }} - seq.contentMetadata = tag.cmddata; - this._client.sendMessage(0, seq); - //console.info("Salam"); - } - } - } - - if(txt == "tagall" && seq.toType == 2 && !isBanned(banList, seq.from_)){ - let { listMember } = await this.searchGroup(seq.to); - for (var i = 0; i < listMember.length; i++) { - if(!isAdminOrBot(listMember[i].mid)){ - this.tagAlls(seq.to,[listMember[i].mid]); - } - } - }else if(txt == 'tagall' && isBanned(banList, seq.from_)){this._sendMessage(seq,"Not permitted !");} - - if(txt == '0103' && lockt == 1){ - let ax = await this._client.getGroup(seq.to); - if(ax.preventJoinByTicket === true){}else{ax.preventJoinByTicket = true;await this._client.updateGroup(0, ax);} - } - if(txt == '0104' && lockt == 1){ - let ax = await this._client.getGroup(seq.to); - if(ax.preventJoinByTicket === true){ax.preventJoinByTicket = false;await this._client.updateGroup(0, ax);}else{} - } - - if(txt == '0102' && lockt == 1) {//Jangan dicoba (gk ada efek) - let { listMember } = await this.searchGroup(seq.to); - for (var i = 0; i < listMember.length; i++) { - if(listMember[i].mid==param){ - let namanya = listMember[i].dn; - seq.text = 'Goodbye ! @'+namanya; - let midnya = listMember[i].mid; - let kata = seq.text.split("@").slice(0,1); - let kata2 = kata[0].split(""); - let panjang = kata2.length; - let member = [namanya]; - - let tmp = 0; - let mentionMember = member.map((v,k) => { - let z = tmp += v.length + 1; - let end = z + panjang; - let mentionz = `{"S":"${panjang}","E":"${end}","M":"${midnya}"}`; - return mentionz; - }) - const tag = {cmddata: { MENTION: `{"MENTIONEES":[${mentionMember}]}` }} - seq.contentMetadata = tag.cmddata; - this._client.sendMessage(0, seq); - //console.info("Salam"); - } - } - } - - if(txt == 'setpoint') { - this._sendMessage(seq, `Setpoint for check reader.`); - this.removeReaderByGroup(seq.to); - } - - if(txt == 'clear') { - this.checkReader = [] - this._sendMessage(seq, `Remove all check reader on memory`); - } - - if(txt == 'recheck'){ - let rec = await this.recheck(this.checkReader,seq.to);seq.text=''; - const mentions = await this.mention(rec); - for(var i = 0; i < mentions.length; i++){ - seq.text += '\n=> '+mentions[i].displayName; - } - this._client.sendMessage(0,seq); - } - - if(txt == 'setpoint for check reader .') { - this.searchReader(seq); - } - - if(txt == 'clearall') { - this.checkReader = []; - } - - if(txt == "kickban" && isAdminOrBot(seq.from_)){ - for(var i = 0; i < banList.length; i++){ - let adaGk = await this.isInGroup(seq.to, banList[i]); - if(typeof adaGk !== "undefined" && adaGk){ - this._kickMember(seq.to,adaGk); - } - } - }else if(txt == "kickban" && !isAdminOrBot(seq.from_)){this._sendMessage(seq,"Not permitted !");} - - if(txt == "setting"){ - this.setState(seq,1) - } - - const action = ['autojoin on','autojoin off','cancel on','cancel off','kick on','kick off','salam on','salam off','protect off','protect on','qr on','qr off'] - if(action.includes(txt)) { - this.setState(seq,0) - } - - if(txt == 'myid' /*|| txt == 'mid' || txt == 'id'*/) { - this._sendMessage(seq,"ID Kamu: "+seq.from_); - } - - /* if(txt == 'speedtest' && isAdminOrBot(seq.from)) { - exec('speedtest-cli --server 6581',(err, res) => { - this._sendMessage(seq,res) - }) - }*/ - - if(txt == 'ginfo' && !isBanned(banList, seq.from_)) { - let groupInfo = await this._client.getGroup(seq.to);let gqr = 'open';let ticketg = 'line://ti/g/'; - let createdT64 = groupInfo.createdTime.toString().split(" "); - let createdTime = await this._getServerTime(createdT64[0]); - let gid = seq.to; - let gticket = groupInfo.groupPreference.invitationTicket; - if(!gticket){ticketg = "CLOSED";}else{ticketg += gticket;} - let gname = groupInfo.name; - let memberCount = groupInfo.members.length; - let gcreator = groupInfo.creator.displayName; - let pendingCount = 0; - if(groupInfo.invitee !== null){ - //console.info("pendingExist"); - pendingCount = groupInfo.invitee.length; - } - let gcover = groupInfo.pictureStatus; - let qr = groupInfo.preventJoinByTicket; - if(qr === true){ - gqr = 'close'; - } - let bang = new Message(); - bang.to = seq.to; - - bang.text = "Group Name:\n"+gname+"\n\ -Group ID:\n"+gid+"\n\ -Group Creator:\n"+gcreator+"\n\ -Group CreatedTime:\n"+createdTime+"\n\ -Group Ticket:\n"+ticketg+"\n\ -Member: "+memberCount+"\n\ -Pending: "+pendingCount+"\n\ -QR: "+gqr+"\n\ -Group Cover:\nhttp://dl.profile.line.naver.jp/"+gcover; - this._client.sendMessage(0,bang); - }else if(txt == 'ginfo' && isBanned(banList, seq.from_)){this._sendMessage(seq,"Not permitted !");} - - const joinByUrl = ['gurl','curl']; - if(joinByUrl.includes(txt) && txt == "gurl") { - this._sendMessage(seq,`Updating group ...`); - let updateGroup = await this._getGroup(seq.to);//console.info(updateGroup); - if(updateGroup.preventJoinByTicket === true) { - updateGroup.preventJoinByTicket = false; - await this._updateGroup(updateGroup); - } - const groupUrl = await this._reissueGroupTicket(seq.to) - this._sendMessage(seq,`Line group = line://ti/g/${groupUrl}`); - }else if(joinByUrl.includes(txt) && txt == "curl") { - this._sendMessage(seq,`Updating group ...`); - let updateGroup = await this._getGroup(seq.to);//console.info(updateGroup); - if(updateGroup.preventJoinByTicket === false) { - updateGroup.preventJoinByTicket = true; - await this._updateGroup(updateGroup); - seq.text = "Done !"; - }else{seq.text = "Sudah ditutup !";} - this._sendMessage(seq,seq.text); - } - - if(txt == "0105" && lockt == 1){ - let aas = new Message(); - aas.to = param; - let updateGroup = await this._getGroup(seq.to); - if(updateGroup.preventJoinByTicket === true) { - updateGroup.preventJoinByTicket = false; - await this._updateGroup(updateGroup); - } - const groupUrl = await this._reissueGroupTicket(seq.to); - aas.toType = 0; - aas.text = `!joinline://ti/g/${groupUrl}`; - this._client.sendMessage(0, aas); - } - - if(txt == "0106" && lockt == 1){ - let friend = await this.isItFriend(param); - if(friend == "no"){ - await this._client.findAndAddContactsByMid(0, param); - this._client.inviteIntoGroup(0,seq.to,[param]); - }else{this._client.inviteIntoGroup(0,seq.to,[param]);} - } - - if(gTicket[0] == "join" && isAdminOrBot(seq.from_)){ - let sudah = "no"; - let grp = await this._client.findGroupByTicket(gTicket[1]); - let lGroup = await this._client.getGroupIdsJoined(); - for(var i = 0; i < lGroup.length; i++){ - if(grp.id == lGroup[i]){ - sudah = "ya"; - } - } - if(sudah == "ya"){ - let bang = new Message(); - bang.to = seq.to; - bang.text = ""; - this._client.sendMessage(0,bang); - }else if(sudah == "no"){ - await this._acceptGroupInvitationByTicket(grp.id,gTicket[1]); - } - } - - /*if(cmd == 'join') { - const [ ticketId ] = payload.split('g/').splice(-1); - let { id } = await this._findGroupByTicket(ticketId); - await this._acceptGroupInvitationByTicket(id,ticketId); - }*/ - - /*if(cmd === 'ip') { - exec(`curl ipinfo.io/${payload}`,(err, res) => { - const result = JSON.parse(res); - if(typeof result.error == 'undefined') { - const { org, country, loc, city, region } = result; - try { - const [latitude, longitude ] = loc.split(','); - let location = new Location(); - Object.assign(location,{ - title: `Location:`, - address: `${org} ${city} [ ${region} ]\n${payload}`, - latitude: latitude, - longitude: longitude, - phone: null - }) - const Obj = { - text: 'Location', - location : location, - contentType: 0, - } - Object.assign(seq,Obj) - this._sendMessage(seq,'Location'); - } catch (err) { - this._sendMessage(seq,'Not Found'); - } - } else { - this._sendMessage(seq,'Location Not Found , Maybe di dalem goa'); - } - }) - }*/ - } - -} - -module.exports = new LINE(); \ No newline at end of file +const Command = require('./command'); +const { Message, OpType, Location, Profile } = require('../curve-thrift/line_types'); + +class LINE extends Command { + constructor() { + super(); + this.receiverID = ''; + this.checkReader = []; + this.stateStatus = { + cancel: 1, + kick: 1, + salam: 1 + }; + this.messages; + this.payload + } + + get myBot() { + const bot = ['u1d55aeaa8b863cb338f4e8fd7a761b4b','u1d55aeaa8b863cb338f4e8fd7a761b4b']; + return bot; + } + + isAdminOrBot(param) { + return this.myBot.includes(param); + } + + getOprationType(operations) { + for (let key in OpType) { + if(operations.type == OpType[key]) { + if(key !== 'NOTIFIED_UPDATE_PROFILE') { + console.info(`[* ${operations.type} ] ${key} `); + } + } + } + } + + poll(operation) { + if(operation.type == 25 || operation.type == 26) { + let message = new Message(operation.message); + this.receiverID = message.to = (operation.message.to === this.myBot[0]) ? operation.message._from : operation.message.to ; + Object.assign(message,{ ct: operation.createdTime.toString() }); + this.textMessage(message) + } + + if(operation.type == 13) { // diinvite + if(this.stateStatus.kick == 1) { + return this._acceptGroupInvitation(operation.param1); + } + } + if(operation.type == 16 && this.stateStatus.salam == 1){ + let halo = new Message(); + halo.to = operation.param1; + halo.text = "opraken"; + this._client.sendMessage(0, halo); + } + this.getOprationType(operation); + } + + command(msg, reply) { + if(this.messages.text !== null) { + if(this.messages.text === msg.trim()) { + if(typeof reply === 'function') { + reply(); + return; + } + if(Array.isArray(reply)) { + reply.map((v) => { + this._sendMessage(this.messages, v); + }) + return; + } + return this._sendMessage(this.messages, reply); + } + } + } + + async textMessage(messages) { + this.messages = messages; + let payload = (this.messages.text !== null) ? this.messages.text.split(' ').splice(1).join(' ') : '' ; + let receiver = messages.to; + let sender = messages.from; + + this.command('sp', this.getSpeed.bind(this)); + this.command(`opraken ${payload}`,this.kickAll.bind(this)); + this.command(`opraken ${payload}`,this.cancelAll.bind(this)); + this.command(`destruirlo ${payload}`,this.spamGroup.bind(this)); + this.command(`destruirlo ${payload}`,this.youngSpamGroup.bind(this)); + + } + +} + + +module.exports = LINE; diff --git a/src/pinVerifier.js b/src/pinVerifier.js index adfc7db..b4717f1 100644 --- a/src/pinVerifier.js +++ b/src/pinVerifier.js @@ -23,4 +23,4 @@ class PinVerifier { } -module.exports = PinVerifier; +module.exports = PinVerifier; \ No newline at end of file