2021-11-28 14:55:10 +00:00
|
|
|
from configparser import RawConfigParser
|
2023-08-17 14:16:53 +00:00
|
|
|
from typing import Union, List
|
2021-11-28 14:55:10 +00:00
|
|
|
from distutils.util import strtobool
|
|
|
|
|
2022-10-02 15:14:06 +00:00
|
|
|
# [pyrogram]
|
|
|
|
api_id: int = 0
|
|
|
|
api_hash: str = ""
|
2021-11-28 14:55:10 +00:00
|
|
|
# [Basic]
|
|
|
|
ipv6: Union[bool, str] = "False"
|
2022-10-05 15:15:35 +00:00
|
|
|
# [post]
|
|
|
|
admin: int = 0
|
|
|
|
lofter_channel: int = 0
|
2022-10-06 08:00:46 +00:00
|
|
|
lofter_channel_username: str = ""
|
2023-06-22 17:17:14 +00:00
|
|
|
splash_channel: int = 0
|
|
|
|
splash_channel_username: str = ""
|
2023-08-18 13:28:16 +00:00
|
|
|
bilifav_id: int = 0
|
|
|
|
bilifav_channel: int = 0
|
|
|
|
bilifav_channel_username: str = ""
|
2022-10-13 14:36:43 +00:00
|
|
|
# [api]
|
|
|
|
amap_key: str = ""
|
2023-08-17 14:16:53 +00:00
|
|
|
bili_auth_user_str: str = ""
|
2023-08-18 13:28:16 +00:00
|
|
|
bili_auth_chat_str: str = ""
|
2021-11-28 14:55:10 +00:00
|
|
|
config = RawConfigParser()
|
|
|
|
config.read("config.ini")
|
2022-10-02 15:14:06 +00:00
|
|
|
api_id = config.getint("pyrogram", "api_id", fallback=api_id)
|
|
|
|
api_hash = config.get("pyrogram", "api_hash", fallback=api_hash)
|
2021-11-28 14:55:10 +00:00
|
|
|
ipv6 = config.get("basic", "ipv6", fallback=ipv6)
|
2022-10-05 15:15:35 +00:00
|
|
|
admin = config.getint("post", "admin", fallback=admin)
|
|
|
|
lofter_channel = config.getint("post", "lofter_channel", fallback=lofter_channel)
|
2023-01-12 13:19:54 +00:00
|
|
|
lofter_channel_username = config.get(
|
|
|
|
"post", "lofter_channel_username", fallback=lofter_channel_username
|
|
|
|
)
|
2023-06-22 17:17:14 +00:00
|
|
|
splash_channel = config.getint("post", "splash_channel", fallback=splash_channel)
|
|
|
|
splash_channel_username = config.get(
|
|
|
|
"post", "splash_channel_username", fallback=splash_channel_username
|
|
|
|
)
|
2023-08-18 13:28:16 +00:00
|
|
|
bilifav_id = config.getint("post", "bilifav_id", fallback=bilifav_id)
|
|
|
|
bilifav_channel = config.getint("post", "bilifav_channel", fallback=bilifav_channel)
|
|
|
|
bilifav_channel_username = config.get(
|
|
|
|
"post", "bilifav_channel_username", fallback=bilifav_channel_username
|
|
|
|
)
|
2022-10-13 14:36:43 +00:00
|
|
|
amap_key = config.get("api", "amap_key", fallback=amap_key)
|
2023-08-17 14:16:53 +00:00
|
|
|
bili_auth_user_str = config.get("api", "bili_auth_user", fallback=bili_auth_user_str)
|
2023-08-18 13:28:16 +00:00
|
|
|
bili_auth_chat_str = config.get("api", "bili_auth_chat", fallback=bili_auth_chat_str)
|
2023-08-17 14:16:53 +00:00
|
|
|
try:
|
|
|
|
bili_auth_user: List[int] = list(map(int, bili_auth_user_str.split(",")))
|
2023-08-18 13:28:16 +00:00
|
|
|
bili_auth_chat: List[int] = list(map(int, bili_auth_chat_str.split(",")))
|
2023-08-17 14:16:53 +00:00
|
|
|
except ValueError:
|
|
|
|
bili_auth_user: List[int] = []
|
2023-08-18 13:28:16 +00:00
|
|
|
bili_auth_chat: List[int] = []
|
2024-10-20 07:31:44 +00:00
|
|
|
# bsky
|
|
|
|
bsky_username = config.get("bsky", "username", fallback="")
|
|
|
|
bsky_password = config.get("bsky", "password", fallback="")
|
2024-10-29 16:05:59 +00:00
|
|
|
# predict
|
|
|
|
predict_url = config.get("predict", "url", fallback="")
|
|
|
|
predict_token = config.get("predict", "token", fallback="")
|
2021-11-28 14:55:10 +00:00
|
|
|
try:
|
2023-05-27 13:45:56 +00:00
|
|
|
ipv6 = bool(strtobool(ipv6))
|
2021-11-28 14:55:10 +00:00
|
|
|
except ValueError:
|
|
|
|
ipv6 = False
|
2023-08-05 05:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
def save_config():
|
|
|
|
config.write(open("config.ini", "w", encoding="utf-8"))
|