This repository has been archived by the owner on Sep 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathevilbot.php
246 lines (217 loc) · 9.43 KB
/
evilbot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?php
date_default_timezone_set('Asia/Tokyo');
include 'LineCross.php';
use x9119x\LineCross;
const AUTH_TOKEN = ""; //PUT YOUR AuthToken HERE
const ADMIN_MID = ""; //YOUR LINE UNIQUE ID FROM LINE DATABASE
$AuthInfo = new \x9119x\AuthInfo(AUTH_TOKEN); //Put AUTH_TOKEN HERE
try{
$Line = new LineCross($AuthInfo); //Put $AuthInfo HERE
}catch(x9119x\TalkException $e) {
echo "\033[0;31m[ERROR]\033[0m".$e->reason . PHP_EOL;
exit;
}
print_r($Line->LineService->getProfile());
$Pooling = new Pooling($Line, $AuthInfo);
while(true){
$Ops = $Pooling->Fetch();
if(empty($Ops))
continue;
foreach ($Pooling->Alloc($Ops) as $msg) {
print_r($msg);
}
}
class Pooling{
public $Line;
public $OpType;
public $ContactStatus;
public $ContentType;
private $mid;
public $_from;
public function __construct($Line, $AuthInfo) {
$this->Line = $Line;
$this->OpType = new x9119x\OpType();
$this->ContactStatus = new x9119x\ContactStatus();
$this->ContentType = new x9119x\ContentType();
}
public function Fetch(){
try {
$Ops = $this->Line->PollService->start(100);
} catch (x9119x\TalkException $e) {
echo "\033[0;31m[ERROR]\033[0m".$e->reason . PHP_EOL;
exit;
}catch(Thrift\Exception\TTransportException $e){
echo $e->getMessage().PHP_EOL;
}
$msg = '';
if(empty($Ops)){
return;
}
return $Ops;
}
public function Alloc($Ops){
foreach ($Ops as $Op) {
$this->Line->AuthInfo->Rev = max(intval($Op->revision), intval($this->Line->AuthInfo->Rev));
switch ($Op->type) {
case $this->OpType::RECEIVE_MESSAGE:
$msg = $Op->message;
$this->_from = $Op->message->_from;
$text = $Op->message->text;
$args = explode(" ", $text);
if($args[0] == "members"){
if($this->_from != ADMIN_MID){
$this->Line->LineService->sendMessage("who are you? you're not admin!", $Op->message->to);
return;
}
//GET GROUP INFO
$getGroupInfo = $this->Line->LineService->getGroup($Op->message->to);
$members = "";
foreach($getGroupInfo->members as $key){
$members .= "@" . $key->displayName . " ";
}
$this->Line->LineService->sendMessage($members, $Op->message->to);
}else if($args[0] == strtolower("kick")){
if($this->_from != ADMIN_MID){
$this->Line->LineService->sendMessage("who are you? you're not admin!", $Op->message->to);
return;
}
//GET GROUP INFO
$getGroupInfo = $this->Line->LineService->getGroup($Op->message->to);
//GET ALL THE MEMBERS IN THE GROUP
$memIDs = array();
$count = 0;
foreach($getGroupInfo->members as $key){
$memIDs["mid"][] = $key->mid;
$count++;
}
//COUNT AMOUNT OF MEMBERS IN THE GROUP
if($count > 50){
echo "[WARNING] Anggota lebih dari 50\n";
}else{
if(($nMid = array_search($Op->message->_from, $memIDs["mid"])) !== false){
unset($memIDs["mid"][$nMid]);
}
try{
foreach($memIDs["mid"] as $key){
$this->Line->LineService->kickoutFromGroup($Op->message->to, (array) $key);
}
}catch(\x9119x\TalkException $ex){
echo $ex->getMessage() . "\n";
}
}
}
switch($Op->message->contentType){
case $this->ContentType::CONTACT:
$this->mid = $Op->message->contentMetadata['mid'];
try{
$content = $this->Line->LineService->getContact($this->mid);
$this->Line->LineService->sendMessage($this->MessageContactBuilder((array) $content),
$Op->message->_from);
}catch(x9119x\TalkException $ex){
echo $ex . PHP_EOL;
}
break;
default:
break;
}
yield $msg;
break;
case $this->OpType::NOTIFIED_INVITE_INTO_GROUP:
//GET GROUP ID
$getGroupIDByInvite = $this->Line->LineService->getGroupIdsInvited();
//ACCEPT GROUP INVITATION
try{
var_dump($this->Line->LineService->acceptGroupInvitation($getGroupIDByInvite[0]));
}catch(\x9119x\TalkException $ex){
echo $ex->getMessage().PHP_EOL;
}
//GET GROUP COMPACT
$getCompactGroup = $this->Line->LineService->getCompactGroup($getGroupIDByInvite[0]);
yield $getCompactGroup;
break;
default:
break;
}
}
}
public function MessageContactBuilder(array $content){
$message = "";
$mid = $content["mid"];
$createdTime = $content["createdTime"];
$type = $content["type"];
$status = $content["status"];
$relation = $content["relation"];
$displayName = $content["displayName"];
$phoneticName = $content["phoneticName"];
$pictureStatus = $content["pictureStatus"];
$thumbnailUrl = $content["thumbnailUrl"];
$statusMessage = $content["statusMessage"];
$displayNameOverridden = $content["displayNameOverridden"];
$favoriteTime = $content["favoriteTime"];
$capableVoiceCall = $content["capableVoiceCall"];
$capableVideoCall = $content["capableVideoCall"];
$capableMyhome = $content["capableMyhome"];
$capableBuddy = $content["capableBuddy"];
$attributes = $content["attributes"];
$settings = $content["settings"];
$picturePath = $content["picturePath"];
if (isset($mid)) {
$message = "UserID : " . $mid . PHP_EOL;
}
if (isset($createdTime) && $createdTime != 0) {
$message .= "Created Time : " . $createdTime . PHP_EOL;
}
if (isset($type) && $type != "NULL") {
$message .= "Account Type : " . $type . PHP_EOL;
}
if (isset($status) && $status != 0) {
$message .= "Status : " . $status . PHP_EOL;
}
if (isset($relation)) {
$message .= "Relation : " . $relation . PHP_EOL;
}
if (isset($displayName)) {
$message .= "Display Name : " . $displayName . PHP_EOL;
}
if (isset($phoneticName) && $phoneticName != "NULL") {
$message .= "Phonetic Name : " . $phoneticName . PHP_EOL;
}
if (isset($pictureStatus)) {
$message .= "Picture URL : http://dl.profile.line-cdn.net/" . $pictureStatus . PHP_EOL;
}
if (isset($thumbnailUrl) && $thumbnailUrl != "NULL") {
$message .= "Thumbnail URL : " . $thumbnailUrl . PHP_EOL;
}
if (isset($statusMessage)) {
$message .= "Status Message : " . $statusMessage . PHP_EOL;
}
if (isset($displayNameOverridden) && $displayNameOverridden != "NULL") {
$message .= "Display Name Override : " . $displayNameOverridden . PHP_EOL;
}
if (isset($favoriteTime) && $favoriteTime != 0) {
$message .= "Favorite Time : " . $favoriteTime . PHP_EOL;
}
if (isset($capableVoiceCall) && $capableVoiceCall != false) {
$message .= "Capable VoiceCall : " . $capableVoiceCall . PHP_EOL;
}
if (isset($capableVideoCall) && $capableVideoCall != false) {
$message .= "Capable VideoCall : " . $capableVideoCall . PHP_EOL;
}
if (isset($capableMyhome) && $capableMyhome != false) {
$message .= "Capable Myhome : " . $capableMyhome . PHP_EOL;
}
if (isset($capableBuddy) && $capableBuddy != false) {
$message .= "Capable Buddy : " . $capableBuddy . PHP_EOL;
}
if (isset($attributes)) {
$message .= "Attributes : " . $attributes . PHP_EOL;
}
if (isset($settings) && $settings != 0) {
$message .= "Settings : " . $settings . PHP_EOL;
}
if (isset($picturePath)) {
$message .= "Picture Path : " . $picturePath . PHP_EOL;
}
return $message;
}
}