mirror of
https://github.com/liberliber/LINE-KickBot1.git
synced 2024-09-20 06:46:01 +08:00
Add files via upload
This commit is contained in:
parent
c4aeab610e
commit
9fe2baba3f
BIN
src/LINE.png
Normal file
BIN
src/LINE.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
725
src/api.js
725
src/api.js
|
@ -16,8 +16,6 @@ const {
|
||||||
Message,
|
Message,
|
||||||
LoginRequest
|
LoginRequest
|
||||||
} = require('../curve-thrift/line_types');
|
} = require('../curve-thrift/line_types');
|
||||||
const imgArr = ['png','jpg','jpeg','gif','bmp','webp'];
|
|
||||||
|
|
||||||
|
|
||||||
const PinVerifier = require('./pinVerifier');
|
const PinVerifier = require('./pinVerifier');
|
||||||
var config = require('./config');
|
var config = require('./config');
|
||||||
|
@ -25,27 +23,14 @@ var moment = require('moment');
|
||||||
var reqx = new LoginRequest();
|
var reqx = new LoginRequest();
|
||||||
var reqxy = new LoginRequest();
|
var reqxy = new LoginRequest();
|
||||||
|
|
||||||
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 LineAPI {
|
class LineAPI {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.setTHttpClient();
|
this.setTHttpClient();
|
||||||
this.axz = false;
|
this.axz = false;
|
||||||
this.axy = false;
|
this.axy = false;
|
||||||
this.gdLine = "http://gd2.line.naver.jp";
|
this.gdLine = "http://gd2.line.naver.jp";
|
||||||
this.gdLine2 = "http://gf.line.naver.jp";
|
this.gdLine2 = "http://gf.line.naver.jp";
|
||||||
}
|
}
|
||||||
|
|
||||||
setTHttpClient(options = {
|
setTHttpClient(options = {
|
||||||
|
@ -55,7 +40,9 @@ class LineAPI {
|
||||||
path: this.config.LINE_HTTP_URL,
|
path: this.config.LINE_HTTP_URL,
|
||||||
https: true
|
https: true
|
||||||
}) {
|
}) {
|
||||||
options.headers['X-Line-Application'] = 'IOSIPAD\x097.14.0\x09iPhone_OS\x0910.12.0';
|
//options.headers['X-Line-Application'] = 'CHROMEOS\t2.1.0\tChrome_OS\t1';
|
||||||
|
options.headers['X-Line-Application'] = 'IOSIPAD 7.14.0 iPhone OS 10.12.0';
|
||||||
|
//options.headers['X-Line-Application'] = 'DESKTOPMAC\t5.3.3-YOSEMITE-x64\tMAC\t10.12.0';
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.connection =
|
this.connection =
|
||||||
thrift.createHttpConnection(this.config.LINE_DOMAIN_3RD, 443, this.options);
|
thrift.createHttpConnection(this.config.LINE_DOMAIN_3RD, 443, this.options);
|
||||||
|
@ -63,33 +50,32 @@ class LineAPI {
|
||||||
console.log('err',err);
|
console.log('err',err);
|
||||||
return err;
|
return err;
|
||||||
});
|
});
|
||||||
if(this.axz === true){
|
if(this.axz === true){
|
||||||
this._channel = thrift.createHttpClient(LineService, this.connection);this.axz = false;
|
this._channel = thrift.createHttpClient(require('../curve-thrift/ChannelService.js'), this.connection);this.axz = false;
|
||||||
} else if(this.axy === true){
|
} else if(this.axy === true){
|
||||||
this._authService = thrift.createHttpClient(LineService, this.connection);this.axy = false;
|
this._authService = thrift.createHttpClient(require('../curve-thrift/AuthService.js'), this.connection);this.axy = false;
|
||||||
} else {
|
} else {
|
||||||
this._client = thrift.createHttpClient(LineService, this.connection);
|
this._client = thrift.createHttpClient(LineService, this.connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async _chanConn(){
|
async _chanConn(){
|
||||||
this.options.headers['X-Line-Access'] = this.config.tokenn;
|
this.options.headers['X-Line-Access'] = this.config.tokenn;
|
||||||
this.options.path = this.config.LINE_CHANNEL_PATH;
|
this.options.path = this.config.LINE_CHANNEL_PATH;
|
||||||
this.axz = true;
|
this.axz = true;
|
||||||
this.setTHttpClient(this.options);
|
this.setTHttpClient(this.options);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
async _authConn(){
|
async _authConn(){
|
||||||
this.axy = true;
|
this.axy = true;
|
||||||
this.options.path = this.config.LINE_RS;
|
this.options.path = this.config.LINE_RS;
|
||||||
this.setTHttpClient(this.options);
|
this.setTHttpClient(this.options);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
async _tokenLogin(authToken, certificate) {
|
async _tokenLogin(authToken, certificate) {
|
||||||
this.options.path = this.config.LINE_COMMAND_PATH;
|
this.options.path = this.config.LINE_COMMAND_PATH;
|
||||||
this.config.Headers['X-Line-Access'] = authToken;config.tokenn = authToken;
|
this.config.Headers['X-Line-Access'] = authToken;config.tokenn = authToken;
|
||||||
this.setTHttpClient(this.options);
|
this.setTHttpClient(this.options);
|
||||||
return Promise.resolve({ authToken, certificate });
|
return Promise.resolve({ authToken, certificate });
|
||||||
|
@ -98,7 +84,7 @@ class LineAPI {
|
||||||
_qrCodeLogin() {
|
_qrCodeLogin() {
|
||||||
this.setTHttpClient();
|
this.setTHttpClient();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._client.getAuthQrcode(true, 'THIRD-PC',(err, result) => {
|
this._client.getAuthQrcode(true, 'MB-JSKICKER',(err, result) => {
|
||||||
const qrcodeUrl = `line://au/q/${result.verifier}`;
|
const qrcodeUrl = `line://au/q/${result.verifier}`;
|
||||||
qrcode.generate(qrcodeUrl,{small: true});
|
qrcode.generate(qrcodeUrl,{small: true});
|
||||||
console.info(`\n\nlink qr code is: ${qrcodeUrl}`)
|
console.info(`\n\nlink qr code is: ${qrcodeUrl}`)
|
||||||
|
@ -108,83 +94,84 @@ class LineAPI {
|
||||||
.timeout(120000)
|
.timeout(120000)
|
||||||
.end(async (res) => {
|
.end(async (res) => {
|
||||||
const verifiedQr = res.body.result.verifier;
|
const verifiedQr = res.body.result.verifier;
|
||||||
this._authConn();
|
this._authConn();
|
||||||
reqx.type = 1;
|
reqx.type = 1;
|
||||||
reqx.verifier = verifiedQr;
|
reqx.verifier = verifiedQr;
|
||||||
this._authService.loginZ(reqx,(err,success) => {
|
this._authService.loginZ(reqx,(err,success) => {
|
||||||
config.tokenn = success.authToken;
|
config.tokenn = success.authToken;
|
||||||
config.certificate = success.certificate;
|
config.certificate = success.certificate;
|
||||||
const authToken = config.tokenn;
|
const authToken = config.tokenn;
|
||||||
const certificate = config.certificate;
|
const certificate = config.certificate;
|
||||||
this.options.headers['X-Line-Access'] = config.tokenn;
|
this.options.headers['X-Line-Access'] = config.tokenn;
|
||||||
this.options.path = this.config.LINE_COMMAND_PATH;
|
this.options.path = this.config.LINE_COMMAND_PATH;
|
||||||
this.setTHttpClient(this.options);
|
this.setTHttpClient(this.options);
|
||||||
this.options.headers['User-Agent'] = 'Line/6.0.0 iPad4,1 9.0.2';
|
this.options.headers['User-Agent'] = 'Line/7.18.1';
|
||||||
this.axz = true;
|
this.axz = true;
|
||||||
this.setTHttpClient(this.options);
|
this.setTHttpClient(this.options);
|
||||||
this.axz = false;
|
this.axz = false;
|
||||||
resolve({ authToken, certificate, verifiedQr });
|
resolve({ authToken, certificate, verifiedQr });
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_xlogin(id,password){
|
_xlogin(id,password){
|
||||||
const pinVerifier = new PinVerifier(id, password);
|
const pinVerifier = new PinVerifier(id, password);
|
||||||
return new Promise((resolve, reject) => (
|
return new Promise((resolve, reject) => (
|
||||||
this._setProvider(id).then(() => {
|
this._setProvider(id).then(() => {
|
||||||
this.setTHttpClient();
|
this.setTHttpClient();
|
||||||
this._getRSAKeyInfo(this.provider, (key, credentials) => {
|
this._getRSAKeyInfo(this.provider, (key, credentials) => {
|
||||||
this.options.path = this.config.LINE_RS;
|
this.options.path = this.config.LINE_RS;
|
||||||
this.setTHttpClient(this.options);
|
this.setTHttpClient(this.options);
|
||||||
const rsaCrypto = pinVerifier.getRSACrypto(credentials);
|
const rsaCrypto = pinVerifier.getRSACrypto(credentials);
|
||||||
reqx.type = 0;
|
reqx.type = 0;
|
||||||
reqx.identityProvider = this.provider;
|
reqx.identityProvider = this.provider;
|
||||||
reqx.identifier = rsaCrypto.keyname;
|
reqx.identifier = rsaCrypto.keyname;
|
||||||
reqx.password = rsaCrypto.credentials;
|
reqx.password = rsaCrypto.credentials;
|
||||||
reqx.keepLoggedIn = true;
|
reqx.keepLoggedIn = true;
|
||||||
reqx.accessLocation = this.config.ip;
|
reqx.accessLocation = this.config.ip;
|
||||||
reqx.systemName = 'THIRD-PC';
|
reqx.systemName = 'MB-JSKICKER';
|
||||||
reqx.e2eeVersion = 0;
|
reqx.e2eeVersion = 0;
|
||||||
try{
|
try{
|
||||||
this._client.loginZ(reqx,
|
this._client.loginZ(reqx,
|
||||||
(err,success) => {
|
(err,success) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('\n\n');
|
console.log('\n\n');
|
||||||
console.error("=> "+err.reason);
|
console.error("=> "+err.reason);
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
this.options.path = this.config.LINE_COMMAND_PATH;
|
this.options.path = this.config.LINE_COMMAND_PATH;
|
||||||
this.setTHttpClient(this.options);
|
this.setTHttpClient(this.options);
|
||||||
this._authConn();
|
this._authConn();
|
||||||
this._client.pinCode = success.pinCode;
|
this._client.pinCode = success.pinCode;
|
||||||
console.info("\n\n=============================\nEnter This Pincode => "+success.pinCode+"\nto your mobile phone in 2 minutes\n=============================");
|
console.info("\n\n=============================\nEnter This Pincode => "+success.pinCode+"\nto your mobile phone in 2 minutes\n=============================");
|
||||||
this._checkLoginResultType(success.type, success);
|
this._checkLoginResultType(success.type, success);
|
||||||
reqxy.type = 1;
|
reqxy.type = 1;
|
||||||
this._loginWithVerifier((verifierResult) => {
|
this._loginWithVerifier((verifierResult) => {
|
||||||
this.options.path = this.config.LINE_COMMAND_PATH;
|
this.options.path = this.config.LINE_COMMAND_PATH;
|
||||||
this.setTHttpClient(this.options);
|
this.setTHttpClient(this.options);
|
||||||
config.tokenn = verifierResult.authToken;
|
config.tokenn = verifierResult.authToken;
|
||||||
this._checkLoginResultType(verifierResult.type, verifierResult);
|
this._checkLoginResultType(verifierResult.type, verifierResult);
|
||||||
resolve(verifierResult);
|
resolve(verifierResult);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}catch(error) {
|
}catch(error) {
|
||||||
console.log('error');
|
console.log('error');
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
async _loginWithVerifier(callback) {
|
async _loginWithVerifier(callback) {
|
||||||
let retx = await this.getJson(this.config.LINE_CERTIFICATE_URL)
|
let retx = await this.getJson(this.config.LINE_CERTIFICATE_URL)
|
||||||
reqxy.verifier = retx.result.verifier;
|
reqxy.verifier = retx.result.verifier;
|
||||||
this._authService.loginZ(reqxy,(err,success) => {
|
this._authService.loginZ(reqxy,(err,success) => {
|
||||||
callback(success);
|
callback(success);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
_setProvider(id) {
|
_setProvider(id) {
|
||||||
|
@ -197,6 +184,11 @@ class LineAPI {
|
||||||
this.getJson(this.config.LINE_SESSION_NAVER_URL);
|
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) {
|
_checkLoginResultType(type, result) {
|
||||||
this.config.Headers['X-Line-Access'] = result.authToken || result.verifier;
|
this.config.Headers['X-Line-Access'] = result.authToken || result.verifier;
|
||||||
if (result.type === LoginResultType.SUCCESS) {
|
if (result.type === LoginResultType.SUCCESS) {
|
||||||
|
@ -211,573 +203,68 @@ class LineAPI {
|
||||||
}
|
}
|
||||||
return result;
|
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;
|
message.text = txt;
|
||||||
return this._client.sendMessage(0, message);
|
return await this._client.sendMessage(0, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
_kickMember(group,memid) {
|
_kickMember(group,memid) {
|
||||||
return this._client.kickoutFromGroup(0,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) {
|
async _acceptGroupInvitation(groupid) {
|
||||||
this._client.acceptGroupInvitation(0,groupid);
|
this._client.acceptGroupInvitation(0,groupid);
|
||||||
await this._getGroupsInvited();
|
await this._refrehGroup();
|
||||||
await this._getGroupsJoined();
|
|
||||||
return;
|
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) {
|
async _getGroups(groupId) {
|
||||||
return await this._client.getGroups(groupId);
|
return await this._client.getGroups(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _updateGroup(group) {
|
||||||
|
return await this._client.updateGroup(0, group)
|
||||||
|
}
|
||||||
|
|
||||||
async _getGroup(groupId) {
|
async _getGroup(groupId) {
|
||||||
return await this._client.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) {
|
_fetchOperations(revision, count = 5) {
|
||||||
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) {
|
|
||||||
// this.options.path = this.config.LINE_POLL_URL
|
// this.options.path = this.config.LINE_POLL_URL
|
||||||
return this._client.fetchOperations(revision, count);
|
return this._client.fetchOperations(revision, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _fetchOps(revision, count = 0) {
|
_fetchOps(revision, count = 5) {
|
||||||
return this._client.fetchOps(revision, count,0,0);
|
return this._client.fetchOps(revision, count,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getJson(path,headerx) {
|
getJson(path) {
|
||||||
return new Promise((resolve, reject) => (
|
return new Promise((resolve, reject) => (
|
||||||
unirest.get(`https://${this.config.LINE_DOMAIN}${path}`)
|
unirest.get(`https://${this.config.LINE_DOMAIN}${path}`)
|
||||||
.headers(
|
.headers(this.config.Headers)
|
||||||
this.config.Headers
|
|
||||||
)
|
|
||||||
.timeout(120000)
|
.timeout(120000)
|
||||||
.end((res) => (
|
.end((res) => (
|
||||||
res.error ? reject(res.error) : resolve(res.body)
|
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;
|
module.exports = LineAPI;
|
||||||
|
|
29
src/bot.js
29
src/bot.js
|
@ -1,28 +1,8 @@
|
||||||
const LineConnect = require('./connect');
|
const LineConnect = require('./connect');
|
||||||
const LINE = require('./main.js');
|
let line = require('./main.js');
|
||||||
console.info("\n\
|
let LINE = new line();
|
||||||
.:::: .:: .:: .::\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***");
|
|
||||||
|
|
||||||
/*
|
|
||||||
| This constant is for auth/login
|
|
||||||
|
|
|
||||||
| Change it to your authToken / your email & password
|
|
||||||
*/
|
|
||||||
const auth = {
|
const auth = {
|
||||||
authToken: '',
|
authToken: '',
|
||||||
certificate: '',
|
certificate: '',
|
||||||
|
@ -34,6 +14,7 @@ let client = new LineConnect();
|
||||||
//let client = new LineConnect(auth);
|
//let client = new LineConnect(auth);
|
||||||
|
|
||||||
client.startx().then(async (res) => {
|
client.startx().then(async (res) => {
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
try {
|
try {
|
||||||
ops = await client.fetchOps(res.operation.revision);
|
ops = await client.fetchOps(res.operation.revision);
|
||||||
|
@ -46,6 +27,6 @@ client.startx().then(async (res) => {
|
||||||
LINE.poll(ops[op])
|
LINE.poll(ops[op])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//LINE.aLike() //AutoLike (CAUSE LAG)
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
133
src/command.js
Normal file
133
src/command.js
Normal file
|
@ -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;
|
|
@ -36,8 +36,8 @@ const config = {
|
||||||
LINE_SESSION_NAVER_URL: '/authct/v1/keys/naver',
|
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: 'https://os.line.naver.jp/talk/m/upload.nhn',
|
||||||
LINE_POST_CONTENT_URL_2ND: 'https://obs-sg.line-apps.com/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: 'IOSIPAD 7.14.0 iPhone OS 10.12.0',
|
||||||
//X_LINE_APP: 'CHROMEOS 1.4.13 Chrome_OS 1',
|
//X_LINE_APP: 'CHROMEOS 1.4.13 Chrome_OS 1',
|
||||||
ip: '127.0.0.1',
|
ip: '127.0.0.1',
|
||||||
version: '0.0.2',
|
version: '0.0.2',
|
||||||
revision: 0,
|
revision: 0,
|
||||||
|
@ -45,15 +45,8 @@ const config = {
|
||||||
platform: whichPlatform,
|
platform: whichPlatform,
|
||||||
EMAIL_REGEX: /[^@]+@[^@]+\.[^@]+/,
|
EMAIL_REGEX: /[^@]+@[^@]+\.[^@]+/,
|
||||||
Headers: {
|
Headers: {
|
||||||
'User-Agent':'Line/7.14.0'
|
'User-Agent':'Line/7.18.1'
|
||||||
},
|
}
|
||||||
FILE_DOWNLOAD_LOCATION: '/../download/',
|
|
||||||
YT_DL: 'http://www.saveitoffline.com/process/',
|
|
||||||
tokenn: '',
|
|
||||||
chanToken: '',
|
|
||||||
certificate: '',
|
|
||||||
botmid: '',
|
|
||||||
doing: 'no'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = config;
|
module.exports = config;
|
|
@ -9,8 +9,6 @@ class LineConnect extends LineAPI {
|
||||||
|
|
||||||
if (typeof options !== 'undefined') {
|
if (typeof options !== 'undefined') {
|
||||||
this.authToken = options.authToken;
|
this.authToken = options.authToken;
|
||||||
this.email = options.email;
|
|
||||||
this.password = options.password;
|
|
||||||
this.certificate = options.certificate;
|
this.certificate = options.certificate;
|
||||||
this.config.Headers['X-Line-Access'] = options.authToken;
|
this.config.Headers['X-Line-Access'] = options.authToken;
|
||||||
}
|
}
|
||||||
|
@ -21,68 +19,52 @@ class LineConnect extends LineAPI {
|
||||||
this._qrCodeLogin().then(async (res) => {
|
this._qrCodeLogin().then(async (res) => {
|
||||||
this.authToken = res.authToken;
|
this.authToken = res.authToken;
|
||||||
this.certificate = res.certificate;
|
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(`[*] Token: ${this.authToken}`);
|
||||||
console.info(`[*] Certificate: ${res.certificate}`);
|
console.info(`[*] Certificate: ${res.certificate}`);
|
||||||
let { mid, displayName } = await this._client.getProfile();config.botmid = mid;
|
await this._chanConn();
|
||||||
console.info(`[*] ID: ${mid}`);
|
console.info(`=======BOT RUNNING======\n`);
|
||||||
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`);
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async startx () {
|
async startx () {
|
||||||
if (this.authToken){
|
if (typeof this.authToken != 'undefined'){
|
||||||
return new Promise((resolve, reject) => {
|
await this._tokenLogin(this.authToken, this.certificate);
|
||||||
this._tokenLogin(this.authToken, this.certificate);
|
this._client.removeAllMessages();
|
||||||
this._chanConn();
|
return this.longpoll();
|
||||||
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 if(this.password && this.email){
|
} else if(this.password && this.email){
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._xlogin(this.email,this.password).then(()=>{
|
this._xlogin(this.email,this.password).then(()=>{
|
||||||
this._chanConn();
|
this._chanConn();
|
||||||
console.info("Success Login!");
|
console.info("Success Login!");
|
||||||
console.info(`\n[*] Token: ${config.tokenn}`);
|
console.info(`\n[*] Token: ${config.tokenn}`);
|
||||||
this.config.Headers['X-Line-Access'] = config.tokenn;
|
this.config.Headers['X-Line-Access'] = config.tokenn;
|
||||||
this._channel.issueChannelToken("1341209950",(err, result)=>{
|
this._channel.issueChannelToken("1341209950",(err, result)=>{
|
||||||
config.chanToken = result.channelAccessToken;
|
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) => {
|
|
||||||
this._client.getLastOpRevision((err,result)=>{
|
this._client.getLastOpRevision((err,result)=>{
|
||||||
let xrx = result.toString().split(" ");
|
let xrx = result.toString().split(" ");
|
||||||
this.revision = xrx[0].toString() - 1;
|
this.revision = xrx[0].toString() - 1;
|
||||||
resolve(this.longpoll());
|
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) {
|
async fetchOps(rev) {
|
||||||
|
@ -96,7 +78,7 @@ class LineConnect extends LineAPI {
|
||||||
|
|
||||||
longpoll() {
|
longpoll() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._fetchOps(this.revision, 5).then((operations) => {
|
this._fetchOperations(this.revision, 50).then((operations) => {
|
||||||
if (!operations) {
|
if (!operations) {
|
||||||
console.log('No operations');
|
console.log('No operations');
|
||||||
reject('No operations');
|
reject('No operations');
|
||||||
|
|
1360
src/main.js
1360
src/main.js
File diff suppressed because it is too large
Load diff
|
@ -23,4 +23,4 @@ class PinVerifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = PinVerifier;
|
module.exports = PinVerifier;
|
Loading…
Reference in a new issue