-
Notifications
You must be signed in to change notification settings - Fork 5
/
new.py
888 lines (878 loc) · 46.2 KB
/
new.py
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
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
# -*- coding: utf-8 -*-
from linepy import *
from datetime import datetime
from time import sleep
from humanfriendly import format_timespan, format_size, format_number, format_length
import time, random, sys, json, codecs, threading, glob, re, string, os, requests, subprocess, six, ast, pytz, urllib, urllib.parse
#==============================================================================#
botStart = time.time()
cl = LINE()
#cl = LINE("TOKEN KAMU")
#cl = LINE("Email","Password")
cl.log("Auth Token : " + str(cl.authToken))
channelToken = cl.getChannelResult()
cl.log("Channel Token : " + str(channelToken))
clMID = cl.profile.mid
clProfile = cl.getProfile()
lineSettings = cl.getSettings()
oepoll = OEPoll(cl)
owners = ["ua10c2ad470b4b6e972954e1140ad1891","ud5ff1dff426cf9e3030c7ac2a61512f0","ue006c548bfffccd02c6a125c0bd6d6f2"]
if clMID not in owners:
python = sys.executable
os.execl(python, python, *sys.argv)
#==============================================================================#
readOpen = codecs.open("read.json","r","utf-8")
settingsOpen = codecs.open("temp.json","r","utf-8")
read = json.load(readOpen)
settings = json.load(settingsOpen)
myProfile = {
"displayName": "",
"statusMessage": "",
"pictureStatus": ""
}
msg_dict = {}
bl = [""]
myProfile["displayName"] = clProfile.displayName
myProfile["statusMessage"] = clProfile.statusMessage
myProfile["pictureStatus"] = clProfile.pictureStatus
#==============================================================================#
def restartBot():
print ("[ INFO ] BOT RESETTED")
backupData()
# time.sleep(3)
python = sys.executable
os.execl(python, python, *sys.argv)
def backupData():
try:
backup = settings
f = codecs.open('temp.json','w','utf-8')
json.dump(backup, f, sort_keys=True, indent=4, ensure_ascii=False)
backup = read
f = codecs.open('read.json','w','utf-8')
json.dump(backup, f, sort_keys=True, indent=4, ensure_ascii=False)
return True
except Exception as error:
logError(error)
return False
def logError(text):
cl.log("[ ERROR ] " + str(text))
time_ = datetime.now()
with open("errorLog.txt","a") as error:
error.write("\n[%s] %s" % (str(time), text))
def sendMessageWithMention(to, mid):
try:
aa = '{"S":"0","E":"3","M":'+json.dumps(mid)+'}'
text_ = '@x '
cl.sendMessage(to, text_, contentMetadata={'MENTION':'{"MENTIONEES":['+aa+']}'}, contentType=0)
except Exception as error:
logError(error)
def helpmessage():
helpMessage = """ ╔═══════════ ╠🍃小新指令表🍃 ║
╠➥【speed】測速
╠➥【Contect @】丟出個人友資
╠➥【Name @】丟出@的友資
╠➥【checkread】查已讀
╠➥【Tagall】標註全部人
╠➥【About】關於
╠➥【AutJoin on/off】自動加入開啟/關閉
╠➥【AutoAdd on/off】自動添加 開啟/關閉
╠➥【Nk @】標注踢人
╠➥【Link on】關閉群組網址
╠➥【Link off】開啟群組網址
╠➥【unban @】解除某人黑單
╠➥【Ban @】黑單標注
╠➥【Banlist 】查看黑單
╠➥【Nkban】 踢除黑單
╠➥【Byeall】 翻群
║
╚═〘 小新的半垢指令表 〙
"""
return helpMessage
#==============================================================================#
def lineBot(op):
try:
if op.type == 0:
print ("[ 0 ] END OF OPERATION")
return
if op.type == 5:
print ("[ 5 ] NOTIFIED ADD CONTACT")
if settings["autoAdd"] == True:
cl.sendMessage(op.param1, "感謝您加入本帳為好友w".format(str(cl.getContact(op.param1).displayName)))
if op.type == 13:
print ("[ 13 ] NOTIFIED INVITE GROUP")
group = cl.getGroup(op.param1)
if settings["autoJoin"] == True:
cl.acceptGroupInvitation(op.param1)
if op.type == 24:
print ("[ 24 ] NOTIFIED LEAVE ROOM")
if settings["autoLeave"] == True:
cl.leaveRoom(op.param1)
if op.type == 25 or op.type == 26:
print ("[ 25 ] SEND MESSAGE")
msg = op.message
text = msg.text
msg_id = msg.id
receiver = msg.to
sender = msg._from
if msg.toType == 0:
if sender != cl.profile.mid:
to = sender
else:
to = receiver
else:
to = receiver
if msg.contentType == 0:
if text is None:
return
#==============================================================================#
if sender in owners:
if text.lower() == 'help':
helpMessage = helpmessage()
cl.sendMessage(to, str(helpMessage))
cl.sendContact(to,"ue006c548bfffccd02c6a125c0bd6d6f2")
cl.sendMessage(msg.to,"我的作者:")
cl.sendContact(to,"ua10c2ad470b4b6e972954e1140ad1891")
#==============================================================================#
elif text.lower() == 'speed':
start = time.time()
cl.sendMessage(to, "計算中...")
elapsed_time = time.time() - start
cl.sendMessage(to,format(str(elapsed_time)))
elif text.lower() == 'restart':
cl.sendMessage(to, "重新啟動中...")
time.sleep(5)
cl.sendMessage(to, "重啟成功,請重新登入")
restartBot()
elif text.lower() == 'runtime':
timeNow = time.time()
runtime = timeNow - botStart
runtime = format_timespan(runtime)
cl.sendMessage(to, "系統已運作 {}".format(str(runtime)))
elif text.lower() == 'about':
try:
arr = []
owner = "ua10c2ad470b4b6e972954e1140ad1891"
creator = cl.getContact(owner)
contact = cl.getContact(clMID)
grouplist = cl.getGroupIdsJoined()
contactlist = cl.getAllContactIds()
blockedlist = cl.getBlockedContactIds()
ret_ = "╔══[ 關於使用者 ]"
ret_ += "\n╠ 使用者名稱 : {}".format(contact.displayName)
ret_ += "\n╠ 群組數 : {}".format(str(len(grouplist)))
ret_ += "\n╠ 好友數 : {}".format(str(len(contactlist)))
ret_ += "\n╠ 已封鎖 : {}".format(str(len(blockedlist)))
ret_ += "\n╠══[ 關於本bot ]"
ret_ += "\n╠ 版本 : 最新"
ret_ += "\n╠ 製作者 : {}".format(creator.displayName)
ret_ += "\n╚══[ 感謝您的使用 ]"
cl.sendMessage(to, str(ret_))
except Exception as e:
cl.sendMessage(msg.to, str(e))
#==============================================================================#
elif text.lower() == 'set':
try:
ret_ = "╔══[ 狀態 ]"
if settings["autoAdd"] == True: ret_ += "\n╠ Auto Add ✅"
else: ret_ += "\n╠ Auto Add ❌"
if settings["autoJoin"] == True: ret_ += "\n╠ Auto Join ✅"
else: ret_ += "\n╠ Auto Join ❌"
if settings["autoLeave"] == True: ret_ += "\n╠ Auto Leave ✅"
else: ret_ += "\n╠ Auto Leave ❌"
if settings["autoRead"] == True: ret_ += "\n╠ Auto Read ✅"
else: ret_ += "\n╠ Auto Read ❌"
if settings["reread"] ==True: ret_+="\n╠ Reread ✅"
else: ret_ += "\n╠ Reread ❌"
ret_ += "\n╚══[ Finish ]"
cl.sendMessage(to, str(ret_))
except Exception as e:
cl.sendMessage(msg.to, str(e))
elif text.lower() == 'autoadd on':
settings["autoAdd"] = True
cl.sendMessage(to, "Auto Add on success")
elif text.lower() == 'autoadd off':
settings["autoAdd"] = False
cl.sendMessage(to, "Auto Add off success")
elif text.lower() == 'autojoin on':
settings["autoJoin"] = True
cl.sendMessage(to, "Auto Join on success")
elif text.lower() == 'autojoin off':
settings["autoJoin"] = False
cl.sendMessage(to, "Auto Join off success")
elif text.lower() == 'autoleave on':
settings["autoLeave"] = True
cl.sendMessage(to, "Auto Leave on success")
elif text.lower() == 'autojoin off':
settings["autoLeave"] = False
cl.sendMessage(to, "Auto Leave off success")
elif text.lower() == 'autoread on':
settings["autoRead"] = True
cl.sendMessage(to, "Auto Read on success")
elif text.lower() == 'autoread off':
settings["autoRead"] = False
cl.sendMessage(to, "Auto Read off success")
elif text.lower() == 'checksticker on':
settings["checkSticker"] = True
cl.sendMessage(to, "Berhasil mengaktifkan Check Details Sticker")
elif text.lower() == 'checksticker off':
settings["checkSticker"] = False
cl.sendMessage(to, "Berhasil menonaktifkan Check Details Sticker")
elif text.lower() == 'detectmention on':
settings["datectMention"] = True
cl.sendMessage(to, "Berhasil mengaktifkan Detect Mention")
elif text.lower() == 'detectmention off':
settings["datectMention"] = False
cl.sendMessage(to, "Berhasil menonaktifkan Detect Mention")
elif text.lower() == 'reread on':
settings["reread"] = True
cl.sendMessage(to,"reread on success")
elif text.lower() == 'reread off':
settings["reread"] = False
cl.sendMessage(to,"reread off success")
elif text.lower() == 'clonecontact':
settings["copy"] = True
cl.sendMessage(to, "Kirim Contact Yang Mau Di Copy")
#==============================================================================#
elif text.lower() == 'me':
sendMessageWithMention(to, clMID)
cl.sendContact(to, clMID)
elif text.lower() == 'mymid':
cl.sendMessage(msg.to,"[MID]\n" + clMID)
elif text.lower() == 'myname':
me = cl.getContact(clMID)
cl.sendMessage(msg.to,"[Name]\n" + me.displayName)
elif text.lower() == 'mytoken':
me = cl.getContact(clMID)
cl.sendMessage(msg.to,"[StatusMessage]\n" + me.statusMessage)
elif text.lower() == 'mypicture':
me = cl.getContact(clMID)
cl.sendImageWithURL(msg.to,"http://dl.profile.line-cdn.net/" + me.pictureStatus)
elif text.lower() == 'myvideoprofile':
me = cl.getContact(clMID)
cl.sendVideoWithURL(msg.to,"http://dl.profile.line-cdn.net/" + me.pictureStatus + "/vp")
elif text.lower() == 'mycover':
me = cl.getContact(clMID)
cover = cl.getProfileCoverURL(clMID)
cl.sendImageWithURL(msg.to, cover)
elif msg.text.lower().startswith("contact "):
if 'MENTION' in msg.contentMetadata.keys()!= None:
names = re.findall(r'@(\w+)', text)
mention = ast.literal_eval(msg.contentMetadata['MENTION'])
mentionees = mention['MENTIONEES']
lists = []
for mention in mentionees:
if mention["M"] not in lists:
lists.append(mention["M"])
for ls in lists:
contact = cl.getContact(ls)
mi_d = contact.mid
cl.sendContact(msg.to, mi_d)
elif msg.text.lower().startswith("mid "):
if 'MENTION' in msg.contentMetadata.keys()!= None:
names = re.findall(r'@(\w+)', text)
mention = ast.literal_eval(msg.contentMetadata['MENTION'])
mentionees = mention['MENTIONEES']
lists = []
for mention in mentionees:
if mention["M"] not in lists:
lists.append(mention["M"])
ret_ = "[ Mid User ]"
for ls in lists:
ret_ += "\n" + ls
cl.sendMessage(msg.to, str(ret_))
elif msg.text.lower().startswith("name "):
if 'MENTION' in msg.contentMetadata.keys()!= None:
names = re.findall(r'@(\w+)', text)
mention = ast.literal_eval(msg.contentMetadata['MENTION'])
mentionees = mention['MENTIONEES']
lists = []
for mention in mentionees:
if mention["M"] not in lists:
lists.append(mention["M"])
for ls in lists:
contact = cl.getContact(ls)
cl.sendMessage(msg.to, "[ 名字 ]\n" + contact.displayName)
for ls in lists:
contact = cl.getContact(ls)
cl.sendMessage(msg.to, "[ 個簽 ]\n" + contact.statusMessage)
for ls in lists:
path = "http://dl.profile.cl.naver.jp/" + cl.getContact(ls).pictureStatus
cl.sendImageWithURL(msg.to, str(path))
for ls in lists:
path = cl.getProfileCoverURL(ls)
pmath = "http://dl.profile.cl.naver.jp/" + cl.getContact(ls).pictureStatus
cl.sendImageWithURL(msg.to, path)
if line != None:
if 'MENTION' in msg.contentMetadata.keys()!= None:
names = re.findall(r'@(\w+)', text)
mention = ast.literal_eval(msg.contentMetadata['MENTION'])
mentionees = mention['MENTIONEES']
lists = []
for mention in mentionees:
if mention["M"] not in lists:
lists.append(mention["M"])
for ls in lists:
path = cl.getProfileCoverURL(ls)
cl.sendImageWithURL(msg.to, str(path))
elif msg.text.lower().startswith("cloneprofile "):
if 'MENTION' in msg.contentMetadata.keys()!= None:
names = re.findall(r'@(\w+)', text)
mention = ast.literal_eval(msg.contentMetadata['MENTION'])
mentionees = mention['MENTIONEES']
for mention in mentionees:
contact = mention["M"]
break
try:
cl.cloneContactProfile(contact)
cl.sendMessage(msg.to, "Berhasil clone member tunggu beberapa saat sampai profile berubah")
except:
cl.sendMessage(msg.to, "Gagal clone member")
elif text.lower() == 'restoreprofile':
try:
clProfile.displayName = str(myProfile["displayName"])
clProfile.statusMessage = str(myProfile["statusMessage"])
clProfile.pictureStatus = str(myProfile["pictureStatus"])
cl.updateProfileAttribute(8, clProfile.pictureStatus)
cl.updateProfile(clProfile)
cl.sendMessage(msg.to, "Berhasil restore profile tunggu beberapa saat sampai profile berubah")
except:
cl.sendMessage(msg.to, "Gagal restore profile")
#==============================================================================#
elif msg.text.lower().startswith("mimicadd "):
targets = []
key = eval(msg.contentMetadata["MENTION"])
key["MENTIONEES"][0]["M"]
for x in key["MENTIONEES"]:
targets.append(x["M"])
for target in targets:
try:
settings["mimic"]["target"][target] = True
cl.sendMessage(msg.to,"已加入模仿名單!")
break
except:
cl.sendMessage(msg.to,"添加失敗 !")
break
elif msg.text.lower().startswith("mimicdel "):
targets = []
key = eval(msg.contentMetadata["MENTION"])
key["MENTIONEES"][0]["M"]
for x in key["MENTIONEES"]:
targets.append(x["M"])
for target in targets:
try:
del settings["模仿名單"]["target"][target]
cl.sendMessage(msg.to,"刪除成功 !")
break
except:
cl.sendMessage(msg.to,"刪除失敗 !")
break
elif text.lower() == 'mimiclist':
if settings["mimic"]["target"] == {}:
cl.sendMessage(msg.to,"未設定模仿目標")
else:
mc = "╔══[ Mimic List ]"
for mi_d in settings["mimic"]["target"]:
mc += "\n╠ "+cl.getContact(mi_d).displayName
cl.sendMessage(msg.to,mc + "\n╚══[ Finish ]")
elif "mimic" in msg.text.lower():
sep = text.split(" ")
mic = text.replace(sep[0] + " ","")
if mic == "on":
if settings["mimic"]["status"] == False:
settings["mimic"]["status"] = True
cl.sendMessage(msg.to,"Reply Message on")
elif mic == "off":
if settings["mimic"]["status"] == True:
settings["mimic"]["status"] = False
cl.sendMessage(msg.to,"Reply Message off")
#==============================================================================#
elif text.lower() == 'groupcreator':
group = cl.getGroup(to)
GS = group.creator.mid
cl.sendContact(to, GS)
elif text.lower() == 'groupid':
gid = cl.getGroup(to)
cl.sendMessage(to, "[ID Group : ]\n" + gid.id)
elif text.lower() == 'grouppicture':
group = cl.getGroup(to)
path = "http://dl.profile.line-cdn.net/" + group.pictureStatus
cl.sendImageWithURL(to, path)
elif text.lower() == 'groupname':
gid = cl.getGroup(to)
cl.sendMessage(to, "[群組名稱 : ]\n" + gid.name)
elif text.lower() == 'grouplink':
if msg.toType == 2:
group = cl.getGroup(to)
if group.preventedJoinByTicket == False:
ticket = cl.reissueGroupTicket(to)
cl.sendMessage(to, "[ Group Ticket ]\nhttps://cl.me/R/ti/g/{}".format(str(ticket)))
else:
cl.sendMessage(to, "Grup qr tidak terbuka silahkan buka terlebih dahulu dengan perintah {}openqr".format(str(settings["keyCommand"])))
elif text.lower() == 'link on':
if msg.toType == 2:
group = cl.getGroup(to)
if group.preventedJoinByTicket == False:
cl.sendMessage(to, "群組網址已開")
else:
group.preventedJoinByTicket = False
cl.updateGroup(group)
cl.sendMessage(to, "開啟成功")
elif text.lower() == 'link off':
if msg.toType == 2:
group = cl.getGroup(to)
if group.preventedJoinByTicket == True:
cl.sendMessage(to, "群組網址已關")
else:
group.preventedJoinByTicket = True
cl.updateGroup(group)
cl.sendMessage(to, "關閉成功")
elif text.lower() == 'groupinfo':
group = cl.getGroup(to)
try:
gCreator = group.creator.displayName
except:
gCreator = "Tidak ditemukan"
if group.invitee is None:
gPending = "0"
else:
gPending = str(len(group.invitee))
if group.preventedJoinByTicket == True:
gQr = "Tertutup"
gTicket = "Tidak ada"
else:
gQr = "Terbuka"
gTicket = "https://cl.me/R/ti/g/{}".format(str(cl.reissueGroupTicket(group.id)))
path = "http://dl.profile.line-cdn.net/" + group.pictureStatus
ret_ = "╔══[ Group Info ]"
ret_ += "\n╠ 群組名稱 : {}".format(str(group.name))
ret_ += "\n╠ 群組 Id : {}".format(group.id)
ret_ += "\n╠ 創建者 : {}".format(str(gCreator))
ret_ += "\n╠ 群組人數 : {}".format(str(len(group.members)))
ret_ += "\n╠ 邀請中 : {}".format(gPending)
ret_ += "\n╠ Group Qr : {}".format(gQr)
ret_ += "\n╠ 群組網址 : {}".format(gTicket)
ret_ += "\n╚══[ Finish ]"
cl.sendMessage(to, str(ret_))
cl.sendImageWithURL(to, path)
elif text.lower() == 'groupmemberlist':
if msg.toType == 2:
group = cl.getGroup(to)
ret_ = "╔══[ 成員名單 ]"
no = 0 + 1
for mem in group.members:
ret_ += "\n╠ {}. {}".format(str(no), str(mem.displayName))
no += 1
ret_ += "\n╚══[ 全部成員共 {} 人]".format(str(len(group.members)))
cl.sendMessage(to, str(ret_))
elif text.lower() == 'grouplist':
groups = cl.groups
ret_ = "╔══[ Group List ]"
no = 0 + 1
for gid in groups:
group = cl.getGroup(gid)
ret_ += "\n╠ {}. {} | {}".format(str(no), str(group.name), str(len(group.members)))
no += 1
ret_ += "\n╚══[ Total {} Groups ]".format(str(len(groups)))
cl.sendMessage(to, str(ret_))
elif msg.text.lower().startswith("nk "):
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.sendMessage(to,"Fuck you")
cl.kickoutFromGroup(msg.to,[target])
except:
cl.sendMessage(to,"Error")
elif text.lower() == 'byeall':
if msg.toType == 2:
print ("[ 19 ] KICK ALL MEMBER")
_name = msg.text.replace("Byeall","")
gs = cl.getGroup(msg.to)
cl.sendMessage(msg.to,"Sorry guys")
targets = []
for g in gs.members:
if _name in g.displayName:
targets.append(g.mid)
if targets == []:
cl.sendMessage(msg.to,"Not Found")
else:
for target in targets:
try:
cl.kickoutFromGroup(msg.to,[target])
print (msg.to,[g.mid])
except:
cl.sendMessage(msg.to,"")
elif ("Gn " in msg.text):
if msg.toType == 2:
X = cl.getGroup(msg.to)
X.name = msg.text.replace("Gn ","")
cl.updateGroup(X)
else:
cl.sendMessage(msg.to,"It can't be used besides the group.")
elif text.lower() == 'clear':
if msg.toType == 2:
group = cl.getGroup(to)
gMembMids = [contact.mid for contact in group.invitee]
for _mid in gMembMids:
cl.cancelGroupInvitation(msg.to,[_mid])
cl.sendMessage(msg.to,"已取消所有邀請!")
elif text.lower() =='inv ':
midd = msg.text.replace("Inv ","")
cl.inviteIntoGroup(to,[midd])
#==============================================================================#
elif text.lower() == 'tagall':
group = cl.getGroup(msg.to)
nama = [contact.mid for contact in group.members]
k = len(nama)//100
for a in range(k+1):
txt = u''
s=0
b=[]
for i in group.members[a*100 : (a+1)*100]:
b.append({"S":str(s), "E" :str(s+6), "M":i.mid})
s += 7
txt += u'@Alin \n'
cl.sendMessage(to, text=txt, contentMetadata={u'MENTION': json.dumps({'MENTIONEES':b})}, contentType=0)
cl.sendMessage(to, "Total {} Mention".format(str(len(nama))))
elif text.lower() == 'setread':
tz = pytz.timezone("Asia/Jakarta")
timeNow = datetime.now(tz=tz)
day = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday","Friday", "Saturday"]
hari = ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"]
bulan = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"]
hr = timeNow.strftime("%A")
bln = timeNow.strftime("%m")
for i in range(len(day)):
if hr == day[i]: hasil = hari[i]
for k in range(0, len(bulan)):
if bln == str(k): bln = bulan[k-1]
readTime = hasil + ", " + timeNow.strftime('%d') + " - " + bln + " - " + timeNow.strftime('%Y') + "\nJam : [ " + timeNow.strftime('%H:%M:%S') + " ]"
if msg.to in read['readPoint']:
try:
del read['readPoint'][msg.to]
del read['readMember'][msg.to]
del read['readTime'][msg.to]
except:
pass
read['readPoint'][msg.to] = msg.id
read['readMember'][msg.to] = ""
read['readTime'][msg.to] = datetime.now().strftime('%H:%M:%S')
read['ROM'][msg.to] = {}
with open('read.json', 'w') as fp:
json.dump(read, fp, sort_keys=True, indent=4)
cl.sendMessage(msg.to,"偵測點已設置")
else:
try:
del read['readPoint'][msg.to]
del read['readMember'][msg.to]
del read['readTime'][msg.to]
except:
pass
read['readPoint'][msg.to] = msg.id
read['readMember'][msg.to] = ""
read['readTime'][msg.to] = datetime.now().strftime('%H:%M:%S')
read['ROM'][msg.to] = {}
with open('read.json', 'w') as fp:
json.dump(read, fp, sort_keys=True, indent=4)
cl.sendMessage(msg.to, "Set reading point:\n" + readTime)
elif text.lower() == 'readcancel':
tz = pytz.timezone("Asia/Jakarta")
timeNow = datetime.now(tz=tz)
day = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday","Friday", "Saturday"]
hari = ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"]
bulan = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"]
hr = timeNow.strftime("%A")
bln = timeNow.strftime("%m")
for i in range(len(day)):
if hr == day[i]: hasil = hari[i]
for k in range(0, len(bulan)):
if bln == str(k): bln = bulan[k-1]
readTime = hasil + ", " + timeNow.strftime('%d') + " - " + bln + " - " + timeNow.strftime('%Y') + "\nJam : [ " + timeNow.strftime('%H:%M:%S') + " ]"
if msg.to not in read['readPoint']:
cl.sendMessage(msg.to,"偵測點已取消")
else:
try:
del read['readPoint'][msg.to]
del read['readMember'][msg.to]
del read['readTime'][msg.to]
except:
pass
cl.sendMessage(msg.to, "Delete reading point:\n" + readTime)
elif text.lower() == 'resetread':
tz = pytz.timezone("Asia/Jakarta")
timeNow = datetime.now(tz=tz)
day = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday","Friday", "Saturday"]
hari = ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"]
bulan = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"]
hr = timeNow.strftime("%A")
bln = timeNow.strftime("%m")
for i in range(len(day)):
if hr == day[i]: hasil = hari[i]
for k in range(0, len(bulan)):
if bln == str(k): bln = bulan[k-1]
readTime = hasil + ", " + timeNow.strftime('%d') + " - " + bln + " - " + timeNow.strftime('%Y') + "\nJam : [ " + timeNow.strftime('%H:%M:%S') + " ]"
if msg.to in read["readPoint"]:
try:
del read["readPoint"][msg.to]
del read["readMember"][msg.to]
del read["readTime"][msg.to]
except:
pass
cl.sendMessage(msg.to, "Reset reading point:\n" + readTime)
else:
cl.sendMessage(msg.to, "偵測點未設置?")
elif text.lower() == 'checkread':
tz = pytz.timezone("Asia/Jakarta")
timeNow = datetime.now(tz=tz)
day = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday","Friday", "Saturday"]
hari = ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"]
bulan = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"]
hr = timeNow.strftime("%A")
bln = timeNow.strftime("%m")
for i in range(len(day)):
if hr == day[i]: hasil = hari[i]
for k in range(0, len(bulan)):
if bln == str(k): bln = bulan[k-1]
readTime = hasil + ", " + timeNow.strftime('%d') + " - " + bln + " - " + timeNow.strftime('%Y') + "\nJam : [ " + timeNow.strftime('%H:%M:%S') + " ]"
if receiver in read['readPoint']:
if read["ROM"][receiver].items() == []:
cl.sendMessage(receiver,"[ 已讀的人 ]:\nNone")
else:
chiya = []
for rom in read["ROM"][receiver].items():
chiya.append(rom[1])
cmem = cl.getContacts(chiya)
zx = ""
zxc = ""
zx2 = []
xpesan = '[ 已讀的人 ]:\n'
for x in range(len(cmem)):
xname = str(cmem[x].displayName)
pesan = ''
pesan2 = pesan+"@c\n"
xlen = str(len(zxc)+len(xpesan))
xlen2 = str(len(zxc)+len(pesan2)+len(xpesan)-1)
zx = {'S':xlen, 'E':xlen2, 'M':cmem[x].mid}
zx2.append(zx)
zxc += pesan2
text = xpesan+ zxc + "\n[ 已讀時間 ]: \n" + readTime
try:
cl.sendMessage(receiver, text, contentMetadata={'MENTION':str('{"MENTIONEES":'+json.dumps(zx2).replace(' ','')+'}')}, contentType=0)
except Exception as error:
print (error)
pass
else:
cl.sendMessage(receiver,"尚未設置偵測點")
#==============================================================================#
elif msg.text.lower().startswith("ban "):
targets = []
key = eval(msg.contentMetadata["MENTION"])
key["MENTIONEES"][0]["M"]
for x in key["MENTIONEES"]:
targets.append(x["M"])
for target in targets:
try:
settings["blacklist"][target] = True
cl.sendMessage(msg.to,"已加入黑單!")
break
except:
cl.sendMessage(msg.to,"添加失敗 !")
break
elif msg.text.lower().startswith("unban "):
targets = []
key = eval(msg.contentMetadata["MENTION"])
key["MENTIONEES"][0]["M"]
for x in key["MENTIONEES"]:
targets.append(x["M"])
for target in targets:
try:
del settings["blacklist"][target]
cl.sendMessage(msg.to,"刪除成功 !")
break
except:
cl.sendMessage(msg.to,"刪除失敗 !")
break
elif text.lower() == 'banlist':
if settings["blacklist"] == {}:
cl.sendMessage(msg.to,"無黑單成員!")
else:
mc = "╔══[ Black List ]"
for mi_d in settings["blacklist"]:
mc += "\n╠ "+cl.getContact(mi_d).displayName
cl.sendMessage(msg.to,mc + "\n╚══[ Finish ]")
elif text.lower() == 'nkban':
if msg.toType == 2:
group = cl.getGroup(to)
gMembMids = [contact.mid for contact in group.members]
matched_list = []
for tag in settings["blacklist"]:
matched_list+=filter(lambda str: str == tag, gMembMids)
if matched_list == []:
cl.sendMessage(msg.to,"There was no blacklist user")
return
for jj in matched_list:
cl.kickoutFromGroup(msg.to,[jj])
cl.sendMessage(msg.to,"Blacklist kicked out")
elif text.lower() == 'cleanban':
try:
settings["blacklist"] == {}
cl.sendMessage(msg.to,"已清空黑單!")
except:
cl.sendMessage(msg.to,"清除失敗 !")
#==============================================================================#
#==============================================================================#
elif text.lower() == 'calender':
tz = pytz.timezone("Asia/Makassar")
timeNow = datetime.now(tz=tz)
day = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday","Friday", "Saturday"]
hari = ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"]
bulan = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"]
hr = timeNow.strftime("%A")
bln = timeNow.strftime("%m")
for i in range(len(day)):
if hr == day[i]: hasil = hari[i]
for k in range(0, len(bulan)):
if bln == str(k): bln = bulan[k-1]
readTime = hasil + ", " + timeNow.strftime('%d') + " - " + bln + " - " + timeNow.strftime('%Y') + "\nJam : [ " + timeNow.strftime('%H:%M:%S') + " ]"
cl.sendMessage(msg.to, readTime)
elif "screenshotwebsite" in msg.text.lower():
sep = text.split(" ")
query = text.replace(sep[0] + " ","")
with requests.session() as web:
r = web.get("http://rahandiapi.herokuapp.com/sswebAPI?key=betakey&link={}".format(urllib.parse.quote(query)))
data = r.text
data = json.loads(data)
cl.sendImageWithURL(to, data["result"])
elif "checkdate" in msg.text.lower():
sep = msg.text.split(" ")
tanggal = msg.text.replace(sep[0] + " ","")
r=requests.get('https://script.google.com/macros/exec?service=AKfycbw7gKzP-WYV2F5mc9RaR7yE3Ve1yN91Tjs91hp_jHSE02dSv9w&nama=ervan&tanggal='+tanggal)
data=r.text
data=json.loads(data)
ret_ = "╔══[ D A T E ]"
ret_ += "\n╠ Date Of Birth : {}".format(str(data["data"]["lahir"]))
ret_ += "\n╠ Age : {}".format(str(data["data"]["usia"]))
ret_ += "\n╠ Birthday : {}".format(str(data["data"]["ultah"]))
ret_ += "\n╠ Zodiak : {}".format(str(data["data"]["zodiak"]))
ret_ += "\n╚══[ Success ]"
cl.sendMessage(to, str(ret_))
elif msg.contentType == 7:
if settings["checkSticker"] == True:
stk_id = msg.contentMetadata['STKID']
stk_ver = msg.contentMetadata['STKVER']
pkg_id = msg.contentMetadata['STKPKGID']
ret_ = "╔══[ Sticker Info ]"
ret_ += "\n╠ STICKER ID : {}".format(stk_id)
ret_ += "\n╠ STICKER PACKAGES ID : {}".format(pkg_id)
ret_ += "\n╠ STICKER VERSION : {}".format(stk_ver)
ret_ += "\n╠ STICKER URL : line://shop/detail/{}".format(pkg_id)
ret_ += "\n╚══[ Finish ]"
cl.sendMessage(to, str(ret_))
elif msg.contentType == 13:
if settings["copy"] == True:
_name = msg.contentMetadata["displayName"]
copy = msg.contentMetadata["mid"]
groups = cl.getGroup(msg.to)
targets = []
for s in groups.members:
if _name in s.displayName:
print ("[Target] Copy")
break
else:
targets.append(copy)
if targets == []:
cl.sendText(msg.to, "Not Found...")
pass
else:
for target in targets:
try:
cl.cloneContactProfile(target)
cl.sendMessage(msg.to, "Berhasil clone member tunggu beberapa saat sampai profile berubah")
settings['copy'] = False
break
except:
msg.contentMetadata = {'mid': target}
settings["copy"] = False
break
#==============================================================================#
if op.type == 26:
print ("[ 26 ] RECEIVE MESSAGE")
msg = op.message
text = msg.text
msg_id = msg.id
receiver = msg.to
sender = msg._from
if msg.toType == 0:
if sender != cl.profile.mid:
to = sender
else:
to = receiver
else:
to = receiver
if settings["autoRead"] == True:
cl.sendChatChecked(to, msg_id)
if to in read["readPoint"]:
if sender not in read["ROM"][to]:
read["ROM"][to][sender] = True
if sender in settings["mimic"]["target"] and settings["mimic"]["status"] == True and settings["mimic"]["target"][sender] == True:
text = msg.text
if text is not None:
cl.sendMessage(msg.to,text)
if msg.contentType == 0 and sender not in clMID and msg.toType == 2:
if 'MENTION' in msg.contentMetadata.keys()!= None:
names = re.findall(r'@(\w+)', text)
mention = ast.literal_eval(msg.contentMetadata['MENTION'])
mentionees = mention['MENTIONEES']
lists = []
for mention in mentionees:
if clMID in mention["M"]:
if settings["detectMention"] == True:
contact = cl.getContact(sender)
cl.sendMessage(to, "sundala nu")
sendMessageWithMention(to, contact.mid)
break
#==============================================================================#
if op.type == 65:
print ("[ 65 ] REREAD")
try:
at = op.param1
msg_id = op.param2
if setting["reread"] == True:
if msg_id in msg_dict:
if msg_dict[msg_id]["from"] not in bl:
cl.sendMessage(at,"[收回訊息者]\n%s\n[訊息內容]\n%s"%(cl.getContact(msg_dict[msg_id]["from"]).displayName,msg_dict[msg_id]["text"]))
del msg_dict[msg_id]
else:
pass
except Exception as e:
print (e)
#==============================================================================#
if op.type == 55:
print ("[ 55 ] NOTIFIED READ MESSAGE")
try:
if op.param1 in read['readPoint']:
if op.param2 in read['readMember'][op.param1]:
pass
else:
read['readMember'][op.param1] += op.param2
read['ROM'][op.param1][op.param2] = op.param2
backupData()
else:
pass
except:
pass
except Exception as error:
logError(error)
#==============================================================================#
while True:
try:
ops = oepoll.singleTrace(count=50)
if ops is not None:
for op in ops:
lineBot(op)
oepoll.setRevision(op.revision)
except Exception as e:
logError(e)