-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathline.py
More file actions
557 lines (493 loc) · 24.1 KB
/
line.py
File metadata and controls
557 lines (493 loc) · 24.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# -*- coding: utf-8 -*-
from linepy import *
from akad import *
import traceback
import time, random, sys, json, codecs, threading, glob, re, string, os, requests, subprocess, six, ast, urllib, urllib,pickle
from datetime import datetime
from random import randint
print("""
\033["""+str(randint(0,1))+""";"""+str(randint(31,36))+"""mplay free\nby beach noxtian\033[0m
""")
with open('tval.pkl', 'rb') as f:
[cltoken,wait] = pickle.load(f,encoding='latin1')
if len(sys.argv) == 2 and sys.argv[1] == "reset":
cltoken = ""
with open('tval.pkl', 'wb') as f:
pickle.dump([cltoken,wait], f)
os._exit(0)
if cltoken == "":
cl = LINE()
cltoken = cl.authToken
else:
try:
cl = LINE(cltoken)
except KeyboardInterrupt as e:
raise e
except:
cl = LINE()
cltoken = cl.authToken
print("authToken: %s" % (cltoken))
user1 = cl.profile.mid
admin = OEPoll(cl)
start_runtime = datetime.now()
wait = {
'alwayread':False,
'autoBlock':False,
'welcomepic':False,
'welcomemessage':False,
'autoadd':False,
'messageadd':"",
'autotag':False,
'tagmessage':"",
}
userhelp = """คำสั่งทั้งหมด (พิมพ์ ! ตามด้วยคำสั่ง):
-help
-myid
-me
-myname
-speed
-name
-kick (@)
-uid (@)
-danyall [text]
-mentionall
-sh *
-invitetocall
-uptime
-remember [1:2]
-forget [1]
-forgetall
-autodeny off
-autodeny [numbers]
-autoread on/off
-autoblock on/off
-welcomemessage on/off
-welcomemessage:[text]
-setmessageadd:[text]
-autoadd on/off
**คำสั่งสำหรับบัญชีนี้เท่านั้น**"""
procLock = 0
mentmedat = {}
respRemember = {}
def user1scipt(op):
global startruntime
global user1
global wait
global alwayread
global autoBlock
global welcomepic
global welcomemessage
global autoadd
global messageadd
global autotag
global tagmessage
global autoDeny
global procLock
global mentmedat
global respRemember
try:
if op.type == 0:
return
if op.type == 5:
if wait['autoBlock'] == True:
cl.blockContact(op.param1)
if wait['autoadd'] == True:
cl.findAndAddContactsByMid(op.param1)
if (wait["messageadd"] in [""," ","\n",None]):
pass
else:
cl.sendMessage(op.param1,str(wait["messageadd"]))
if op.type ==13:
invitor = op.param2
gotinvite = []
if "\x1e" in op.param3:
gotinvite = op.param3.split("\x1e")
else:
gotinvite.append(op.param3)
if invitor in user1 in gotinvite:
cl.acceptGroupInvitation(op.param1)
else:
group = cl.getGroup(op.param1)
if len(group.members) <= autoDeny:
procLock += 1
cl.acceptGroupInvitation(op.param1)
cl.leaveGroup(op.param1)
if op.type == 17:
if wait['welcomemessage'] and "welcomemessage" in wait:
cnt = cl.getContact(op.param2)
cl.sendMessage(op.param1,cnt.displayName + "\n" + str(wait["welcomemessage"]))
if wait['welcomepic'] and "welcomepic" in wait:
cnt = cl.getContact(op.param2)
cl.sendImageWithURL(op.param1,"http://dl.profile.line.naver.jp/" + cnt.pictureStatus)
if op.type == 26:
msg = op.message
msg.from_ = msg._from
if msg.contentMetadata != {}:
try:
prov = eval(msg.contentMetadata["MENTION"])["MENTIONEES"]
tagme = False
alluids = []
for i in range(len(prov)):
alluids.append(prov[i]["M"])
if prov[i]["M"] == mid:
tagme = True
alluids = list(set(alluids))
if tagme:
if len(alluids) <= 4:
if msg.to not in mentmedat:
mentmedat[msg.to] = []
tagfrom = msg.from_
tagtime = nowS = datetime.strftime(datetime.now(),"%H:%M:%S")
tagid = msg.id
mentmedat[msg.to].append(
{
"tfrom" : tagfrom,
"ttime" : tagtime,
"tid" : tagid
}
)
except:
pass
if wait["alwayread"]:
cl.sendChatChecked(msg.from_,msg.id)
else:
cl.sendChatChecked(msg.to,msg.id)
if msg.to in respRemember and msg.text in respRemember[msg.to]:
if msg.toType != 0:
cl.sendMessage(msg.to,respRemember[msg.to][msg.text])
else:
cl.sendMessage(msg.from_,respRemember[msg.to][msg.text])
if wait["tagmessage"] == True:
cl.sendMessage(op.param1)
if (wait["tagmessage"] in [""," ","\n",None]):
pass
else:
cl.sendMessage(op.param1,str(wait["tagmessage"]))
if op.type == 25:
msg = op.message
if msg.text is None:
return
elif msg.text.lower() == "!help":
cl.sendMessage(msg.to,userhelp)
elif msg.text.lower() == "!myid":
cl.sendMessage(msg.to,user1)
elif msg.text.lower() == "!me":
beach = user1
cl.sendContact(msg.to,beach)
elif msg.text.lower() == "!myname":
G = cl.getContact(user1)
cl.sendMessage(msg.to,G.displayName)
elif msg.text.lower() == "!speed":
start = time.time()
cl.sendMessage(msg.to,"กำลังทดสอบ(`・ω・´)")
cl.sendMessage(msg.to,str(int(round((time.time() - start) * 1000)))+" ms")
elif "!name " in msg.text.lower():
spl = re.split("!name ",msg.text,flags=re.IGNORECASE)
if spl[0] == "":
prof = cl.getProfile()
prof.displayName = spl[1]
cl.updateProfile(prof)
cl.sendMessage(msg.to,"เปลี่ยนชื่อสำเร็จแล้ว(`・ω・´)")
elif "!kick" in msg.text.lower():
if msg.contentMetadata is not None:
targets = []
key = eval(msg.contentMetadata["MENTION"])
key["MENTIONEES"][0]["M"]
for x in key["MENTIONEES"]:
targets.append(x["M"])
for target in targets:
try:
cl.kickoutFromGroup(msg.to,[target])
except:
cl.kickoutFromGroup(msg.to,[target])
else:
pass
elif "!uid " in msg.text.lower():
if msg.toType == 2:
red = re.compile(re.escape('!uid '),re.IGNORECASE)
namel = red.sub('',msg.text)
namel = namel.lstrip()
namel = namel.replace(" @","$spliter$")
namel = namel.replace("@","")
namel = namel.rstrip()
namel = namel.split("$spliter$")
gmem = cl.getGroup(msg.to).members
for targ in gmem:
if targ.displayName in namel:
cl.sendMessage(msg.to,targ.displayName+": "+targ.mid)
elif "!denyall" in msg.text.lower():
spl = re.split("!denyall",msg.text,flags=re.IGNORECASE)
if spl[0] == "":
spl[1] = spl[1].strip()
ag = cl.getGroupIdsInvited()
txt = "กำลังยกเลิกค้างเชิญจำนวน "+str(len(ag))+"กลุ่ม"
if spl[1] != "":
txt = txt + " ด้วยข้อความ \""+spl[1]+"\""
txt = txt + "\nกรุณารอสักครู่.."
cl.sendMessage(msg.to,txt)
procLock = len(ag)
for gr in ag:
try:
cl.acceptGroupInvitation(gr)
if spl[1] != "":
cl.sendMessage(gr,spl[1])
cl.leaveGroup(gr)
except:
pass
cl.sendMessage(msg.to,"สำเร็จแล้ว(`・ω・´)")
elif "!setmessageadd:" in msg.text.lower():
wait['messageadd'] = msg.text.replace("!setmessageadd:","")
cl.sendMessage(msg.to,"ตั้งค่าสำเร็จ(`・ω・´)")
elif "!tagmessage:" in msg.text.lower():
wait['tagmessage'] = msg.text.replace("!tagmessage:","")
cl.sendMessage(msg.to,"ตั้งค่าสำเร็จ(`・ω・´)")
elif msg.text.lower().startswith("!mentionall"):
data = msg.text[len("!mentionall"):].strip()
if data == "":
group = cl.getGroup(msg.to)
nama = [contact.mid for contact in group.members if contact.mid != user1]
cb = ""
cb2 = ""
count = 1
strt = len(str(count)) + 2
akh = int(0)
cnt = 0
for md in nama:
akh = akh + len(str(count)) + 2 + 5
cb += """{"S":"""+json.dumps(str(strt))+""","E":"""+json.dumps(str(akh))+""","M":"""+json.dumps(md)+"},"""
strt = strt + len(str(count+1)) + 2 + 6
akh = akh + 1
cb2 += str(count)+". @name\n"
cnt = cnt + 1
if cnt == 50:
cb = (cb[:int(len(cb)-1)])
cb2 = cb2[:-1]
msg.contentType = 0
msg.text = cb2
msg.contentMetadata ={'MENTION':'{"MENTIONEES":['+cb+']}','EMTVER':'4'}
try:
cl.sendMessage(msg)
except:
cl.sendMessage(msg.to,"[[NO MENTION]]")
cb = ""
cb2 = ""
strt = len(str(count)) + 2
akh = int(0)
cnt = 0
count += 1
cb = (cb[:int(len(cb)-1)])
cb2 = cb2[:-1]
msg.contentType = 0
msg.text = cb2
msg.contentMetadata ={'MENTION':'{"MENTIONEES":['+cb+']}','EMTVER':'4'}
try:
cl.sendMessage(msg.to, text=cb2,contentMetadata={u'MENTION':'{"MENTIONEES":['+cb+']}','EMTVER':'4'},contentType=0)
except:
cl.sendMessage(msg.to,"[[NO MENTION]]")
elif msg.text.lower() == "!checkmention":
if msg.to in mentmedat and mentmedat[msg.to] != []:
text = ""
for data in mentmedat[msg.to]:
print("555")
try:
conname = cl.getContact(data["tfrom"]).displayName
except:
conname = "[DELETED]"
text += "[%s] %s\nline://nv/chatMsg?chatId=%s&messageId=%s\n\n" % (data["ttime"],conname,msg.to,data["tid"])
text = text[:-2]
try:
cl.sendMessage(msg.to,text)
except Exception as e:
cl.sendMessage(msg.to,str(e))
del mentmedat[msg.to]
else:
cl.sendMessage(msg.to,"ไม่มีการกล่าวถึงก่อนหน้านี้(`・ω・´)")
elif msg.text.lower() == "!resetmention":
dkey = mentmedat.pop(msg.to,None)
cl.sendMessage(msg.to,"รีเซ็ตข้อมูลการกล่าวถึงเรียบร้อยแล้ว")
elif msg.text.lower() == "!resetallmention":
mentmedat = {}
cl.sendMessage(msg.to,"รีเซ็ตข้อมูลการกล่าวถึงทั้งหมดแล้ว")
elif "!sh " in msg.text.lower():
spl = re.split("!sh ",msg.text,flags=re.IGNORECASE)
if spl[0] == "":
try:
cl.sendMessage(msg.to,subprocess.getoutput(spl[1]))
except:
pass
elif msg.text.lower() == "!invitetocall":
exc = cl.getGroup(msg.to).members
zxc = cl.getProfile().mid
cl.inviteIntoGroupCall(msg.to,[uid.mid for uid in exc if uid.mid != zxc])
cl.sendMessage(msg.to,"เชิญเข้าร่วมการคอลเรียบร้อย(`・ω・´)")
elif msg.text.lower() == "!uptime":
cl.sendMessage(msg.to,str(datetime.now() - start_runtime)[:-7].split(":")[0]+" hour, "+str(datetime.now() - start_runtime)[:-7].split(":")[1]+" minute, "+str(datetime.now() - start_runtime)[:-7].split(":")[2]+" second,")
elif msg.text.lower().startswith("!remember "):
data = msg.text[len("!remember "):]
keyword = data.split(":",1)[0]
if keyword.lower().startswith("!remember") or keyword.lower().startswith("!forget") or keyword in ["",None]:
raise ValueError
response = data.split(":",1)[1]
if response in ["",None]:
raise ValueError
if msg.to not in respRemember:
respRemember[msg.to] = {}
respRemember[msg.to][keyword] = response
now2 = datetime.now()
nowT = datetime.strftime(now2,"%H")
nowM = datetime.strftime(now2,"%M")
nowS = datetime.strftime(now2,"%S")
tm = "\n\n"+nowT+":"+nowM+":"+nowS
if msg.toType != 0:
cl.sendMessage(msg.to,"จำแล้ว (`・ω・´)"+tm)
else:
cl.sendMessage(msg._from,"จำแล้ว (`・ω・´)"+tm)
elif msg.text.lower().startswith("!forget "):
keyword = msg.text[len("!forget "):]
if keyword in ["",None]:
raise ValueError
if msg.to in respRemember and keyword in respRemember[msg.to]:
dkey = respRemember[msg.to].pop(keyword,None)
now2 = datetime.now()
nowT = datetime.strftime(now2,"%H")
nowM = datetime.strftime(now2,"%M")
nowS = datetime.strftime(now2,"%S")
tm = "\n\n"+nowT+":"+nowM+":"+nowS
if msg.toType != 0:
cl.sendMessage(msg.to,"ลืมแล้ว (`・ω・´)"+tm)
else:
cl.sendMessage(msg._from,"ลืมแล้ว (`・ω・´)"+tm)
else:
now2 = datetime.now()
nowT = datetime.strftime(now2,"%H")
nowM = datetime.strftime(now2,"%M")
nowS = datetime.strftime(now2,"%S")
tm = "\n\n"+nowT+":"+nowM+":"+nowS
if msg.toType != 0:
cl.sendMessage(msg.to,"ไม่สามารถลืมได้ (`・ω・´)"+tm)
else:
cl.sendMessage(msg._from,"ไม่สามารถลืมได้ (`・ω・´)"+tm)
elif msg.text.lower() == "!forgetall":
dkey = respRemember.pop(msg.to,None)
now2 = datetime.now()
nowT = datetime.strftime(now2,"%H")
nowM = datetime.strftime(now2,"%M")
nowS = datetime.strftime(now2,"%S")
tm = "\n\n"+nowT+":"+nowM+":"+nowS
if msg.toType != 0:
cl.sendMessage(msg.to,"ลืมทุกอย่างแล้ว (`・ω・´)"+tm)
else:
cl.sendMessage(msg.from_,"ลืมทุกอย่างแล้ว (`・ω・´)"+tm)
elif "!welcomemessage:" in msg.text.lower():
c = msg.text.replace("!welcomemessage:","")
if c in [""," ","\n",None]:
cl.sendMessage(msg.to,"เกิดข้อผิดพลาด!!(`・ω・´)")
else:
wait['welcomemessage'] = c
cl.sendMessage(msg.to,"ตั้งค่าข้อความสำเร็จแล้ว(`・ω・´)")
elif msg.text.lower() == "!autodeny off":
autoDeny = -1
cl.sendMessage(msg.to,"ตั้งค่าสำเร็จแล้ว(`・ω・´)")
elif msg.text.lower().startswith("!autodeny "):
try:
autoDeny = int(msg.text[len(".autodeny "):])
cl.sendMessage(msg.to,"ตั้งค่าสำเร็จแล้ว(`・ω・´)")
except:
cl.sendMessage(msg.to,"พบข้อผิดพลาด(`・ω・´)")
elif msg.text.lower() == "!autoread on":
if wait["alwayread"] == True:
cl.sendMessage(msg.to,"เปิดอ่านอัตโนมัติแล้ว(`・ω・´)")
wait["alwayread"] = False
else:
if wait["alwayread"] == False:
cl.sendMessage(msg.to,"เปิดอ่านอัตโนมัติแล้ว(`・ω・´)")
elif msg.text.lower() == "!autoread off":
if wait["alwayread"] == False:
cl.sendMessage(msg.to,"ปิดอ่านอัตโนมัติแล้ว(`・ω・´)")
wait["alwayread"] = True
else:
if wait["alwayread"] == True:
cl.sendMessage(msg.to,"ปิดอ่านอัตโนมัติแล้ว(`・ω・´)")
elif msg.text.lower() == "!autoblock on":
if wait['autoBlock'] == True:
cl.sendMessage(msg.to,"เปิดการบล็อคอัตโนมัตื(`・ω・´)")
wait['autoBlock'] = False
else:
if wait['autoBlock'] == False:
cl.sendMessage(msg.to,"เปิดการบล็อคอัตโนมัตื(`・ω・´)")
elif msg.text.lower() == "!autoblock off":
if wait['autoBlock'] == False:
cl.sendMessage(msg.to,"ปิดการบล็อคอัตโนมัตื(`・ω・´)")
wait['autoBlock'] = True
else:
if wait['autoBlock'] == True:
cl.sendMessage(msg.to,"ปิดการบล็อคอัตโนมัตื(`・ω・´)")
elif msg.text.lower() == "!welcomepic on":
if wait['welcomepic'] == False:
cl.sendMessage(msg.to,"เปิดต้อนรับรูปเรียบร้อย(`・ω・´)")
wait['welcomepic'] = True
else:
if wait['welcomepic'] == True:
cl.sendMessage(msg.to,"เปิดต้อนรับรูปเรียบร้อย(`・ω・´)")
elif msg.text.lower() == "!welcomepic off":
if wait['welcomepic'] == True:
cl.sendMessage(msg.to,"ปิดต้อนรับรูปเรียบร้อย(`・ω・´)")
wait['welcomepic'] = False
else:
if wait['welcomepic'] == False:
cl.sendMessage(msg.to,"ปิดต้อนรับรูปเรียบร้อย(`・ω・´)")
elif msg.text.lower() == "!welcomemessage on":
if wait['welcomemessage'] == False:
cl.sendMessage(msg.to,"เปิดต้อนรับข้อความเรียบร้อย(`・ω・´)")
wait['welcomemessage'] = True
else:
if wait['welcomemessage'] == True:
cl.sendMessage(msg.to,"เปิดต้อนรับข้อความเรียบร้อย(`・ω・´)")
elif msg.text.lower() == "!welcomemessage off":
if wait['welcomemessage'] == True:
cl.sendMessage(msg.to,"ปิดต้อนรับข้อความเรียบร้อย(`・ω・´)")
wait['welcomemessage'] = False
else:
if wait['welcomemessage'] == False:
cl.sendMessage(msg.to,"ปิดต้อนรับข้อความเรียบร้อย(`・ω・´)")
elif msg.text.lower() == "!autoadd on":
if wait['autoadd'] == False:
cl.sendMessage(msg.to,"เปิดการรับเพื่อนอัตโนมัติ(`・ω・´)")
wait['autoadd'] = True
else:
if wait['autoadd'] == True:
cl.sendMessage(msg.to,"เปิดการรับเพื่อนอัตโนมัติ(`・ω・´)")
elif msg.text.lower() == "!autoadd off":
if wait['autoadd'] == True:
cl.sendMessage(msg.to,"ปิดการรับเพื่อนอัตโนมัติ(`・ω・´)")
wait['auto'] = False
else:
if wait['autoadd'] == False:
cl.sendMessage(msg.text,"ปิดการรับเพื่อนอัตโนมัติ(`・ω・´)")
elif msg.text.lower() == "!autotag on":
if wait['autotag'] == False:
cl.sendMessage(msg.to,"เปิดการแท็กตอบกลับเรียบร้อย(`・ω・´)")
wait['autotag'] = True
else:
if wait['autotag'] == True:
cl.sendMessage(msg.to,"เปิดการแท็กตอบกลับเรียบร้อย(`・ω・´)")
elif msg.text.lower() == "!autotag off":
if wait['autotag'] == True:
cl.sendMessage(msg.to,"ปิดการแท็กตอบกลับเรียบร้อย(`・ω・´)")
wait['autotag'] = False
else:
if wait['autotag'] == False:
cl.sendMessage(msg.to,"ปิดการแท็กตอบกลับเรียบร้อย(`・ω・´)")
except:
traceback.print_exc()
try:
while True:
ops = admin.singleTrace(count=50)
if ops is not None:
for op in ops:
user1scipt(op)
admin.setRevision(op.revision)
except:
traceback.print_exc()
with open('tval.pkl', 'wb') as f:
pickle.dump([cltoken,wait], f)