mirror of
https://github.com/studio-neptune/yuuki.git
synced 2024-11-10 17:14:06 +08:00
Update Security
This commit is contained in:
parent
018f47b7ef
commit
eb2ae2dcff
3 changed files with 62 additions and 17 deletions
|
@ -20,6 +20,7 @@ class English:
|
||||||
"Admin of the Group:\n%s": "Admin of the Group:\n%s",
|
"Admin of the Group:\n%s": "Admin of the Group:\n%s",
|
||||||
"Sorry...\nThe number of members is not satisfied (%s needed)": "Sorry...\nThe number of members is not satisfied (%s needed)",
|
"Sorry...\nThe number of members is not satisfied (%s needed)": "Sorry...\nThe number of members is not satisfied (%s needed)",
|
||||||
"LINE System UserID:\n": "LINE System UserID:\n",
|
"LINE System UserID:\n": "LINE System UserID:\n",
|
||||||
|
"Kick Limit.": "Kick Limit.",
|
||||||
"Testing...": "Testing...",
|
"Testing...": "Testing...",
|
||||||
"Speed:\n%ss": "Speed:\n%ss",
|
"Speed:\n%ss": "Speed:\n%ss",
|
||||||
"Bye Bye": "Bye Bye",
|
"Bye Bye": "Bye Bye",
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import os, time, \
|
import os, time, \
|
||||||
requests, \
|
requests, \
|
||||||
json, ntpath,\
|
json, ntpath,\
|
||||||
traceback
|
random, traceback
|
||||||
|
|
||||||
|
|
||||||
from .core.TalkService import *
|
from .core.TalkService import *
|
||||||
|
@ -20,6 +20,7 @@ class Yuuki_Settings:
|
||||||
config = {
|
config = {
|
||||||
"Seq": 0,
|
"Seq": 0,
|
||||||
"Admin": [],
|
"Admin": [],
|
||||||
|
"Hour_KickLimit": 10,
|
||||||
"Default_Language": "en",
|
"Default_Language": "en",
|
||||||
"GroupMebers_Demand": 100,
|
"GroupMebers_Demand": 100,
|
||||||
"helper_LINE_ACCESS_KEYs": []
|
"helper_LINE_ACCESS_KEYs": []
|
||||||
|
@ -32,6 +33,9 @@ class Yuuki:
|
||||||
self.Seq = self.YuukiConfigs["Seq"]
|
self.Seq = self.YuukiConfigs["Seq"]
|
||||||
self.Admin = self.YuukiConfigs["Admin"]
|
self.Admin = self.YuukiConfigs["Admin"]
|
||||||
|
|
||||||
|
self.KickedTimes = {}
|
||||||
|
self.KickLimit = self.YuukiConfigs["Hour_KickLimit"]
|
||||||
|
|
||||||
self.data = Yuuki_Data()
|
self.data = Yuuki_Data()
|
||||||
self.i18n = Yuuki_LangSetting(self.YuukiConfigs["Default_Language"])
|
self.i18n = Yuuki_LangSetting(self.YuukiConfigs["Default_Language"])
|
||||||
|
|
||||||
|
@ -45,6 +49,9 @@ class Yuuki:
|
||||||
for access in self.YuukiConfigs["helper_LINE_ACCESS_KEYs"]:
|
for access in self.YuukiConfigs["helper_LINE_ACCESS_KEYs"]:
|
||||||
self.Connect.helperConnect(access)
|
self.Connect.helperConnect(access)
|
||||||
|
|
||||||
|
for client in [self.client] + self.Connect.helper:
|
||||||
|
self.KickedTimes[client] = self.KickLimit
|
||||||
|
|
||||||
self.MyMID = self.client.getProfile().mid
|
self.MyMID = self.client.getProfile().mid
|
||||||
|
|
||||||
global _
|
global _
|
||||||
|
@ -101,10 +108,10 @@ class Yuuki:
|
||||||
self.client.acceptGroupInvitation(self.Seq, cleanInvitations)
|
self.client.acceptGroupInvitation(self.Seq, cleanInvitations)
|
||||||
self.client.leaveGroup(self.Seq, cleanInvitations)
|
self.client.leaveGroup(self.Seq, cleanInvitations)
|
||||||
|
|
||||||
def getContact(self, mid):
|
def getContact(self, userId):
|
||||||
if len(mid) == len(self.MyMID) and mid[0] == "u":
|
if len(userId) == len(self.userId) and userId[0] == "u":
|
||||||
try:
|
try:
|
||||||
contactInfo = self.getContact(mid)
|
contactInfo = self.getContact(userId)
|
||||||
except:
|
except:
|
||||||
contactInfo = False
|
contactInfo = False
|
||||||
else:
|
else:
|
||||||
|
@ -123,6 +130,31 @@ class Yuuki:
|
||||||
elif Message.type == OpType.NOTIFIED_KICKOUT_FROM_GROUP:
|
elif Message.type == OpType.NOTIFIED_KICKOUT_FROM_GROUP:
|
||||||
return Message.param1
|
return Message.param1
|
||||||
|
|
||||||
|
def getClientByMid(self, userId):
|
||||||
|
Accounts = [self.client] + self.Connect.helper
|
||||||
|
for count, AccountUserId in enumerate([self.MyMID] + self.Connect.helper_ids):
|
||||||
|
if AccountUserId == userId:
|
||||||
|
return Accounts[count]
|
||||||
|
|
||||||
|
def kickLimitReset(self):
|
||||||
|
for client in [self.client] + self.Connect.helper:
|
||||||
|
self.KickedTimes[client] = self.KickLimit
|
||||||
|
|
||||||
|
def kickSomeone(self, groupId, userId, exceptAccount=None):
|
||||||
|
if len(self.Connect.helper) >= 1:
|
||||||
|
accounts = [self.client] + self.Connect.helper
|
||||||
|
if exceptAccount:
|
||||||
|
accounts.remove(exceptAccount)
|
||||||
|
helper = max(accounts, key=accounts.get)
|
||||||
|
else:
|
||||||
|
helper = self.client
|
||||||
|
|
||||||
|
if self.KickedTimes[helper] > 0:
|
||||||
|
helper.kickoutFromGroup(self.Seq, groupId, [userId])
|
||||||
|
self.KickedTimes[helper] -= 1
|
||||||
|
else:
|
||||||
|
self.sendText(groupId, _("Kick Limit."))
|
||||||
|
|
||||||
def sendToWho(self, Message):
|
def sendToWho(self, Message):
|
||||||
if Message.message.toType == MIDType.USER:
|
if Message.message.toType == MIDType.USER:
|
||||||
return Message.message.from_
|
return Message.message.from_
|
||||||
|
@ -135,14 +167,16 @@ class Yuuki:
|
||||||
message = Message(to=toid, text=msg)
|
message = Message(to=toid, text=msg)
|
||||||
self.client.sendMessage(self.Seq, message)
|
self.client.sendMessage(self.Seq, message)
|
||||||
|
|
||||||
def sendUser(self, toid, mid):
|
def sendUser(self, toid, userId):
|
||||||
message = Message(contentType=ContentType.CONTACT,
|
message = Message(
|
||||||
|
contentType=ContentType.CONTACT,
|
||||||
text='',
|
text='',
|
||||||
contentMetadata={
|
contentMetadata={
|
||||||
'mid': mid,
|
'mid': userId,
|
||||||
'displayName': 'LINE User',
|
'displayName': 'LINE User',
|
||||||
},
|
},
|
||||||
to=toid)
|
to=toid
|
||||||
|
)
|
||||||
self.client.sendMessage(self.Seq, message)
|
self.client.sendMessage(self.Seq, message)
|
||||||
|
|
||||||
def sendMedia(self, toid, type, path):
|
def sendMedia(self, toid, type, path):
|
||||||
|
@ -234,10 +268,10 @@ class Yuuki:
|
||||||
NOTIFIED_UPDATE_GROUP (11)
|
NOTIFIED_UPDATE_GROUP (11)
|
||||||
NOTIFIED_INVITE_INTO_GROUP (13)
|
NOTIFIED_INVITE_INTO_GROUP (13)
|
||||||
NOTIFIED_ACCEPT_GROUP_INVITATION (17)
|
NOTIFIED_ACCEPT_GROUP_INVITATION (17)
|
||||||
KICKOUT_FROM_GROUP (18)
|
|
||||||
NOTIFIED_KICKOUT_FROM_GROUP (19)
|
NOTIFIED_KICKOUT_FROM_GROUP (19)
|
||||||
"""
|
"""
|
||||||
SEGroup = self.data.getSEGroup(self.securityForWhere(ncMessage))
|
GroupID = self.securityForWhere(ncMessage)
|
||||||
|
SEGroup = self.data.getSEGroup(GroupID)
|
||||||
|
|
||||||
if SEGroup[ncMessage.type]:
|
if SEGroup[ncMessage.type]:
|
||||||
if ncMessage.type == OpType.NOTIFIED_UPDATE_GROUP:
|
if ncMessage.type == OpType.NOTIFIED_UPDATE_GROUP:
|
||||||
|
@ -246,10 +280,16 @@ class Yuuki:
|
||||||
pass
|
pass
|
||||||
elif ncMessage.type == OpType.NOTIFIED_ACCEPT_GROUP_INVITATION:
|
elif ncMessage.type == OpType.NOTIFIED_ACCEPT_GROUP_INVITATION:
|
||||||
pass
|
pass
|
||||||
elif ncMessage.type == OpType.KICKOUT_FROM_GROUP:
|
|
||||||
pass
|
|
||||||
elif ncMessage.type == OpType.NOTIFIED_KICKOUT_FROM_GROUP:
|
elif ncMessage.type == OpType.NOTIFIED_KICKOUT_FROM_GROUP:
|
||||||
|
if ncMessage.param2 in self.Connect.helper_ids:
|
||||||
|
self.data.updateLog("", ())
|
||||||
|
else:
|
||||||
|
if ncMessage.param3 in [self.MyMID] + self.Connect.helper_ids:
|
||||||
|
# Block
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
self.sendText(GroupID, _("Bye Bye"))
|
||||||
|
self.kickSomeone(GroupID, ncMessage.param2)
|
||||||
|
|
||||||
# Main
|
# Main
|
||||||
|
|
||||||
|
@ -268,6 +308,8 @@ class Yuuki:
|
||||||
for ncMessage in catchedNews:
|
for ncMessage in catchedNews:
|
||||||
if ncMessage.type == OpType.NOTIFIED_INVITE_INTO_GROUP:
|
if ncMessage.type == OpType.NOTIFIED_INVITE_INTO_GROUP:
|
||||||
self.JoinGroup(ncMessage)
|
self.JoinGroup(ncMessage)
|
||||||
|
elif ncMessage.type == OpType.NOTIFIED_KICKOUT_FROM_GROUP:
|
||||||
|
self.Security(ncMessage)
|
||||||
elif ncMessage.type == OpType.RECEIVE_MESSAGE:
|
elif ncMessage.type == OpType.RECEIVE_MESSAGE:
|
||||||
self.Commands(ncMessage)
|
self.Commands(ncMessage)
|
||||||
if ncMessage.reqSeq != -1:
|
if ncMessage.reqSeq != -1:
|
||||||
|
|
2
main.py
2
main.py
|
@ -12,6 +12,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Admin = [""]
|
Admin = [""]
|
||||||
|
KickLimit = 10
|
||||||
Language = "en"
|
Language = "en"
|
||||||
LINE_ACCESS_KEY = ""
|
LINE_ACCESS_KEY = ""
|
||||||
GroupMebers_Demand = 100
|
GroupMebers_Demand = 100
|
||||||
|
@ -39,6 +40,7 @@ Settings = Yuuki_Settings()
|
||||||
Settings.config = {
|
Settings.config = {
|
||||||
"Seq": 0,
|
"Seq": 0,
|
||||||
"Admin": Admin,
|
"Admin": Admin,
|
||||||
|
"Hour_KickLimit": KickLimit,
|
||||||
"Default_Language": Language,
|
"Default_Language": Language,
|
||||||
"GroupMebers_Demand": GroupMebers_Demand,
|
"GroupMebers_Demand": GroupMebers_Demand,
|
||||||
"helper_LINE_ACCESS_KEYs": helper_LINE_ACCESS_KEYs
|
"helper_LINE_ACCESS_KEYs": helper_LINE_ACCESS_KEYs
|
||||||
|
|
Loading…
Reference in a new issue