diff --git a/libs/__init__.py b/libs/__init__.py index 46ad91e..11c648c 100644 --- a/libs/__init__.py +++ b/libs/__init__.py @@ -1,4 +1,4 @@ -from .yuuki import Yuuki +from .yuuki import Yuuki, Yuuki_Settings from .connection import Yuuki_Connection -__all__ = ['Yuuki', 'Yuuki_Connection'] \ No newline at end of file +__all__ = ['Yuuki', "Yuuki_Settings", 'Yuuki_Connection'] \ No newline at end of file diff --git a/libs/i18n/en.py b/libs/i18n/en.py index 77c8410..e28c183 100644 --- a/libs/i18n/en.py +++ b/libs/i18n/en.py @@ -18,7 +18,7 @@ class English: i18nText = { "Helllo^^\nMy name is Yuuki ><\nNice to meet you OwO": "Helllo^^\nMy name is Yuuki ><\nNice to meet you OwO", "Admin of the Group:\n%s": "Admin of the Group:\n%s", - "Sorry...\nThe number of members is not satisfied (100 needed)": "Sorry...\nThe number of members is not satisfied (100 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", "Testing...": "Testing...", "Speed:\n%ss": "Speed:\n%ss", diff --git a/libs/yuuki.py b/libs/yuuki.py index bcd725f..31c0178 100644 --- a/libs/yuuki.py +++ b/libs/yuuki.py @@ -14,12 +14,26 @@ from .data import Yuuki_Data from .i18n import Yuuki_LangSetting +class Yuuki_Settings: + """ Yuuki Custom Settings """ + + config = { + "Seq": 0, + "Admin": [], + "Default_Language": "en", + "GroupMebers_Demand": 100, + "helper_LINE_ACCESS_KEYs": [] + } + class Yuuki: - def __init__(self, Seq, Yuuki_Connection, helper_LINE_ACCESS_KEYs, Lang="en", Admin=[]): - self.Seq = Seq - self.Admin = Admin + def __init__(self, Yuuki_Settings, Yuuki_Connection): + self.YuukiConfigs = Yuuki_Settings.config + + self.Seq = self.YuukiConfigs["Seq"] + self.Admin = self.YuukiConfigs["Admin"] + self.data = Yuuki_Data() - self.i18n = Yuuki_LangSetting(Lang) + self.i18n = Yuuki_LangSetting(self.YuukiConfigs["Default_Language"]) self.LINE_Media_server = "https://obs.line-apps.com" @@ -28,7 +42,7 @@ class Yuuki: (self.client, self.listen) = self.Connect.connect() self.connectHeader = Yuuki_Connection.connectHeader - for access in helper_LINE_ACCESS_KEYs: + for access in self.YuukiConfigs["helper_LINE_ACCESS_KEYs"]: self.Connect.helperConnect(access) self.MyMID = self.client.getProfile().mid @@ -179,13 +193,14 @@ class Yuuki: GroupMember = [Catched.mid for Catched in GroupInfo.members] if GroupInfo.members: self.client.acceptGroupInvitation(self.Seq, GroupID) - if len(GroupMember) >= 100: + if len(GroupMember) >= self.YuukiConfigs["GroupMebers_Demand"]: self.data.updateLog("JoinGroup", (self.data.getTime(), GroupInfo.name, GroupID, Inviter)) self.sendText(GroupID, _("Helllo^^\nMy name is Yuuki ><\nNice to meet you OwO")) self.sendText(GroupID, _("Admin of the Group:\n%s") % (self.sybGetGroupCreator(GroupInfo).displayName,)) else: - self.sendText(GroupID, _("Sorry...\nThe number of members is not satisfied (100 needed)")) + self.sendText(GroupID, _("Sorry...\nThe number of members is not satisfied (%s needed)") % + (self.YuukiConfigs["GroupMebers_Demand"],)) self.client.leaveGroup(self.Seq, GroupID) def Commands(self, ncMessage): diff --git a/main.py b/main.py index 35b5a32..7571a96 100644 --- a/main.py +++ b/main.py @@ -14,6 +14,7 @@ Admin = [""] Language = "en" LINE_ACCESS_KEY = "" +GroupMebers_Demand = 100 helper_LINE_ACCESS_KEYs = [] ########################Initializing########################## @@ -33,8 +34,17 @@ Connection.connectHeader = { 'User-Agent': '' } -Seq = 0 -Console = Yuuki(Seq, Connection, helper_LINE_ACCESS_KEYs, Language, Admin) +Settings = Yuuki_Settings() + +Settings.config = { + "Seq": 0, + "Admin": Admin, + "Default_Language": Language, + "GroupMebers_Demand": GroupMebers_Demand, + "helper_LINE_ACCESS_KEYs": helper_LINE_ACCESS_KEYs +} + +Console = Yuuki(Settings, Connection) Console.cleanMyGroupInvitations() ###########################Start!#############################