Skip to content

Commit

Permalink
formatted with black
Browse files Browse the repository at this point in the history
  • Loading branch information
yurnov committed Mar 26, 2024
1 parent 3de1f80 commit 31bb99b
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
"""

logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
)
logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO)
logger = logging.getLogger(__name__)

load_dotenv()
Expand Down Expand Up @@ -81,9 +79,7 @@
MESSAGE = "💥За даними ЗМІ, зафіксовані вибухи у "

if not TOKEN or not CHAT_ID:
logger.error(
"TOKEN or CHAT_ID is not defined in .env file or environment variables"
)
logger.error("TOKEN or CHAT_ID is not defined in .env file or environment variables")
exit()

if not URL:
Expand All @@ -94,9 +90,7 @@


if not REGION_LIST:
logger.warning(
"REGION_LIST is not defined in .env file, using a default list of regions"
)
logger.warning("REGION_LIST is not defined in .env file, using a default list of regions")
# List of regions that bot will send message if date is changed
REGION_LIST = [
"Сумська область",
Expand All @@ -115,9 +109,7 @@
REGION_LIST = [region.strip('"') for region in REGION_LIST]

if not TIMEZONE:
logger.warning(
"TIMEZONE is not defined in .env file, using a default timezone Europe/Kiev"
)
logger.warning("TIMEZONE is not defined in .env file, using a default timezone Europe/Kiev")
TIMEZONE = "Europe/Kiev"

logger.info(f"Bot started with CHAT_ID: {CHAT_ID}")
Expand All @@ -135,9 +127,7 @@ def get_data():


def send_message(text):
url = (
f"https://api.telegram.org/bot{TOKEN}/sendMessage?chat_id={CHAT_ID}&text={text}"
)
url = f"https://api.telegram.org/bot{TOKEN}/sendMessage?chat_id={CHAT_ID}&text={text}"
try:
response = requests.get(url)
response.raise_for_status()
Expand Down Expand Up @@ -167,9 +157,7 @@ def main():
message = MESSAGE

for region, date in states.items():
if region in REGION_LIST and date != last_data["states"].get(
region
):
if region in REGION_LIST and date != last_data["states"].get(region):
logger.info(f"Explosion in region: {region}, date: {date}")

message += f"{regions_gram_case.get(region, region)} о {datetime\
Expand Down

0 comments on commit 31bb99b

Please sign in to comment.