Giter Club home page Giter Club logo

efb-patch-middleware's Introduction

EH Forwarder Bot

Python >= 3.6

GitHub Discussions

Telegram

Documentation

Tests status

PyPI release

Downloads per month

Codacy grade

Translate this project

Banner

Codename EH Forwarder Bot (EFB) is an extensible message tunneling chat bot framework which delivers messages to and from multiple platforms and remotely control your accounts.

Read the Documentation. For tips, tricks and community contributed articles, see project wiki.

Getting Started

  1. Install the framework:

    pip3 install ehforwarderbot
  2. Install modules from the module repository.
  3. Enable and set up modules:

    efb-wizard
  4. Launch EFB:

    ehforwarderbot

Feel like contributing?

Everyone is welcomed to raise an issue or submit a pull request, just remember to read through and follow the contribution guideline before you do so.

License

EFB framework is licensed under GNU Affero General Public License 3.0 or later versions:

EH Forwarder Bot: An extensible message tunneling chat bot framework.
Copyright (C) 2016 - 2020 Eana Hufwe, and the EH Forwarder Bot contributors
All rights reserved.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

Translation support

EFB supports translated user interface prompts, by setting the locale environmental variable (LANGUAGE, LC_ALL, LC_MESSAGES or LANG) to one of our supported languages. Our documentation is also available in different languages. You can help to translate this project into your languages on our Crowdin page.

efb-patch-middleware's People

Contributors

wolfsilver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

efb-patch-middleware's Issues

建议在 Patch 之前检查需要被覆盖的函数是否与上次手工检查时一致

建议在 Patch 之前检查需要被覆盖的函数是否与上次手工检查时一致,以避免上游代码更新时覆盖的代码没有同步更新所导致的未预知的 bug。

判断方法示例

import binascii
import functools
import inspect
from types import ModuleType
from typing import Callable, Type, Union


def patch_check(f: Callable, crc32: int, patch_base: Union[ModuleType, Type], patch_attr: str):
    """检查并覆盖指定的函数。
    
    参数:
        f:需要覆盖的新函数(已提供)
        crc32:原函数源码的 CRC32 值(已提供)
        patch_base:需要被覆盖的函数所在类或模块
        patch_attr:需要被覆盖的函数名称
    
    抛出:
        ValueError:当 CRC32 值不匹配时抛出。
    """
    patch_source = getattr(patch_base, patch_attr)
    base_crc32 = binascii.crc32(inspect.getsource(patch_source).encode())
    if base_crc32 != crc32:
        raise ValueError(f"CRC32 值不匹配,指定的值为 {crc32},实际值为 {base_crc32}。")
    setattr(patch_base, patch_attr, f)


def patch(crc32: int):
    """用于标记覆盖函数的装饰器。

    参数:
        crc32:原函数源码的 CRC32 值
    """
    def wrapper(f: Callable):
        f.crc32 = crc32
        f.patch = functools.partial(patch_check, f, crc32)
        return f
    return wrapper


class Foo:
    def bar(self):
        print("bar")


@patch(3753216895)
def patched_bar(self):
    print("patched bar")


@patch(0)
def patched_bar_fails(self):
    print("patched bar (failed)")


# 原始 Foo.bar
Foo().bar()  # bar


# 覆盖 Foo.bar(成功例)
patched_bar.patch(Foo, "bar")
Foo().bar()  # patched bar


# 覆盖 Foo.bar(失败例)
patched_bar_fails.patch(Foo, "bar")  # 抛出 ValueError

Setting custom attributes such as 'check_update' on objects such as 'MessageHandler' of the PTB **library is deprecated.**

image

有个警告,不知道以后会不会有影响,日志:

Initializing middleware patch.PatchMiddleware...
May 27 09:34:09 oracle-centos-2 ehforwarderbot[30884]: /usr/local/lib/python3.6/site-packages/efb_patch_middleware/init.py:368: TelegramDeprecationWarning: Setting custom attributes such as 'check_update' on objects such as 'MessageHandler' of the PTB library is deprecated.
May 27 09:34:09 oracle-centos-2 ehforwarderbot[30884]: self.handler.check_update = self.check_update
May 27 09:34:09 oracle-centos-2 ehforwarderbot[30884]: 2022-05-27 09:34:09,113 [Level 99]: ehforwarderbot.main (main.init; main.py:167)

CRC32值不匹配

When I use the github version of ETM. The log shows
/usr/lib/python3.9/site-packages/efb_patch_middleware/__init__.py:366: TelegramDeprecationWarning: Setting custom attributes such as 'check_update' on objects such as 'MessageHandler' of the PTB library is deprecated. self.handler.check_update = self.check_update 2021-08-16 23:07:30,103 [Level 99]: plugins.patch.PatchMiddleware (__init__.__init__; __init__.py:288) patch result: [['process_telegram_message CRC32值不匹配,指定的值为 877899915 ,实际值为 2987607773 。']]

Strikethrough_recall_msg stopping working

Has strikethrough_recall_msg: True in config. Worked before 64b83ec (excluding). Stopped working after updating to v2.0.8 (464396c).

Env

Patch Version: 2.0.8
EFB Master Version: 2.1.0
EFB WeChat Slave Version: 2.0.1

Reproduce

From WeChat client, send a message to your WeChat account managed by EFB, then recall the message from the WeChat client.

Expected behavior:

On Telegram client, the said message should be edited with original text stroke out.

Actual behavior:

On Telegram client, a new message replying to/quoting the said message is received, saying "Message is removed in remote chat." (This is the behavior of the vanilla EFB)


Blindly guessing here, but possibly wrong/outdated crc32 code when patching send_status?

[bug] Middleware[PatchMiddleware 2.0.19] Matching check failed, please check the version.

I am working with the latest version of ETM & EWS, but there is an issue to initialize this middleware.

Warning through ETM:

中间件[PatchMiddleware 2.0.19]匹配校验失败,请核查版本

EFB log:

patch result: [['process_telegram_message CRC32值不匹配,指定的值为 2987607773 ,实际值为 877899915 。']]

I follow the config guidance and make sure no omission.

[FR] 自动已读功能增加延迟

问题描述:
Web端消息更新速度通常会比其它终端更快,而自动已读默认速度过快,当消息更新到APP端时已经被标记为已读,导致通知不可靠。

功能改进:
自动已读功能增加自定义延迟时间(秒)的可选项,缺省为0s(立刻),以增加APP端消息更新的包容性。

rm` function can be remove

efb has already support remove message from WeChat so maybe just like "update_info", the "rm`" part could be remove as well

TGS converting behaves incorrect

Description

If patch-middleware is enabled, GIF converted from TGS will lose its alpha channel and get a weirdly slow frame rate.

Screenshot

FYI, the sticker could be found in Capoo_Dynamic3

EFB info

Account A (w/ patch-middleware):

This is EFB Telegram Master Channel 2.2.5.dev1, running on profile “****”, default instance, on EFB 2.1.1.
1 slave channel activated:
- 💬 WeChat Slave (blueset.wechat, 2.0.5)

2 middlewares activated:
- Patch Middleware (patch.PatchMiddleware, 2.0.21)
- MP InstantView Middleware (catbaron.mp_instantview, 0.3.2)

Account B (w/o patch-middleware):

This is EFB Telegram Master Channel 2.2.5.dev1, running on profile “****”, default instance, on EFB 2.1.1.
1 slave channel activated:
- 💬 WeChat Slave (blueset.wechat, 2.0.5)

1 middleware activated:
- MP InstantView Middleware (catbaron.mp_instantview, 0.3.2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.