Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[BUG] Persistence of Bots #1992

Closed
💡 feature
@Bibo-Joshi

Description

@Bibo-Joshi

Steps to reproduce

  1. Add an object with a bot attribute to e.g.chat_data and persist it

  2. Change the bots token and restart the updater

Expected behaviour

The reloaded bot should have the new token.

Actual behaviour

The bot in the loadedchat_data still has the old token. Similar for the other bot attributes

Proposed solution

  1. Remove__reduce__ fromBot , as we don't want to encourage pickling bots

  2. Add static methodsreplace_bots(object) andset_bots(objects, bot) (or other naming) toBasePersistence, wherereplace_bots implements the logic to replace everyBot instance in an object, be it a dict, a list, a custom object … with some special placeholderBOT_INSTANCE or whatever andset_bots in turn replacesBOT_INSTANCE with the given bot. To makeget_*_data andupdate_*_data use those, we have several options:

    1. Just call them inget/update_. Custom subclasses ofBasePersistence will have to adjust.
    2. Add a__new__ method to make theget/update_ methods call the methods under the hood. that way custom subclasses don't need to change anything
    3. Add methodsget/update_*_replace_bot, which callset/replace_bots and before/afterget/update_*. Use those inUpdater. This way, custom classes also don't need to be changed.

    don't know, whats better …

  3. Alternatively to passing the bot toset_bots, we could addset_bot toBasePersistence so that we can useself.bot inset_bot. That would save us from having to passbot toget_* as well

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp