-
Notifications
You must be signed in to change notification settings - Fork 13
/
kick.py
54 lines (41 loc) · 1.36 KB
/
kick.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
from linepy import *
from dotenv import load_dotenv, find_dotenv
from var_dump import var_dump
import os
load_dotenv(find_dotenv())
LINE_EMAIL = os.getenv('LINE_EMAIL')
LINE_PASS = os.getenv('LINE_PASS')
line= LINE(LINE_EMAIL, LINE_PASS)
oepoll = OEPoll(line)
prohibitedWords = ['Asu', 'Jancuk', 'Tai']
userTemp = {}
userKicked = []
def TERIMA_PESAN(op):
try:
msg = op.message
text = msg.text
receiver = msg.to
sender = msg._from
msg_id = msg.id
# Jika kita menerima pesan dari grup
if msg.toType == 2:
var_dump(userTemp)
displayName = line.getContact(sender).displayName
if text in prohibitedWords:
if sender in userTemp:
userTemp[sender] = userTemp.get(sender) + 1
# Jika sudah melebihi dari 3, maka akan terkick
if userTemp.get(sender) > 3:
userKicked.append(sender)
line.kickoutFromGroup(receiver, userKicked)
line.log("{} telah terkick dari grup".format(displayName))
userTemp.pop(sender)
else:
userTemp[sender] = 1
except Exception as e:
line.log(str(e))
oepoll.addOpInterruptWithDict({
OpType.RECEIVE_MESSAGE : TERIMA_PESAN
})
while True:
oepoll.trace()