use env for params
This commit is contained in:
parent
d8d95881d8
commit
85f1e3d54e
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
.idea
|
.idea
|
||||||
*.py[oc]
|
*.py[oc]
|
||||||
|
.env
|
||||||
|
2
example.env
Normal file
2
example.env
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
BOT_TOKEN=450146961:asd
|
||||||
|
SEND_CHAT=9893249151
|
12
main.py
12
main.py
@ -1,18 +1,22 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
import redis.asyncio as aioredis
|
import redis.asyncio as aioredis
|
||||||
import logging
|
|
||||||
from aiogram import Bot, Dispatcher
|
from aiogram import Bot, Dispatcher
|
||||||
from aiogram.types import Message
|
from aiogram.types import Message
|
||||||
from aiogram.utils import executor
|
from aiogram.utils import executor
|
||||||
|
import dotenv
|
||||||
|
|
||||||
from e621 import E621
|
from e621 import E621
|
||||||
|
|
||||||
|
dotenv.load_dotenv('.env')
|
||||||
|
|
||||||
redis = aioredis.from_url('redis://localhost')
|
redis = aioredis.from_url('redis://localhost')
|
||||||
e621 = E621()
|
e621 = E621()
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
bot = Bot(token='450146961:AAFqwPcXuWXaYP8j8sE_rYgp_dAsk9YWf7I')
|
bot = Bot(token=os.environ['BOT_TOKEN'])
|
||||||
dp = Dispatcher(bot)
|
dp = Dispatcher(bot)
|
||||||
|
|
||||||
|
|
||||||
@ -34,14 +38,14 @@ async def check_updates():
|
|||||||
f'Character: {" ".join(post.tags.character)}\n\n' \
|
f'Character: {" ".join(post.tags.character)}\n\n' \
|
||||||
f'https://e621.net/posts/{post.id}'
|
f'https://e621.net/posts/{post.id}'
|
||||||
if post.file.ext == 'webm':
|
if post.file.ext == 'webm':
|
||||||
await bot.send_video(98934915,
|
await bot.send_video(int(os.environ['SEND_CHAT']),
|
||||||
post.file.url,
|
post.file.url,
|
||||||
width=post.file.width,
|
width=post.file.width,
|
||||||
height=post.file.height,
|
height=post.file.height,
|
||||||
thumb=post.preview.url,
|
thumb=post.preview.url,
|
||||||
caption=caption)
|
caption=caption)
|
||||||
else:
|
else:
|
||||||
await bot.send_photo(98934915,
|
await bot.send_photo(int(os.environ['SEND_CHAT']),
|
||||||
post.file.url,
|
post.file.url,
|
||||||
caption=caption)
|
caption=caption)
|
||||||
await redis.sadd('e621:sent', post.id)
|
await redis.sadd('e621:sent', post.id)
|
||||||
|
Loading…
Reference in New Issue
Block a user