forked from rootmelo92118/testbot
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathx.py
More file actions
1174 lines (1152 loc) · 54.5 KB
/
x.py
File metadata and controls
1174 lines (1152 loc) · 54.5 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
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
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*-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, timeit
#==============================================================================#
botStart = time.time()
cl = LINE()
cl.log("Auth Token : " + str(cl.authToken))
#ki = LINE()
#ki.log("Auth Token : " + str(ki.authToken))
#k1 = LINE()
#k1.log("Auth Token : " + str(k1.authToken))
#k2 = LINE()
#k2.log("Auth Token : " + str(k2.authToken))
clMID = cl.profile.mid
#AMID = ki.profile.mid
#BMID = k1.profile.mid
#CMID = k2.profile.mid
#KAC = [cl,ki,k1,k2]
#Bots = [clMID,AMID,BMID,CMID]
clProfile = cl.getProfile()
#kiProfile = ki.getProfile()
#k1Profile = k1.getProfile()
#k2Profile = k2.getProfile()
lineSettings = cl.getSettings()
#kiSettings = ki.getSettings()
#k1Settings = k1.getSettings()
#k2Settings = k2.getSettings()
oepoll = OEPoll(cl)
#oepoll1 = OEPoll(ki)
#oepoll2 = OEPoll(k1)
#oepoll3 = OEPoll(k2)
#==============================================================================#
readOpen = codecs.open("read.json","r","utf-8")
settingsOpen = codecs.open("temp.json","r","utf-8")
banOpen = codecs.open("ban.json","r","utf-8")
read = json.load(readOpen)
settings = json.load(settingsOpen)
ban = json.load(banOpen)
msg_dict = {}
bl = [""]
#==============================================================================#
def restartBot():
print ("[ INFO ] BOT RESETTED")
backupData()
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)
backup = ban
f = codecs.open('ban.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 = """╔══════════════
╠♥ ✿✿✿ 喵の特製單體半垢 ✿✿✿ ♥
║
╠══✪〘 Help Message 〙✪═══
║
╠✪〘 Help 〙✪══════════
╠➥ Help 查看指令
║
╠✪〘 Status 〙✪════════
╠➥ Restart 重新啟動
╠➥ Save 儲存設定
╠➥ Runtime 運作時間
╠➥ Speed 速度
╠➥ Set 設定
╠➥ About關於本帳
║
╠✪〘 Settings 〙✪═══════
╠➥ AutoAdd On/Off 自動加入
╠➥ AutoJoin On/Off 自動進群
╠➥ AutoLeave On/Off 離開副本
╠➥ AutoRead On/Off 自動已讀
╠➥ Share On/Off 公開/私人
╠➥ ReRead On/Off 查詢收回
╠➥ Pro On/Off 所有保護
╠➥ Protect On/Off 踢人保護
╠➥ QrProtect On/Off 網址保護
╠➥ Invprotect On/Off 邀請保護
╠➥ Getmid On/Off 取得mid
╠➥ Detect On/Off 標註偵測
╠➥ Timeline On/Off 文章網址預覽
║
╠✪〘 Self 〙✪═════════
╠➥ Me 我的連結
╠➥ MyMid 我的mid
╠➥ MyName 我的名字
╠➥ MyBio 個簽
╠➥ MyPicture 我的頭貼
╠➥ MyCover 我的封面
╠➥ Contact @ 標註取得連結
╠➥ Mid @ 標註查mid
╠➥ Name @ 查看名字
║
╠✪〘 Blacklist 〙✪═══════
╠➥ Ban @ 加入黑單
╠➥ Unban @ 取消黑單
╠➥ Banlist 查看黑單
╠➥ CleanBan 清空黑單
╠➥ Nkban 踢除黑單
║
╠✪〘 Group 〙✪════════
╠➥ GroupCreator創群者
╠➥ GroupId 群組ID
╠➥ GroupName 群組名稱
╠➥ GroupPicture 群組圖片
╠➥ GroupLink 群組網址
╠➥ Link「On/Off」網址開啟/關閉
╠➥ GroupList所有群組列表
╠➥ GroupMemberList 成員名單
╠➥ GroupInfo 群組資料
╠➥ Gn (文字) 更改群名
╠➥ Nk @ 單、多踢
╠➥ Zk 踢出0字元
╠➥ Byeall翻群
╠➥ Inv (mid) 透過mid邀請
╠➥ Inv @ 標註多邀
╠➥ Cancel 取消所有邀請
╠➥ Ri @ 來回機票
║
╠✪〘 Special 〙✪═══════
╠➥ Mimic「On/Off」模仿說話
╠➥ MimicList 模仿名單
╠➥ MimicAdd @ 新增模仿名單
╠➥ MimicDel @ 模仿名單刪除
╠➥ Tagall 標註全體
╠➥ Zc 發送0字元友資
╠➥ Setread 已讀點設置
╠➥ Cancelread 取消偵測
╠➥ Checkread 已讀偵測
╠➥ Gbc: 群組廣播
╠➥ Fbc: 好友廣播
║
╠✪〘 Admin 〙✪═════════
╠➥ Adminadd @ 新增權限
╠➥ Admindel @ 刪除權限
╠➥ Adminlist 查看權限表
║
╠✪〘 Invite 〙✪════════
╠➥ Botsadd @ 加入自動邀請
╠➥ Botsdel @ 取消自動邀請
╠➥ Botslist 自動邀請表
╠➥ Join 自動邀請
║
╚═〘 Created By: ©ながみ すずか™ 〙"""
return helpMessage
wait2 = {
'readPoint':{},
'readMember':{},
'setTime':{},
'ROM':{}
}
setTime = {}
setTime = wait2['setTime']
def cTime_to_datetime(unixtime):
return datetime.datetime.fromtimestamp(int(str(unixtime)[:len(str(unixtime))-3]))
admin =['ud5ff1dff426cf9e3030c7ac2a61512f0','ua10c2ad470b4b6e972954e1140ad1891',clMID]
owners = ["ud5ff1dff426cf9e3030c7ac2a61512f0","ua10c2ad470b4b6e972954e1140ad1891"]
#if clMID not in owners:
# python = sys.executable
# os.execl(python, python, *sys.argv)
#==============================================================================#
def lineBot(op):
try:
if op.type == 0:
return
if op.type == 5:
print ("[ 5 ] NOTIFIED ADD CONTACT")
if settings["autoAdd"] == True:
cl.findAndAddContactsByMid(op.param1)
cl.sendMessage(op.param1, "感謝您加入本喵為好友w".format(str(cl.getContact(op.param1).displayName)))
if op.type == 11:
group = cl.getGroup(op.param1)
contact = cl.getContact(op.param2)
if settings["qrprotect"] == True:
if op.param2 in admin or op.param2 in ban["bots"]:
pass
else:
gs = cl.getGroup(op.param1)
cl.kickoutFromGroup(op.param1,[op.param2])
gs.preventJoinByTicket = True
cl.updateGroup(gs)
if op.type == 13:
print ("[ 13 ] NOTIFIED INVITE GROUP")
if clMID in op.param3:
group = cl.getGroup(op.param1)
if settings["autoJoin"] == True:
cl.acceptGroupInvitation(op.param1)
elif settings["invprotect"] == True:
if op.param2 in admin or op.param2 in ban["bots"]:
pass
else:
cl.cancelGroupInvitation(op.param1,[op.param3])
else:
group = cl.getGroup(op.param1)
gInviMids = []
for z in group.invitee:
if z.mid in ban["blacklist"]:
gInviMids.append(z.mid)
if gInviMids == []:
pass
else:
cl.cancelGroupInvitation(op.param1, gInviMids)
cl.sendMessage(op.param1,"被邀請者黑單中...")
if op.type == 17:
if op.param2 in admin or op.param2 in ban["bots"]:
return
ginfo = str(cl.getGroup(op.param1).name)
try:
strt = int(3)
akh = int(3)
akh = akh + 8
aa = """{"S":"""+json.dumps(str(strt))+""","E":"""+json.dumps(str(akh))+""","M":"""+json.dumps(op.param2)+"},"""
aa = (aa[:int(len(aa)-1)])
cl.sendMessage(op.param1, "歡迎 @wanping 加入"+ginfo , contentMetadata={'MENTION':'{"MENTIONEES":['+aa+']}'}, contentType=0)
except Exception as e:
print(str(e))
if op.type == 19:
msg = op.message
chiya = []
chiya.append(op.param2)
chiya.append(op.param3)
cmem = cl.getContacts(chiya)
zx = ""
zxc = ""
zx2 = []
xpesan ='警告!'
for x in range(len(cmem)):
xname = str(cmem[x].displayName)
pesan = ''
pesan2 = pesan+"@x 將"
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 + "出群組"
try:
cl.sendMessage(op.param1, text, contentMetadata={'MENTION':str('{"MENTIONEES":'+json.dumps(zx2).replace(' ','')+'}')}, contentType=0)
except:
cl.sendMessage(op.param1,"Notified kick out from group")
if op.param2 not in admin:
if op.param2 in ban["bots"]:
pass
elif settings["protect"] == True:
ban["blacklist"][op.param2] = True
cl.kickoutFromGroup(op.param1,[op.param2])
cl.inviteIntoGroup(op.param1,[op.param3])
else:
cl.sendMessage(op.param1,"")
else:
cl.sendMessage(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:
K0 = admin
msg = op.message
if settings["share"] == True:
K0 = msg._from
else:
K0 = admin
# if op.type == 25 :
# if msg.toType ==2:
# g = cl.getGroup(op.message.to)
# print ("sended:".format(str(g.name)) + str(msg.text))
# else:
# print ("sended:" + str(msg.text))
# if op.type == 26:
# msg =op.message
# pop = cl.getContact(msg._from)
# print ("replay:"+pop.displayName + ":" + str(msg.text))
if op.type == 26 or op.type == 25:
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 K0 or sender in owners:
if text.lower() == 'help':
helpMessage = helpmessage()
cl.sendMessage(to, str(helpMessage))
cl.sendContact(to,"ua10c2ad470b4b6e972954e1140ad1891")
elif text.lower() == 'bye':
cl.sendMessage(to,"ByeBye")
cl.leaveGroup(msg.to)
#==============================================================================#
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() == 'save':
backupData()
cl.sendMessage(to,"儲存設定成功!")
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["protect"] ==True: ret_+="\n╠ Protect ✅"
else: ret_ += "\n╠ Protect ❌"
if settings["qrprotect"] ==True: ret_+="\n╠ QrProtect ✅"
else: ret_ += "\n╠ QrProtect ❌"
if settings["invprotect"] ==True: ret_+="\n╠ InviteProtect ✅"
else: ret_ += "\n╠ InviteProtect ❌"
if settings["detectMention"] ==True: ret_+="\n╠ DetectMention ✅"
else: ret_ += "\n╠ DetectMention ❌"
if settings["reread"] ==True: ret_+="\n╠ Reread ✅"
else: ret_ += "\n╠ Reread ❌"
if settings["share"] ==True: ret_+="\n╠ Share ✅"
else: ret_ += "\n╠ Share ❌"
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() == '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() == 'protect on':
settings["protect"] = True
cl.sendMessage(to, "踢人保護開啟")
elif text.lower() == 'protect off':
settings["protect"] = False
cl.sendMessage(to, "踢人保護關閉")
elif text.lower() == 'share on':
settings["share"] = True
cl.sendMessage(to, "已開啟分享")
elif text.lower() == 'share off':
settings["share"] = False
cl.sendMessage(to, "已關閉分享")
elif text.lower() == 'detect on':
settings["detectMention"] = True
cl.sendMessage(to, "已開啟標註偵測")
elif text.lower() == 'detect off':
settings["detectMention"] = False
cl.sendMessage(to, "已關閉標註偵測")
elif text.lower() == 'qrprotect on':
settings["qrprotect"] = True
cl.sendMessage(to, "網址保護開啟")
elif text.lower() == 'qrprotect off':
settings["qrprotect"] = False
cl.sendMessage(to, "網址保護關閉")
elif text.lower() == 'invprotect on':
settings["invprotect"] = True
cl.sendMessage(to, "邀請保護開啟")
elif text.lower() == 'invprotect off':
settings["invprotect"] = False
cl.sendMessage(to, "邀請保護關閉")
elif text.lower() == 'getmid on':
settings["getmid"] = True
cl.sendMessage(to, "mid獲取開啟")
elif text.lower() == 'getmid off':
settings["getmid"] = False
cl.sendMessage(to, "mid獲取關閉")
elif text.lower() == 'timeline on':
settings["timeline"] = True
cl.sendMessage(to, "文章預覽開啟")
elif text.lower() == 'timeline off':
settings["timeline"] = False
cl.sendMessage(to, "文章預覽關閉")
elif text.lower() == 'pro on':
settings["protect"] = True
settings["qrprotect"] = True
settings["invprotect"] = True
cl.sendMessage(to, "踢人保護開啟")
cl.sendMessage(to, "網址保護開啟")
cl.sendMessage(to, "邀請保護開啟")
elif text.lower() == 'pro off':
settings["protect"] = False
settings["qrprotect"] = False
settings["invprotect"] = False
cl.sendMessage(to, "踢人保護關閉")
cl.sendMessage(to, "網址保護關閉")
cl.sendMessage(to, "邀請保護關閉")
#==============================================================================#
elif msg.text.lower().startswith("adminadd "):
MENTION = eval(msg.contentMetadata['MENTION'])
inkey = MENTION['MENTIONEES'][0]['M']
admin.append(str(inkey))
cl.sendMessage(to, "已獲得權限!")
elif msg.text.lower().startswith("admindel "):
MENTION = eval(msg.contentMetadata['MENTION'])
inkey = MENTION['MENTIONEES'][0]['M']
admin.remove(str(inkey))
cl.sendMessage(to, "已取消權限!")
elif text.lower() == 'adminlist':
if admin == []:
cl.sendMessage(to,"無擁有權限者!")
else:
mc = "╔══[ Admin List ]"
for mi_d in admin:
mc += "\n╠ "+cl.getContact(mi_d).displayName
cl.sendMessage(to,mc + "\n╚══[ Finish ]")
elif msg.text.lower().startswith("invite "):
targets = []
key = eval(msg.contentMetadata["MENTION"])
key["MENTIONEES"][0]["M"]
for x in key["MENTIONEES"]:
targets.append(x["M"])
G = cl.getGroup
cl.inviteIntoGroup(to,targets)
elif ("Say " in msg.text):
x = text.split(' ',2)
c = int(x[2])
for c in range(c):
cl.sendMessage(to,x[1])
elif msg.text.lower().startswith("tag "):
MENTION = eval(msg.contentMetadata['MENTION'])
inkey = MENTION['MENTIONEES'][0]['M']
x = text.split(' ',2)
c = int(x[2])
for c in range(c):
sendMessageWithMention(to, inkey)
elif msg.text.lower().startswith("botsadd "):
MENTION = eval(msg.contentMetadata['MENTION'])
inkey = MENTION['MENTIONEES'][0]['M']
ban["bots"].append(str(inkey))
cl.sendMessage(to, "已加入分機!")
elif msg.text.lower().startswith("botsdel "):
MENTION = eval(msg.contentMetadata['MENTION'])
inkey = MENTION['MENTIONEES'][0]['M']
ban["bots"].remove(str(inkey))
cl.sendMessage(to, "已取消分機!")
elif text.lower() == 'botslist':
if ban["bots"] == []:
cl.sendMessage(to,"無分機!")
else:
mc = "╔══[ Inviter List ]"
for mi_d in ban["bots"]:
mc += "\n╠ "+cl.getContact(mi_d).displayName
cl.sendMessage(to,mc + "\n╚══[ Finish ]")
elif text.lower() == 'join':
if msg.toType == 2:
G = cl.getGroup
cl.inviteIntoGroup(to,ban["bots"])
elif msg.text.lower().startswith("ii "):
MENTION = eval(msg.contentMetadata['MENTION'])
inkey = MENTION['MENTIONEES'][0]['M']
cl.createGroup("fuck",[inkey])
cl.leaveGroup(op.param1)
#==============================================================================#
elif text.lower() == 'me':
if msg.toType == 2 or msg.toType == 1:
sendMessageWithMention(to, sender)
cl.sendContact(to, sender)
else:
cl.sendContact(to,sender)
elif text.lower() == 'mymid':
cl.sendMessage(msg.to,"[MID]\n" + sender)
elif text.lower() == 'myname':
me = cl.getContact(sender)
cl.sendMessage(msg.to,"[Name]\n" + me.displayName)
elif text.lower() == 'mybio':
me = cl.getContact(sender)
cl.sendMessage(msg.to,"[StatusMessage]\n" + me.statusMessage)
elif text.lower() == 'mypicture':
me = cl.getContact(sender)
cl.sendImageWithURL(msg.to,"http://dl.profile.line-cdn.net/" + me.pictureStatus)
elif text.lower() == 'myvideoprofile':
me = cl.getContact(sender)
cl.sendVideoWithURL(msg.to,"http://dl.profile.line-cdn.net/" + me.pictureStatus + "/vp")
elif text.lower() == 'mycover':
me = cl.getContact(sender)
cover = cl.getProfileCoverURL(sender)
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 mention in mentionees:
if mention["M"] not in lists:
lists.append(mention["M"])
for ls in lists:
path = "http://dl.profile.line-cdn.net/" + cl.getContact(ls).pictureStatus
cl.sendImageWithURL(msg.to, str(path))
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("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:
ban["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 ban["mimic"]["target"] == {}:
cl.sendMessage(msg.to,"未設定模仿目標")
else:
mc = "╔══[ Mimic List ]"
for mi_d in ban["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 ban["mimic"]["status"] == False:
ban["mimic"]["status"] = True
cl.sendMessage(msg.to,"Reply Message on")
elif mic == "off":
if ban["mimic"]["status"] == True:
ban["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, "Grouplink未開啟 {}openlink".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 = "不明"
if group.invitee is None:
gPending = "0"
else:
gPending = str(len(group.invitee))
if group.preventedJoinByTicket == True:
gQr = "關閉"
gTicket = "無"
else:
gQr = "開啟"
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╠ 網址狀態 : {}".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 "Zk" in msg.text:
gs = cl.getGroup(to)
targets = []
for g in gs.members:
if g.displayName in "":
targets.append(g.mid)
if targets == []:
pass
else:
for target in targets:
if target in admin:
pass
else:
try:
cl.kickoutFromGroup(to,[target])
except:
pass
elif msg.text.lower().startswith("ri "):
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,"來回機票一張ww")
cl.kickoutFromGroup(msg.to,[target])
cl.inviteIntoGroup(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() == 'cancel':
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 ("Inv " in msg.text):
if msg.toType == 2:
midd = msg.text.replace("Inv ","")
cl.findAndAddContactsByMid(midd)
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() == 'zt':
gs = cl.getGroup(to)
targets = []
for g in gs.members:
if g.displayName in "":
targets.append(g.mid)
if targets == []:
pass
else:
for target in targets:
sendMessageWithMention(to,target)
elif text.lower() == 'zm':
gs = cl.getGroup(to)
targets = []
for g in gs.members:
if g.displayName in "":
targets.append(g.mid)
if targets == []:
pass
else:
for mi_d in targets:
cl.sendContect(to,mi_d)
elif text.lower() == 'setread':
cl.sendMessage(msg.to, "已讀點設置成功")
try:
del wait2['readPoint'][msg.to]
del wait2['readMember'][msg.to]
except:
pass
now2 = datetime.now()
wait2['readPoint'][msg.to] = msg.id
wait2['readMember'][msg.to] = ""
wait2['setTime'][msg.to] = datetime.strftime(now2,"%H:%M")
wait2['ROM'][msg.to] = {}
elif text.lower() == "cancelread":
cl.sendMessage(to, "已讀點已刪除")
try:
del wait2['readPoint'][msg.to]
del wait2['readMember'][msg.to]
del wait2['setTime'][msg.to]
except:
pass
elif msg.text in ["checkread","Checkread"]:
if msg.to in wait2['readPoint']:
if wait2["ROM"][msg.to].items() == []:
chiya = ""
else:
chiya = ""
for rom in wait2["ROM"][msg.to].items():
chiya += rom[1] + "\n"
cl.sendMessage(msg.to, "[已讀順序]%s\n\n[已讀的人]:\n%s\n查詢時間:[%s]" % (wait2['readMember'][msg.to],chiya,setTime[msg.to]))
else:
cl.sendMessage(msg.to, "請輸入setread")
#==============================================================================#
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:
ban["blacklist"][target] = True
cl.sendMessage(msg.to,"已加入黑單!")
break
except:
cl.sendMessage(msg.to,"添加失敗 !")
break
elif "Ban:" in msg.text:
mmtxt = text.replace("Ban:","")
try:
ban["blacklist"][mmtext] = True
cl.sendMessage(msg.to,"已加入黑單!")
except:
cl.sendMessage(msg.to,"添加失敗 !")
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 ban["blacklist"][target]
cl.sendMessage(msg.to,"刪除成功 !")
break
except:
cl.sendMessage(msg.to,"刪除失敗 !")
break
elif text.lower() == 'banlist':
if ban["blacklist"] == {}:
cl.sendMessage(msg.to,"無黑單成員!")
else:
mc = "╔══[ Black List ]"
for mi_d in ban["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 ban["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':
for mi_d in ban["blacklist"]:
ban["blacklist"] = {}
cl.sendMessage(to, "已清空黑名單")
elif text.lower() == 'banmidlist':
if ban["blacklist"] == {}:
cl.sendMessage(msg.to,"無黑單成員!")
else:
mc = "╔══[ Black List ]"
for mi_d in ban["blacklist"]:
mc += "\n╠ "+mi_d
cl.sendMessage(to,mc + "\n╚══[ Finish ]")