forked from wkwkwkwkw/BotKick
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbotkick.py
More file actions
167 lines (143 loc) · 5.04 KB
/
botkick.py
File metadata and controls
167 lines (143 loc) · 5.04 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
# -*- coding: utf-8 -*-
# Edited from script LineVodka script made by Merkremont
from LineAlpha import LineClient
from LineAlpha.LineApi import LineTracer
from LineAlpha.LineThrift.ttypes import Message
from LineAlpha.LineThrift.TalkService import Client
import time, datetime, random ,sys, re, string, os, json
reload(sys)
sys.setdefaultencoding('utf-8')
client = LineClient()
client._qrLogin("line://au/q/")
profile, setting, tracer = client.getProfile(), client.getSettings(), LineTracer(client)
offbot, messageReq, wordsArray, waitingAnswer = [], {}, {}, {}
print client._loginresult()
wait = {
'readPoint':{},
'readMember':{},
'setTime':{},
'ROM':{}
}
setTime = {}
setTime = wait["setTime"]
def sendMessage(to, text, contentMetadata={}, contentType=0):
mes = Message()
mes.to, mes.from_ = to, profile.mid
mes.text = text
mes.contentType, mes.contentMetadata = contentType, contentMetadata
if to not in messageReq:
messageReq[to] = -1
messageReq[to] += 1
client._client.sendMessage(messageReq[to], mes)
def NOTIFIED_ADD_CONTACT(op):
try:
sendMessage(op.param1, client.getContact(op.param1).displayName + "Thanks for add")
except Exception as e:
print e
print ("\n\nNOTIFIED_ADD_CONTACT\n\n")
return
tracer.addOpInterrupt(5,NOTIFIED_ADD_CONTACT)
def NOTIFIED_ACCEPT_GROUP_INVITATION(op):
#print op
try:
sendMessage(op.param1, client.getContact(op.param2).displayName + "WELCOME to " + group.name)
except Exception as e:
print e
print ("\n\nNOTIFIED_ACCEPT_GROUP_INVITATION\n\n")
return
tracer.addOpInterrupt(17,NOTIFIED_ACCEPT_GROUP_INVITATION)
def NOTIFIED_KICKOUT_FROM_GROUP(op):
try:
sendMessage(op.param1, client.getContact(op.param3).displayName + " Good Bye\n(*´・ω・*)")
except Exception as e:
print e
print ("\n\nNOTIFIED_KICKOUT_FROM_GROUP\n\n")
return
tracer.addOpInterrupt(19,NOTIFIED_KICKOUT_FROM_GROUP)
def NOTIFIED_LEAVE_GROUP(op):
try:
sendMessage(op.param1, client.getContact(op.param2).displayName + " Good Bye\n(*´・ω・*)")
except Exception as e:
print e
print ("\n\nNOTIFIED_LEAVE_GROUP\n\n")
return
tracer.addOpInterrupt(15,NOTIFIED_LEAVE_GROUP)
def NOTIFIED_READ_MESSAGE(op):
#print op
try:
if op.param1 in wait['readPoint']:
Name = client.getContact(op.param2).displayName
if Name in wait['readMember'][op.param1]:
pass
else:
wait['readMember'][op.param1] += "\n・" + Name
wait['ROM'][op.param1][op.param2] = "・" + Name
else:
pass
except:
pass
tracer.addOpInterrupt(55, NOTIFIED_READ_MESSAGE)
def RECEIVE_MESSAGE(op):
msg = op.message
try:
if msg.contentType == 0:
try:
if msg.to in wait['readPoint']:
if msg.from_ in wait["ROM"][msg.to]:
del wait["ROM"][msg.to][msg.from_]
else:
pass
except:
pass
else:
pass
except KeyboardInterrupt:
sys.exit(0)
except Exception as error:
print error
print ("\n\nRECEIVE_MESSAGE\n\n")
return
tracer.addOpInterrupt(26, RECEIVE_MESSAGE)
def SEND_MESSAGE(op):
msg = op.message
try:
if msg.toType == 2:
if msg.contentType == 0:
#if "gname:" in msg.text:
#--------------------------------------------------------------
if msg.text == "Kick":
print "ok"
_name = msg.text.replace("Kick","")
gs = client.getGroup(msg.to)
sendMessage(msg.to,"Waktunya Untuk Meng Kick Orang Di Group Ini Anjay Wkwk")
targets = []
for g in gs.members:
if _name in g.displayName:
targets.append(g.mid)
if targets == []:
sendMessage(msg.to,"error")
else:
for target in targets:
try:
klist=[client]
kicker=random.choice(klist)
kicker.kickoutFromGroup(msg.to,[target])
print (msg.to,[g.mid])
except:
sendText(msg.to,"error")
#-------------------------------------------------------------
if msg.text == "Salken all":
start = time.time()
sendMessage(msg.to, "hehehe")
elapsed_time = time.time() - start
sendMessage(msg.to, "%sseconds" % (elapsed_time))
#-------------------------------------------------------------
else:
pass
except Exception as e:
print e
print ("\n\nSEND_MESSAGE\n\n")
return
tracer.addOpInterrupt(25,SEND_MESSAGE)
while True:
tracer.execute()