-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsb.py
204 lines (195 loc) · 9.5 KB
/
sb.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
# -*- coding: utf-8 -*-
from linepy import *
import json, time, random
client = LineClient()
#client = LineClient(authToken='AuthToken')
client.log("Auth Token : " + str(client.authToken))
channel = LineChannel(client)
client.log("Channel Access Token : " + str(channel.channelAccessToken))
poll = LinePoll(client)
cctv={
"cyduk":{},
"point":{},
"sidermem":{}
}
def mention(to, nama):
aa = ""
bb = ""
strt = int(0)
akh = int(0)
nm = nama
myid = client.getProfile().mid
if myid in nm:
nm.remove(myid)
#print nm
for mm in nm:
akh = akh + 6
aa += """{"S":"""+json.dumps(str(strt))+""","E":"""+json.dumps(str(akh))+""","M":"""+json.dumps(mm)+"},"""
strt = strt + 7
akh = akh + 1
bb += "@nrik \n"
aa = (aa[:int(len(aa)-1)])
text = bb
try:
client.sendMessage(to, text, contentMetadata={'MENTION':'{"MENTIONEES":['+aa+']}'}, contentType=0)
except Exception as error:
print(error)
while True:
try:
ops=poll.singleTrace(count=50)
for op in ops:
if op.type == OpType.RECEIVE_MESSAGE:
msg = op.message
if msg.text != None:
if msg.toType == 2:
may = client.getProfile().mid
#if may in str(msg.contentMetadata):
#pilih = ['/join']
#rslt = random.choice(pilih)
#client.sendText(msg.to, str(rslt))
if msg.text == "Pertempuran akan dimulai dalam 1 Menit. Ketik /join untuk mengikuti pertempuran":
time.sleep(3)
client.sendText(msg.to, "/join")
else:
pass
else:
pass
else:
pass
if op.type == OpType.SEND_MESSAGE:
msg = op.message
text = msg.text
msg_id = msg.id
receiver = msg.to
sender = msg._from
try:
if msg.contentType == 0:
if msg.toType == 2:
client.sendChatChecked(receiver, msg_id)
contact = client.getContact(sender)
if text.lower() == 'me':
client.sendMessage(receiver, None, contentMetadata={'mid': sender}, contentType=13)
elif text.lower() == 'speed':
start = time.time()
client.sendText(receiver, "TestSpeed")
elapsed_time = time.time() - start
client.sendText(receiver, "%sdetik" % (elapsed_time))
elif 'spic' in text.lower():
try:
key = eval(msg.contentMetadata["MENTION"])
u = key["MENTIONEES"][0]["M"]
a = client.getContact(u).pictureStatus
print(client.getContact(u))
client.sendImageWithURL(receiver, 'http://dl.profile.line.naver.jp/'+a)
except Exception as e:
print(e)
elif 'scover' in text.lower():
try:
key = eval(msg.contentMetadata["MENTION"])
u = key["MENTIONEES"][0]["M"]
a = client.getProfileCoverURL(mid=u)
print(a)
client.sendImageWithURL(receiver, a)
except Exception as e:
print(e)
elif text.lower() == 'tagall':
group = client.getGroup(msg.to)
nama = [contact.mid for contact in group.members]
nm1, nm2, nm3, nm4, nm5, jml = [], [], [], [], [], len(nama)
if jml <= 100:
mention(msg.to, nama)
if jml > 100 and jml < 200:
for i in range(0, 100):
nm1 += [nama[i]]
mention(msg.to, nm1)
for j in range(101, len(nama)):
nm2 += [nama[j]]
mention(msg.to, nm2)
if jml > 200 and jml < 300:
for i in range(0, 100):
nm1 += [nama[i]]
mention(msg.to, nm1)
for j in range(101, 200):
nm2 += [nama[j]]
mention(msg.to, nm2)
for k in range(201, len(nama)):
nm3 += [nama[k]]
mention(msg.to, nm3)
if jml > 300 and jml < 400:
for i in range(0, 100):
nm1 += [nama[i]]
mention(msg.to, nm1)
for j in range(101, 200):
nm2 += [nama[j]]
mention(msg.to, nm2)
for k in range(201, len(nama)):
nm3 += [nama[k]]
mention(msg.to, nm3)
for l in range(301, len(nama)):
nm4 += [nama[l]]
mention(msg.to, nm4)
if jml > 400 and jml < 501:
for i in range(0, 100):
nm1 += [nama[i]]
mention(msg.to, nm1)
for j in range(101, 200):
nm2 += [nama[j]]
mention(msg.to, nm2)
for k in range(201, len(nama)):
nm3 += [nama[k]]
mention(msg.to, nm3)
for l in range(301, len(nama)):
nm4 += [nama[l]]
mention(msg.to, nm4)
for m in range(401, len(nama)):
nm5 += [nama[m]]
mention(msg.to, nm5)
client.sendText(receiver, "Members :"+str(jml))
elif text.lower() == 'ceksider':
try:
del cctv['point'][msg.to]
del cctv['sidermem'][msg.to]
del cctv['cyduk'][msg.to]
except:
pass
cctv['point'][msg.to] = msg.id
cctv['sidermem'][msg.to] = ""
cctv['cyduk'][msg.to]=True
elif text.lower() == 'offread':
if msg.to in cctv['point']:
cctv['cyduk'][msg.to]=False
client.sendText(msg.to, cctv['sidermem'][msg.to])
else:
client.sendText(msg.to, "Heh belom di Set")
except Exception as e:
client.log("[SEND_MESSAGE] ERROR : " + str(e))
if op.type == OpType.NOTIFIED_READ_MESSAGE:
try:
if cctv['cyduk'][op.param1]==True:
if op.param1 in cctv['point']:
Name = client.getContact(op.param2).displayName
if Name in cctv['sidermem'][op.param1]:
pass
else:
cctv['sidermem'][op.param1] += "\n~ " + Name
#cl.mention(op.param1, op.param2)
if " " in Name:
nick = Name.split(' ')
if len(nick) == 2:
client.sendText(op.param1, 'haii... '+nick[0])
else:
client.sendText(op.param1, 'paagi '+nick[1])
else:
client.sendText(op.param1, 'hai '+Name)
else:
pass
else:
pass
except:
pass
else:
pass
# Don't remove this line, if you wan't get error soon!
poll.setRevision(op.revision)
except Exception as e:
client.log("[SINGLE_TRACE] ERROR : " + str(e))