Skip to content

Commit a166b4f

Browse files
committed
Merge branch 'dev'
* dev: Documentation update. Clear cache EWS: Change first chat to File helper ETM: Update chat assoc logic. Fixed typo Added chat linking indicator. ETM: Group unlink msg bug fix. ETM: bug fix More more debug msg More debug msg Added traceback logging for ETM: process_msg EWS: Reversing UID Priority order. EWS: Update priority of UID detection no message Fixed a typo Added log filtering Add detailed logging, and async msg processing for ETM. Try to count for queue time consumption. EWS: WeChat disconnection system notice.
2 parents 7eceb50 + 8be1313 commit a166b4f

26 files changed

+382
-386
lines changed

.gitignore

+1-22
Original file line numberDiff line numberDiff line change
@@ -94,28 +94,7 @@ ENV/
9494

9595
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
9696
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
97-
98-
# User-specific stuff:
99-
.idea/workspace.xml
100-
.idea/tasks.xml
101-
.idea/dictionaries
102-
.idea/vcs.xml
103-
.idea/jsLibraryMappings.xml
104-
105-
# Sensitive or high-churn files:
106-
.idea/dataSources.ids
107-
.idea/dataSources.xml
108-
.idea/dataSources.local.xml
109-
.idea/sqlDataSources.xml
110-
.idea/dynamic.xml
111-
.idea/uiDesigner.xml
112-
113-
# Gradle:
114-
.idea/gradle.xml
115-
.idea/libraries
116-
117-
# Mongo Explorer plugin:
118-
.idea/mongoSettings.xml
97+
.idea
11998

12099
## File-based project format:
121100
*.iws

.idea/.name

-1
This file was deleted.

.idea/ehForwarderBot.iml

-14
This file was deleted.

.idea/encodings.xml

-6
This file was deleted.

.idea/inspectionProfiles/Project_Default.xml

-22
This file was deleted.

.idea/inspectionProfiles/profiles_settings.xml

-7
This file was deleted.

.idea/misc.xml

-14
This file was deleted.

.idea/modules.xml

-8
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# EH Forwarder Bot
22

3-
![Python 3.x](https://img.shields.io/badge/Python-3.x-blue.svg)
3+
![Python ≥ 3.5](https://img.shields.io/badge/Python-≥_3.5-blue.svg)
44
[![Gitter](https://img.shields.io/gitter/room/blueset/ehForwarderBot.svg)](https://gitter.im/blueset/ehForwarderBot)
55
[![Telegram support group](https://img.shields.io/badge/Chat-on%20Telegram-blue.svg)](https://telegram.me/efbsupport)
66
[![license](https://img.shields.io/github/license/blueset/ehforwarderbot.svg)](LICENSE)

channel.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class MsgType:
1616
class MsgSource:
1717
User = "User"
1818
Group = "Group"
19+
System = "System"
1920

2021

2122
class TargetType:

docs/CONTRIBUTING.md

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Include details about your configuration and environment:
3232
* **What's the name and version of the OS you're using?**
3333
* **Which channel caused the problem?** Or did the framework cause it?
3434

35+
!!! attention
36+
When submitting your log, please remember to hide your private information.
37+
3538
## Suggesting enhancements
3639

3740
If you have any suggestions, feel free to raise it up in the issue list. Please try to provide as much details as you can, that includes:

docs/ETM.md

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# EFB Telegram Master
2-
32
EFB Telegram Master (ETM) is a master channel for EFB based on [`python-telegram-bot`](https://python-telegram-bot.org/) and [Telegram Official Bot API](https://core.telegram.org/bots/api).
43

54
## Specs
@@ -18,8 +17,8 @@ pydub
1817
moviepy
1918
peewee
2019
```
21-
> **Note**
22-
> Please refer to [Pillow documentation](https://pillow.readthedocs.io/en/3.0.x/installation.html) for details on installing Pillow.
20+
!!! note
21+
Please refer to [Pillow documentation](https://pillow.readthedocs.io/en/3.0.x/installation.html) for details on installing Pillow.
2322

2423
#### Non-python dependencies
2524
```
@@ -29,9 +28,11 @@ ffmpeg
2928
and all other required by Pillow.
3029

3130
### Configuration
31+
* Create a bot with [@BotFather](https://telegram.me/botfather). [Related tutorial](https://core.telegram.org/bots#6-botfather).
32+
* Set `/setjoingroups` to `Enable`, `/setprivacy` to `Disable`.
3233
* Copy `eh_telegram_master` to "plugins" directory,
3334
_May not be necessary as it's a built-in plugin of EFB_
34-
* Set `master = "plugins.eh_telegram_master", "TelegramChannel"` in `config.py`
35+
* Set `master_channel = "plugins.eh_telegram_master", "TelegramChannel"` in `config.py`
3536
* Give read and write access to `eh_telegram_master` directory
3637
* Add variable `eh_telegram_master` as follows
3738

@@ -48,7 +49,7 @@ eh_telegram_master = {
4849
}
4950
```
5051

51-
* `token`: (string) Telegram Bot token issued by [@BotFather](https://telegram.me/botfather). [Related tutorial](https://core.telegram.org/bots#6-botfather).
52+
* `token`: (string) Telegram Bot token issued by BotFather.
5253
* `admins`: (list of int) User IDs of admin.
5354
**Only** messages from admins will be processed. All other messages will be discarded.
5455
There are several ways obtaining your ID: Send a message to [@JackBot](https://telegram.me/jackbot), [@get_id_bot](https://telegram.me/get_id_bot), [@UserInfoBot](https://telegram.me/userinfobot), or check it with [Plus messenger](http://plusmessenger.org/).
@@ -73,8 +74,8 @@ No extra action required during start up.
7374
## Usage
7475
At the beginning, messages from all senders will be sent to the user directly, that means every message will be mixed in the same conversation. By linking a chat, you can redirect messages from a specific sender to an empty group for a more organized conversation.
7576

76-
> **Notice**:
77-
In case of multiple admins are assigned, they may all send message on your behalf, but only the 0th admin can receive direct message from the bot.
77+
!!! note "Notice"
78+
In case of multiple admins are assigned, they may all send message on your behalf, but only the 0th admin can receive direct message from the bot.
7879

7980
### Link a chat
8081
1. Create a new group, invite your bot to the group
@@ -83,10 +84,11 @@ In case of multiple admins are assigned, they may all send message on your behal
8384
_You can also choose to unlink or relink a linked chat from this menu._
8485
4. Tap "Start" at the bottom of your screen, and you should see a success message: "Chat associated."
8586

86-
> **Notice**:
87-
You may introduce other non-ETM admins to the group, however, they:
88-
> * Can read all messages send from the related remote chat;
89-
> * May NOT send message on your behalf.
87+
!!! note "Notice"
88+
You may introduce other non-ETM admins to the group, however, they:
89+
90+
* Can read all messages send from the related remote chat;
91+
* May NOT send message on your behalf.
9092

9193
### Send a message
9294
#### Send to a linked chat
@@ -107,8 +109,8 @@ To send a message to a non-linked chat, you should "direct reply" to a message o
107109

108110
In a non-linked chat, direct reply will not be delivered to the remote channel, everything else is supported as it does in a linked chat.
109111

110-
> **Tip**
111-
When direct replying to voice messages, always reply to the message preceding to it, or the message with the name of sender. Do not reply to the message itself.
112+
!!! tip
113+
When direct replying to voice messages, always reply to the message preceding to it, or the message with the name of sender. Do not reply to the message itself.
112114

113115
#### Chat head
114116
If you want to send a message to a non-linked chat which has not yet sent you a message, you can ask ETM to generate a "chat head". Chat head works similarly to an incoming message, you can reply to it to send messages to your recipient.
@@ -159,3 +161,6 @@ ko-KR | - | Korean
159161
nb-NO | - | Norwegian
160162
it-IT | - | Italian
161163
sv-SE | - | Swedish
164+
165+
## Known issues
166+
* In rare cases, some messages may take 20 to 35 minutes to be delivered to user. (Upstream library [python-telegram-bot#364](https://github.com/python-telegram-bot/python-telegram-bot/issues/364))

docs/EWS.md

+13-7
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ pymagic
1616
pillow
1717
xmltodict
1818
```
19-
> **Note**
20-
> Please refer to [Pillow documentation](https://pillow.readthedocs.io/en/3.0.x/installation.html) for details on installing Pillow.
19+
!!! note
20+
Please refer to [Pillow documentation](https://pillow.readthedocs.io/en/3.0.x/installation.html) for details on installing Pillow.
2121

2222
#### Non-python dependencies
2323
```
@@ -28,7 +28,7 @@ and all other required by Pillow.
2828
### Configuration
2929
* Copy `eh_wechat_slave.py` to "plugins" directory
3030
_May not be necessary as it's a built-in plugin of EFB_
31-
* Append `("plugins.we_wechat_slave", "WeChatChannel")` to `slaves` dict in `config.py`
31+
* Append `("plugins.we_wechat_slave", "WeChatChannel")` to `slave_chanels` dict in `config.py`
3232
* No other configuration is required
3333

3434
### Start up
@@ -61,7 +61,13 @@ and all other required by Pillow.
6161
Please remove the `itchat.pkl` file in the EFB root directory, and restart EFB for QR code scanning.
6262
* **Can I log in 2 WeChat accounts concurrently?**
6363
No. The feature is not yet available to EWS.
64-
* **I want to report a bug.**
65-
**I have some suggestions.**
66-
**Can I submit a pull request?**
67-
All bug reports, suggestions and pull requests are welcomed. Please read through and understand the [Contribution guideline](CONTRIBUTING.md) before submitting.
64+
65+
## Known issues
66+
* Random disconnection may occur occasionally due to the limit of protocol.
67+
* Chat linking may be unstable sometime due to the limit of API.
68+
69+
!!! note "Technical detail"
70+
WeChat does not provide a stable chat identifier, so hash of the name of a user is used for the chat identifier. This may cause 2 issues:
71+
72+
* Chat is no longer traceable when its name is changed.
73+
* Conflict and mis-delivery may happen when 2 users share the same name.

docs/channel.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# `EFBChannel`
22

3-
`EFBChannel` is a base class for EFB channels. All channel classes, master and slave, should extend this class. It can be defined in either a single file or a module folder with `__init__.py`.
3+
`EFBChannel` is the base class for EFB channels. All channel classes, master and slave, should extend this class. It can be defined in either a single file or a module folder with `__init__.py`.
44

55
## Attributes
66
**channel_name** (str)
@@ -34,6 +34,7 @@ Methods below are required to be implemented for respective channel types noted,
3434
Initialize the channel and log in the account (if necessary) with in this method. `super().__init__(queue)` must always be called in the beginning.
3535

3636
Args:
37+
3738
* `queue` (queue.Queue): Global message queue, used for message delivery from slave channels to the master channel.
3839
* `slaves` (dict): All enabled slave channel objects. Format: `"channel_id": channel_object`.
3940

@@ -49,9 +50,11 @@ Returns a `dict` of all extra functions of the slave channel, in the format of `
4950
This method sends messages from master channel to slave channel. All related media files should be cleared when the message is sent.
5051

5152
Args:
53+
5254
* msg (EFBMsg): The message object.
5355

5456
Raises:
57+
5558
* `EFBChatNotFound`
5659
* `EFBMessageNotFound`
5760
* `EFBMessageTypeNotSupported`

docs/getting-started.md

+32-34
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,36 @@ The variable `slave_channels` is a list of tuples of 2 strings where each of the
2121

2222
A sample of config file is available at `config.sample.py`.
2323

24-
> **Example**
25-
>
26-
> When enabling the following channels:
27-
> * Master channel
28-
> * DemoMaster
29-
> Import path: `plugins.eh_demo_master`
30-
> Class name: `DemoMasterChannel`
31-
> * Slave channels
32-
> * DemoSlave
33-
> Import path: `plugins.eh_demo_slave`
34-
> Class name: `DemoSlaveChannel`
35-
> * RandomSlave
36-
> Import path: `plugins.eh_random_slave`
37-
> Class name: `RandomSlaveChannel`
38-
> * MyChatSlave
39-
> Import path: `plugins.eh_mychat_slave`
40-
> Class name: `MyChatSlaveChannel`
41-
>
42-
> You should have the `master_channel` and `slave_channels` variable defined as follow:
43-
>
44-
> ```python
45-
> master_channel = "plugins.eh_demo_master", "DemoMasterChannel"
46-
> slave_channels = [
47-
> ("plugins.eh_demo_slave", "DemoSlaveChannel"),
48-
> ("plugins.eh_random_slave", "RandomSlaveChannel"),
49-
> ("plugins.eh_mychat_slave", "MyChatSlaveChannel")
50-
> ]
51-
> ```
52-
53-
> **Technical details**
54-
The "import path" and "class name" of the module is actually used to import the channel class at root level.
55-
It can be understood as `from <import_path> import <class_name>`.
24+
!!! note "Example"
25+
When enabling the following channels:
26+
27+
* Master channel
28+
* DemoMaster
29+
Import path: `plugins.eh_demo_master`
30+
Class name: `DemoMasterChannel`
31+
* Slave channels
32+
* DemoSlave
33+
Import path: `plugins.eh_demo_slave`
34+
Class name: `DemoSlaveChannel`
35+
* RandomSlave
36+
Import path: `plugins.eh_random_slave`
37+
Class name: `RandomSlaveChannel`
38+
* MyChatSlave
39+
Import path: `plugins.eh_mychat_slave`
40+
Class name: `MyChatSlaveChannel`
41+
42+
You should have the `master_channel` and `slave_channels` variable defined as follow:
43+
44+
master_channel = "plugins.eh_demo_master", "DemoMasterChannel"
45+
slave_channels = [
46+
("plugins.eh_demo_slave", "DemoSlaveChannel"),
47+
("plugins.eh_random_slave", "RandomSlaveChannel"),
48+
("plugins.eh_mychat_slave", "MyChatSlaveChannel")
49+
]
50+
51+
!!! tip "Technical details"
52+
The "import path" and "class name" of the module is actually used to import the channel class at root level.
53+
It can be understood as `from <import_path> import <class_name>`.
5654

5755
## Permissions
5856
`storage` directory should be given read and write access for media processing.
@@ -65,8 +63,8 @@ For more details about how to configure your channel, please consult the respect
6563
## Get it up and running
6664
Most of the time, you can just run `python3 main.py -d start` and it should be ready to go.
6765

68-
> **Run it as a normal process**
69-
> Besides, you can still use the classic `python3 main.py` to launch EFB. If you want to keep it running in the background when accessing the machine via SSH, you can use tools like `screen` to prevent it from being terminated during disconnection.
66+
!!! tip "Run it as a normal process"
67+
Besides, you can still use the classic `python3 main.py` to launch EFB. If you want to keep it running in the background when accessing the machine via SSH, you can use tools like `screen` to prevent it from being terminated during disconnection.
7068

7169
However, some channels may require one-time credentials (e.g. Dynamic QR code scanning for WeChat Web Protocol). When you run the module, you may be required to take some actions before the bot goes online.
7270

docs/index.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# EH Forwarder Bot
22

3-
![Python 3.x](https://img.shields.io/badge/Python-3.x-blue.svg)
4-
[![Gitter](https://img.shields.io/gitter/room/blueset/ehForwarderBot.svg)](https://gitter.im/blueset/ehForwarderBot)
3+
![Python ≥ 3.5](https://img.shields.io/badge/Python-≥_3.5-blue.svg) [![Gitter](https://img.shields.io/gitter/room/blueset/ehForwarderBot.svg)](https://gitter.im/blueset/ehForwarderBot)
54
[![Telegram support group](https://img.shields.io/badge/Chat-on%20Telegram-blue.svg)](https://telegram.me/efbsupport)
65
[![license](https://img.shields.io/github/license/blueset/ehforwarderbot.svg)](LICENSE)
76

0 commit comments

Comments
 (0)