Skip to content

Commit 385f2a8

Browse files
committed
settings bug fix
1 parent 5120168 commit 385f2a8

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed
121 Bytes
Binary file not shown.

app/filters/owner.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
from aiogram import types
33
import os
44

5-
owner_id = int(os.getenv("OWNER_ID"))
5+
owner_id_str = os.getenv("OWNER_ID")
6+
if not owner_id_str:
7+
raise ValueError("OWNER_ID environment variable is not set")
8+
owner_id = int(owner_id_str)
69

710
class IsOwner(BaseFilter):
811
async def __call__(self, message: types.Message) -> bool:
9-
return message.from_user.id == owner_id
12+
return message.from_user.id == owner_id
28 Bytes
Binary file not shown.
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
import json
2+
import os
3+
4+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
5+
SETTINGS_PATH = os.path.join(BASE_DIR, "settings.json")
26

37
class Settings():
48
def __init__(self):
59
pass
610

711
def read_settings(self, val):
8-
with open('settings.json', 'r') as f:
12+
with open(SETTINGS_PATH, 'r') as f:
913
data = json.load(f)
1014
print(data[val])
1115

1216
def write_settings(self, item, val):
13-
with open('settings.json', 'r') as f:
17+
with open(SETTINGS_PATH, 'r') as f:
1418
data = json.load(f)
1519

1620
data[item] = val
1721

18-
with open('settings.json', 'w') as f:
22+
with open(SETTINGS_PATH, 'w') as f:
1923
json.dump(data, f, indent=4)
2024

app/settings/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"update_interval": 5,
2+
"update_interval": "5",
33
"timezone": "America/New_York",
44
"notification_time": "8:00"
55
}

requirements.txt

-1.03 KB
Binary file not shown.

0 commit comments

Comments
 (0)