summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-11-05 02:30:08 +0800
committerMistivia <i@mistivia.com>2025-11-05 02:30:08 +0800
commiteda49be9b8fdd8d9e9a5e3b32fc35ca636cd34b3 (patch)
tree0282ab136fbedccde92643c4ce73abfbca3c70d6 /main.py
parentb8ed7e512d8d226e35aaa1419ddd44e73b23bf4e (diff)
use config file
Diffstat (limited to 'main.py')
-rw-r--r--main.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/main.py b/main.py
index a117d8d..4341137 100644
--- a/main.py
+++ b/main.py
@@ -4,26 +4,28 @@ from airc import Client, Message
from aiogram import Bot, Dispatcher
from aiogram.filters import Command
from aiogram.types import Message
+import json
-SERVER = "raye.mistivia.com"
-PORT = 6697
-NICKNAME = "ezlivebot"
-CHANNELS = [
- "#xxxxxxxxx",
- "#xxxxxxxxx"
-]
+config = None
+with open('config.json', 'r') as fp:
+ config = json.load(fp)
-TGTOKEN = 'xxxxxxxxx:xxxxxxxx'
-TGCHAT = -0000000000000
-TGTHREAD = 000
+SERVER = config['server']
+PORT = config['port']
+NICKNAME = config['nickname']
+CHANNELS = config['channels']
+USE_SSL = config['use_ssl']
+TGTOKEN = config['tgtoken']
+TGCHAT = config['tgchat']
+TGTHREAD = config['tgthread']
# --- Instantiate the Client ---
irc_client = Client(
host=SERVER,
port=PORT,
nickname=NICKNAME,
- realname="My Awesome Async Bot",
- use_ssl=True
+ realname="bot",
+ use_ssl=USE_SSL
)
tgbot = Bot(token=TGTOKEN)
@@ -75,9 +77,9 @@ def get_sender(msg):
if msg.from_user is None:
return
user = msg.from_user
- if user.username is not None:
- return user.username
- if user.last_name is not None:
+ # if user.username is not None:
+ # return user.username
+ if user.last_name is None:
return user.first_name + ' ' + user.last_name
return user.first_name