Closed blueset closed 4 years ago
Seems like file of EFBMsg objects cannot be overridden due to the @property attribute of it.
file
EFBMsg
@property
(Not sure if that should be considered as a bug.)
https://gist.github.com/catbaron0/e91e295b67901fe47aaeabc2e311c305
from typing import Optional from ehforwarderbot import EFBMiddleware, EFBMsg, coordinator from tempfile import NamedTemporaryFile class DebugMiddleware(EFBMiddleware): """ Debug middleware. A minimum working example """ middleware_id: str = "debug.DebugMiddleware" middleware_name: str = "Debug Middleware" __version__: str = '1.0.0' @staticmethod def sent_by_master(message: EFBMsg) -> bool: return message.deliver_to != coordinator.master def process_message(self, message: EFBMsg) -> Optional[EFBMsg]: """ Process a message with middleware Args: message (:obj:`.EFBMsg`): Message object to process Returns: Optional[:obj:`.EFBMsg`]: Processed message or None if discarded. """ if self.sent_by_master(message) and message.text.startswith('debug`'): print("\nStart Debuging...") print(f"message.file: {message.file}") print("message.file = NamedTemporaryFile()") message.file = NamedTemporaryFile() print(f"message.file: {message.file}") if message.target and message.target.file: message.file = message.target.file print("message.file = message.target.file") print(f"message.target.file: {message.target.file}") print(f"message.file: {message.file}") print("Debuging Finished\n") return message
Ref: Support group Dec. 2019, [2]
Seems like
file
ofEFBMsg
objects cannot be overridden due to the@property
attribute of it.(Not sure if that should be considered as a bug.)
Reproduction code
https://gist.github.com/catbaron0/e91e295b67901fe47aaeabc2e311c305
Ref: Support group Dec. 2019, [2]