1

Basically I was doing a small bot for telegram to send pictures from a subreddit, but it gives me an error which I don't know how to fix. Everything where it says (not shown) is something I can't show due to it being something with which anyone could use it under something I created, but I guess you don't really need it.

client_session: <aiohttp.client.ClientSession object at 0x000001555709DD90>```

config.py:
```settings = {
    "CLIENT_ID": "(not shown)",
    "SECRET_CODE":"(not shown)",
    "TOKEN":"(not shown)"
} ```



telegram_bot.py:
```import asyncio
import aiohttp
import config
import asyncpraw
from aiogram import Bot, types

API_TOKEN = config.settings["TOKEN"]
CHANNEL_ID = -1001374273592

bot = Bot(token=API_TOKEN, parse_mode=types.ParseMode.HTML)

reddit = asyncpraw.Reddit(client_id=config.settings["CLIENT_ID"],
                          client_secret=config.settings["SECRET_CODE"],
                          user_agent="random_raddit_bot/0.0.1")

mems = []
TIMEOUT = 5
SUBREDDIT_NAME = "memes"
POST_LIMIT = 1

async def send_message(channel_id: int, txt: str):
    await bot.send_message(channel_id, text)

async def main():
  while True:
    await asyncio.sleep(TIMEOUT)
    memes_submissions = await reddit.subreddit(SUBREDDIT_NAME)
    memes_submissions = memes_submissions.new(limit=POST_LIMIT)
    item = await memes_submissions.__anext__()
    if item.titles not in mems:
        mems.append(item.title)
        await send_message(CHANNEL_ID, item.url)


asyncio.get_event_loop().run_until_complete```

0 Answers0