Skip to content

Commit 215f95d

Browse files
authored
v1.3.20170119
2 parents 6e93c4b + bad1dec commit 215f95d

16 files changed

+525
-175
lines changed

CONTRIBUTING.md

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ If you need help, or want to talk to the authors, feel free to chat with us at o
2020
* **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior.
2121
* **Explain which behavior you expected to see instead and why.**
2222
* **If the problem wasn't triggered by a specific action**, describe what you were doing before the problem happened and share more information using the guidelines below.
23+
* **Provide log related to the issue.** Use `python3 main.py -vv` to start the logging process, and submit the entire log from the first step you performed.
2324

2425
Provide more context by answering these questions:
2526

@@ -32,6 +33,9 @@ Include details about your configuration and environment:
3233
* **What's the name and version of the OS you're using?**
3334
* **Which channel caused the problem?** Or did the framework cause it?
3435

36+
!!! attention
37+
When submitting your log, please remember to hide your private information.
38+
3539
## Suggesting enhancements
3640

3741
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:

README.md

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

3-
![Python ≥ 3.5](https://img.shields.io/badge/Python-≥_3.5-blue.svg)
3+
![Python 3.x](https://img.shields.io/badge/Python-3.x-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)
6-
[![license](https://img.shields.io/github/license/blueset/ehforwarderbot.svg)](LICENSE)
6+
[![Docs: Stable version](https://readthedocs.org/projects/ehforwarderbot/badge/?version=latest)](https://ehforwarderbot.readthedocs.io/en/latest/)
7+
[![Docs: Development version version](https://readthedocs.org/projects/ehforwarderbot/badge/?version=dev)](https://ehforwarderbot.readthedocs.io/en/dev/)
8+
[![tag](https://img.shields.io/github/tag/blueset/ehforwarderbot.svg)](https://github.com/blueset/ehForwarderBot/releases)
79

810

911
![EFB](https://images.1a23.com/upload/images/SPET.png)
@@ -26,8 +28,9 @@ _Codename_ **EH Forwarder Bot** (EFB) is an extensible chat tunnel framework whi
2628
## Feel like contributing?
2729
Anyone is welcomed to raise an issue or submit a pull request, just remember to read through and understand the [contribution guideline](CONTRIBUTING.md) before you do so.
2830

29-
## Special thanks
30-
* @clairvoyantegg for documentation refine.
31+
## Related articles
32+
* [EFB How-to: Send and Receive Messages from WeChat on Telegram (zh-CN)](https://blog.1a23.com/2017/01/09/EFB-How-to-Send-and-Receive-Messages-from-WeChat-on-Telegram-zh-CN/)
33+
_(安装并使用 EFB:在 Telegram 收发微信消息)_
3134

3235
## License
3336
EFB framework is licensed under [GNU General Public License 3.0](https://www.gnu.org/licenses/gpl-3.0.txt).

channel.py

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class EFBChannel:
3838
channel_id = "emptyChannel"
3939
channel_type = ChannelType.Slave
4040
queue = None
41+
supported_message_types = set()
4142

4243
def __init__(self, queue):
4344
self.queue = queue

channelExceptions.py

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ class EFBMessageNotFound(Exception):
88

99
class EFBMessageTypeNotSupported(Exception):
1010
pass
11+
12+
13+
class EFBMessageError(Exception):
14+
pass

daemon.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from datetime import datetime
1818
from functools import partial
1919
import time
20-
import argparse
2120
import signal
2221
import fcntl
2322
import subprocess
@@ -27,9 +26,8 @@
2726
except ImportError:
2827
import pickle
2928

30-
if sys.version_info.major == 3:
31-
raw_input = input
32-
29+
if sys.version_info.major < 3:
30+
raise Exception("Python 3.x is required. Your version is %s." % sys.version)
3331

3432
user_home = os.path.expanduser('~')
3533
dm_home = os.path.join(user_home, '.dm')
@@ -220,7 +218,7 @@ def kill(self, name=None, group=None, quiet=False, sigkill=False):
220218
notify = 'Stopping EFB Daemon (%d)\n' % len(daemons)
221219
if quiet is False:
222220
notify += 'are you sure? [Y/n]'
223-
yn = raw_input(notify)
221+
yn = input(notify)
224222
else:
225223
yn = 'Y'
226224
print(notify)
@@ -245,7 +243,7 @@ def restart(self, name=None, group=None, cmd=None,
245243
notify = 'Restarting EFB daemon (%d)' % len(daemons)
246244
if quiet is False:
247245
notify += 'are you sure? [Y/n]'
248-
yn = raw_input(notify)
246+
yn = input(notify)
249247
else:
250248
yn = 'Y'
251249
print(notify)
@@ -277,7 +275,7 @@ def help():
277275
print("EFB Daemon Process\n"
278276
"Usage: %s {start|stop|restart|status|transcript|help} [args_to_EFB]\n\n" % sys.argv[0] +
279277
"EFB help:")
280-
subprocess.call(["python3", "main.py", "-h"])
278+
subprocess.call([sys.executable, "main.py", "-h"])
281279

282280

283281
def transcript(path, reset=False):
@@ -289,7 +287,7 @@ def transcript(path, reset=False):
289287
"Press ^C (Control+C on Mac, Ctrl+C otherwise) to hide."]
290288
w = int(max(len(i) for i in l))
291289
for i in l:
292-
print("\x1b[0;37;41m %s \x1b[0m" % i.ljust(w))
290+
print("\x1b[0;37;46m %s \x1b[0m" % i.ljust(w))
293291
print()
294292
try:
295293
subprocess.call(["tail", "-f", path])
@@ -307,7 +305,7 @@ def main():
307305
dm = DM()
308306
efb_args = " ".join(sys.argv[2:])
309307
if sys.argv[1] == "start":
310-
dm.run(cmdline=" ".join(("python3 main.py", efb_args)),
308+
dm.run(cmdline=" ".join((sys.executable + " main.py", efb_args)),
311309
name="EFB",
312310
logfile="EFB.log")
313311
transcript(transcript_path, True)
@@ -318,7 +316,7 @@ def main():
318316
elif sys.argv[1] == "restart":
319317
kwargs = {"name": "EFB", "quiet": True, "sigkill": True}
320318
if len(sys.argv) > 2:
321-
kwargs["cmd"] = " ".join(("python3 main.py", efb_args))
319+
kwargs["cmd"] = " ".join((sys.executable + " main.py", efb_args))
322320
dm.restart(**kwargs)
323321
transcript(transcript_path, True)
324322
elif sys.argv[1] == "transcript":

docs/CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ If you need help, or want to talk to the authors, feel free to chat with us at o
2020
* **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior.
2121
* **Explain which behavior you expected to see instead and why.**
2222
* **If the problem wasn't triggered by a specific action**, describe what you were doing before the problem happened and share more information using the guidelines below.
23+
* **Provide log related to the issue.** Use `python3 main.py -vv` to start the logging process, and submit the entire log from the first step you performed.
2324

2425
Provide more context by answering these questions:
2526

docs/ETM.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ In a nutshell, ETM offers the following commands, you can also send it to BotFat
7878

7979
```
8080
link - Link a remote chat to a group.
81+
unlink_all - Unlink all remote chats from a group.
8182
chat - Generate a chat head.
8283
recog - Recognize a speech by replying to it.
8384
extra - Access extra functionalities.
@@ -99,6 +100,8 @@ extra - Access extra functionalities.
99100
* Can read all messages send from the related remote chat;
100101
* May NOT send message on your behalf.
101102

103+
Also, you can send `/unlink_all` to a group to unlink all remote chats from it.
104+
102105
### Send a message
103106
#### Send to a linked chat
104107
You can send message as you do in a normal Telegram chat.
@@ -193,7 +196,8 @@ it-IT | - | Italian
193196
sv-SE | - | Swedish
194197

195198
## Known issues
196-
* 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))
199+
* 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), said to be fixed in version 6.)
200+
* Too often invitation of the bot to groups will trigger Telegram's anti-spam mechanism. If you see "Could not add user, please try again later", you really need to "try again later". No joking.
197201

198202
## Experimental flags
199203
The following flags are experimental features, may change, break, or disappear at any time. Use at your own risk.
@@ -209,10 +213,14 @@ eh_telegram_master = {
209213
}
210214
```
211215

212-
* `no_conversion` _(bool)_ [Default: False]
216+
* `no_conversion` _(bool)_ [Default: `False`]
213217
Disable audio conversion, send all audio file as is, and let Telegram to handle it.
214-
* `join_msg_threshold_secs` _(int)_ [Default: 15]
218+
* `join_msg_threshold_secs` _(int)_ [Default: `15`]
215219
Threshold in seconds for message joining. Messages sent from the same person from the same chat between the threshold time will be joined together.
216220
_Only works in linked chats._
217-
* `chats_per_page` _(int)_ [Default: 10]
221+
* `chats_per_page` _(int)_ [Default: `10`]
218222
Number of chats shown in when choosing for `/chat` and `/link` command. An overly large value may lead to malfunction of such commands.
223+
* `text_as_html` _(bool)_ [Default: `False`]
224+
Parse all text messages as Telegram HTML. Tags supported: `a`, `b`, `strong`, `i`, `em`, `code`, `pre`.
225+
* `multiple_slave_chats` _(bool)_ [Default: `False`]
226+
Link more than one remote chat to one Telegram group. Send and reply as you do with an unlinked chat.

docs/EWS.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# EFB WeChat Slave Channel
22

3-
EFB WeChat Slave Channel is a slave channel for EFB based on [ItChat](https://github.com/littlecodersh/ItChat) and WeChat Web <span style="font-size: 0.5em;">(rev.eng.)</span> API.
3+
EFB WeChat Slave (EWS) is a slave channel for EFB based on [ItChat](https://github.com/littlecodersh/ItChat) and WeChat Web <span style="font-size: 0.5em;">(rev.eng.)</span> API.
44

55
## Specs
66
* Unique name: `eh_wechat_slave`
@@ -92,5 +92,15 @@ eh_wechat_slave = {
9292
}
9393
```
9494

95-
* `refresh_friends` _(bool)_ [Default: False]
95+
* `refresh_friends` _(bool)_ [Default: `False`]
9696
Always refresh chat lists when asked. (Except from the extra function.)
97+
* `uid_order` _(list of str)_ [Default: `["NickName"]`]
98+
Fallback order of resolving `uid` from WeChat user info. Highest priority goes to index 0. The list **MUST** be non empty with only values below, and the last element associate to a rather stable and available value for most chats, if not all of them.
99+
Available values: _(U, G, M means the value is available to users, groups, and group members respectively)_
100+
* `"NickName"`: [UGM] Name of the user/group
101+
* `"alias"`: [UM] Alias of the user
102+
* `"uin"`: [UG] WeChat Unique Identifier for all chats, **Not always available**.
103+
* `extra_links_on_message` _(bool)_ [Default: `False`]
104+
List out all other messages (more than first one) for link messages with more than one link from MPS accounts.
105+
* `max_quote_length` _(int)_ [Default: `-1`]
106+
Maximum length of text for quotation messages. Set to 0 to fully disable quotation. Set to -1 to always quote full message.

docs/channel.md

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Type of the channel, choose between
2323
* `ChannelType.Master`
2424
* `ChannelType.Slave`
2525

26+
**supported_message_types** (`set` of `MsgType` constant)
27+
A list of supported message types to send **to** the channel.
28+
2629
**queue** (queue.Queue)
2730
Global message queue initialized by the parental `__init__` method. This queue is used to deliver messages from slave channels to the master channel.
2831

@@ -58,6 +61,10 @@ Raises:
5861
* `EFBChatNotFound`
5962
* `EFBMessageNotFound`
6063
* `EFBMessageTypeNotSupported`
64+
* `EFBMessageError`
65+
66+
Returns:
67+
The original EFBMsg object `msg` with `uid` property defined.
6168

6269
**get_chats(self)** _(for slave channels)_
6370
Returns a `list` of `dict`s for available chats in the channel. Each `dict` should be like:

docs/exceptions.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ Raised by a slave channel when the recipient channel is not found when a message
99
Raised when an incoming message is in a type not supported by the recipient channel. Applicable to both master and slave channels.
1010

1111
## `EFBMessageNotFound`
12-
Raised when a message is trying to "direct reply" to another message which couldn't be found.
12+
Raised when a message is trying to "direct reply" to another message which couldn't be found.
13+
14+
## `EFBMessageError`
15+
Raised when a message is failed to send for any other reason.

docs/index.md

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

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)
3+
![Python 3.x](https://img.shields.io/badge/Python-3.x-blue.svg) [![Gitter](https://img.shields.io/gitter/room/blueset/ehForwarderBot.svg)](https://gitter.im/blueset/ehForwarderBot)
44
[![Telegram support group](https://img.shields.io/badge/Chat-on%20Telegram-blue.svg)](https://telegram.me/efbsupport)
5-
[![license](https://img.shields.io/github/license/blueset/ehforwarderbot.svg)](LICENSE)
6-
5+
[![Docs: Stable version](https://readthedocs.org/projects/ehforwarderbot/badge/?version=latest)](https://ehforwarderbot.readthedocs.io/en/latest/)
6+
[![Docs: Development version version](https://readthedocs.org/projects/ehforwarderbot/badge/?version=dev)](https://ehforwarderbot.readthedocs.io/en/dev/)
77

88
![EFB](https://images.1a23.com/upload/images/SPET.png)
99

@@ -36,8 +36,9 @@ _Codename_ **EH Forwarder Bot** (EFB) is an extensible chat tunnel framework whi
3636
## Feel like contributing?
3737
Anyone is welcomed to raise an issue or submit a pull request, just remember to read through and understand the [contribution guideline](CONTRIBUTING.md) before you do so.
3838

39-
## Special thanks
40-
* @clairvoyantegg for documentation refine.
39+
## Related articles
40+
* [EFB How-to: Send and Receive Messages from WeChat on Telegram (zh-CN)](https://blog.1a23.com/2017/01/09/EFB-How-to-Send-and-Receive-Messages-from-WeChat-on-Telegram-zh-CN/)
41+
_(安装并使用 EFB:在 Telegram 收发微信消息)_
4142

4243
## License
4344
EFB framework is licensed under [GNU General Public License 3.0](https://www.gnu.org/licenses/gpl-3.0.txt).

docs/message.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Location messages.
178178

179179
Shared links.
180180

181-
* `text`: Structured text with at least the URL in the message.
181+
* `text`: Any extra information for the link.
182182
* `attributes`: a `dict` with 4 items: _(None if not available)_
183183
* **"title"**: Title of the linked article,
184184
* **"description"**: Brief description of the article,

main.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
import threading
44
import logging
55
import argparse
6+
import sys
67

7-
__version__ = "1.2 build 20170112"
8+
if sys.version_info.major < 3:
9+
raise Exception("Python 3.x is required. Your version is %s." % sys.version)
10+
11+
__version__ = "1.3 build 20170119"
812

913
parser = argparse.ArgumentParser(description="EH Forwarder Bot is an extensible chat tunnel framework which allows "
1014
"users to contact people from other chat platforms, and ultimately "
@@ -52,13 +56,19 @@ def init():
5256
q = queue.Queue()
5357
# Initialize Plug-ins Library
5458
# (Load libraries and modules and init them with Queue `q`)
59+
l = logging.getLogger("ehForwarderBot")
5560
slaves = {}
5661
for i in config.slave_channels:
62+
l.critical("\x1b[0;37;46m Initializing slave %s... \x1b[0m" % i)
5763
obj = getattr(__import__(i[0], fromlist=i[1]), i[1])
5864
slaves[obj.channel_id] = obj(q)
65+
l.critical("\x1b[0;37;42m Slave channel %s (%s) initialized. \x1b[0m" % (obj.channel_name, obj.channel_id))
66+
l.critical("\x1b[0;37;46m Initializing master %s... \x1b[0m" % config.master_channel)
5967
master = getattr(__import__(config.master_channel[0], fromlist=config.master_channel[1]), config.master_channel[1])(
6068
q, slaves)
69+
l.critical("\x1b[0;37;42m Master channel %s (%s) initialized. \x1b[0m" % (master.channel_name, master.channel_id))
6170

71+
l.critical("\x1b[0;37;42m All channels initialized. \x1b[0m")
6272
master_thread = threading.Thread(target=master.poll)
6373
slave_threads = {key: threading.Thread(target=slaves[key].poll) for key in slaves}
6474

0 commit comments

Comments
 (0)