2023-05-02 16:46:15 +03:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from discord import Activity, ActivityType
|
|
|
|
|
2023-05-06 19:56:01 +03:00
|
|
|
from modules.client import client
|
|
|
|
from modules.scheduled import scheduler
|
|
|
|
from modules.utils import config_get
|
|
|
|
from modules.utils_sync import config_get_sync
|
2023-05-02 16:46:15 +03:00
|
|
|
|
|
|
|
logging.basicConfig(
|
|
|
|
level=logging.INFO,
|
|
|
|
format="%(name)s.%(funcName)s | %(levelname)s | %(message)s",
|
|
|
|
datefmt="[%X]",
|
|
|
|
)
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
try:
|
2023-05-04 17:14:33 +03:00
|
|
|
import uvloop # type: ignore
|
2023-05-02 16:46:15 +03:00
|
|
|
|
|
|
|
uvloop.install()
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@client.event
|
|
|
|
async def on_ready():
|
2024-06-23 13:05:03 +03:00
|
|
|
logger.info("Logged in as %s", client.user)
|
2023-05-06 20:06:04 +03:00
|
|
|
|
|
|
|
activity_type = await config_get("type", "status")
|
|
|
|
activity_message = await config_get("message", "status")
|
|
|
|
|
|
|
|
if activity_type == "playing":
|
|
|
|
await client.change_presence(
|
|
|
|
activity=Activity(type=ActivityType.playing, name=activity_message)
|
|
|
|
)
|
|
|
|
elif activity_type == "watching":
|
|
|
|
await client.change_presence(
|
|
|
|
activity=Activity(type=ActivityType.watching, name=activity_message)
|
|
|
|
)
|
|
|
|
elif activity_type == "listening":
|
|
|
|
await client.change_presence(
|
|
|
|
activity=Activity(type=ActivityType.listening, name=activity_message)
|
|
|
|
)
|
|
|
|
elif activity_type == "streaming":
|
|
|
|
await client.change_presence(
|
|
|
|
activity=Activity(type=ActivityType.streaming, name=activity_message)
|
|
|
|
)
|
|
|
|
elif activity_type == "competing":
|
|
|
|
await client.change_presence(
|
|
|
|
activity=Activity(type=ActivityType.competing, name=activity_message)
|
|
|
|
)
|
|
|
|
elif activity_type == "custom":
|
|
|
|
await client.change_presence(
|
|
|
|
activity=Activity(type=ActivityType.custom, name=activity_message)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
return
|
|
|
|
|
2024-06-23 13:05:03 +03:00
|
|
|
logger.info(
|
|
|
|
"Set activity type to %s with message %s", activity_type, activity_message
|
|
|
|
)
|
2023-05-04 17:14:33 +03:00
|
|
|
|
2023-05-02 16:46:15 +03:00
|
|
|
|
|
|
|
def main():
|
2024-06-23 13:05:03 +03:00
|
|
|
client.load_extension("cogs")
|
2023-05-04 17:09:47 +03:00
|
|
|
|
2023-05-02 16:46:15 +03:00
|
|
|
try:
|
|
|
|
scheduler.start()
|
2023-05-04 17:09:47 +03:00
|
|
|
client.run(config_get_sync("token"))
|
2023-05-02 16:46:15 +03:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
scheduler.shutdown()
|
|
|
|
exit()
|
|
|
|
|
2023-05-04 17:14:33 +03:00
|
|
|
|
2023-05-02 16:46:15 +03:00
|
|
|
if __name__ == "__main__":
|
2023-05-04 17:14:33 +03:00
|
|
|
main()
|