LINE-KickBot1/command.js
2019-07-13 12:50:03 +08:00

63 lines
1.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
await this._sendMessage(this.messages, 'Waiting.....');
const rtime = (Date.now() / 1000) - curTime;
await this._sendMessage(this.messages, `${rtime} Second`);
return;
}
async kickAll() {
let groupID;
if(this.stateStatus.kick == 1) {
let updateGroup = await this._getGroup(this.messages.to);
updateGroup.name = '𝔑𝔬 𝔢𝔞𝔡';
await this._updateGroup(updateGroup);
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, 'Ndeleng sampeyan asu');
}
}
module.exports = Command;