Skip to content

Problem when using the modify_job method. #7

@Mat0mba24

Description

@Mat0mba24

How do I create a scheduler object:

job_stores = {
            "default": RedisJobStore(
                jobs_key="dispatched_trips_jobs", run_times_key="dispatched_trips_running",
                host=config.redis.redis_host, port=config.redis.redis_port, password=config.redis.redis_pass
            )
        }
        
scheduler = ContextSchedulerDecorator(AsyncIOScheduler(jobstores=job_stores))
scheduler.ctx.add_instance(bot, declared_class=Bot)
scheduler.ctx.add_instance(scheduler, declared_class=AsyncIOScheduler)

How do I add a job:

scheduler.add_job(
            func=spam_message,
            trigger="interval",
            seconds=30,
            kwargs={
                "user_id": event.from_user.id,
                "message_text": text,
                "message_id": msg.message_id,
                "spam_count": spam_count
            },
            id=f"interval_spam_message:{event.from_user.id}"
        )

In the process of doing the job, I change its parameters:

async def spam_message(
        scheduler: AsyncIOScheduler,
        bot: Bot,
        user_id: int,
        message_text: str,
        message_id: int,
        spam_count: int
) -> None:
    ...
    scheduler.modify_job(
        f"interval_spam_message:{user_id}",
        kwargs={
            "user_id": user_id,
            "message_text": message_text,
            "message_id": msg.message_id,
            "spam_count": spam_count
        }
    )
    ...

But the following error occurs:

The following arguments have not been supplied: scheduler, bot

What should I do to make job_modify see bot and apscheduler objects, or what am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions