use env for params

master
bakatrouble 1 year ago
parent d8d95881d8
commit 85f1e3d54e

1
.gitignore vendored

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

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

@ -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)

Loading…
Cancel
Save