use env for params

This commit is contained in:
bakatrouble 2023-03-22 19:10:44 +03:00
parent d8d95881d8
commit 85f1e3d54e
3 changed files with 11 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.idea
*.py[oc]
.env

2
example.env Normal file
View File

@ -0,0 +1,2 @@
BOT_TOKEN=450146961:asd
SEND_CHAT=9893249151

12
main.py
View File

@ -1,18 +1,22 @@
import asyncio
import logging
import os
import redis.asyncio as aioredis
import logging
from aiogram import Bot, Dispatcher
from aiogram.types import Message
from aiogram.utils import executor
import dotenv
from e621 import E621
dotenv.load_dotenv('.env')
redis = aioredis.from_url('redis://localhost')
e621 = E621()
logging.basicConfig(level=logging.INFO)
bot = Bot(token='450146961:AAFqwPcXuWXaYP8j8sE_rYgp_dAsk9YWf7I')
bot = Bot(token=os.environ['BOT_TOKEN'])
dp = Dispatcher(bot)
@ -34,14 +38,14 @@ async def check_updates():
f'Character: {" ".join(post.tags.character)}\n\n' \
f'https://e621.net/posts/{post.id}'
if post.file.ext == 'webm':
await bot.send_video(98934915,
await bot.send_video(int(os.environ['SEND_CHAT']),
post.file.url,
width=post.file.width,
height=post.file.height,
thumb=post.preview.url,
caption=caption)
else:
await bot.send_photo(98934915,
await bot.send_photo(int(os.environ['SEND_CHAT']),
post.file.url,
caption=caption)
await redis.sadd('e621:sent', post.id)