GithubHelp home page GithubHelp logo

ehforwarderbot / efb-telegram-master Goto Github PK

View Code? Open in Web Editor NEW
220.0 10.0 77.0 10.01 MB

EFB Telegram Master Channel, a channel for EH Forwarder Bot.

License: GNU Affero General Public License v3.0

Python 100.00%
eh-forwarder-bot efb-master-channel telegram telegram-bot

efb-telegram-master's Introduction

EFB Telegram Master Channel (ETM)

PyPI release

Tests status

Downloads per month

Translate this project

Banner

README in other languages.

Channel ID: blueset.telegram

ETM is a Telegram Master Channel for EH Forwarder Bot, based on Telegram Bot API, python-telegram-bot.

Requirements

  • Python >= 3.6
  • EH Forwarder Bot >= 2.0.0
  • ffmpeg
  • libmagic
  • libwebp

Getting Started

  1. Install all required binary dependencies
  2. Install ETM

    pip3 install efb-telegram-master
  3. Enable and configure ETM using the EFB configuration wizard, or enable it manually in the profile’s config.yaml.

    The path of your profile storage directory depends on your configuration.

    (As of EFB 2, default profile storage directory is located at ~/.ehforwarderbot/profiles/default )

  4. Configure the channel (manual configure instructions as follows)

Alternative installation methods

ETM also has other alternative installation methods contributed by the community, including:

Manual Configuration

Set up a bot

Create a bot with @BotFather, give it a name and a username. Then you’ll get a token, which will be used later. Keep this token secure, as it gives who owns it the full access to the bot.

Use /setjoingroups to allow your bot to join groups. Use /setprivacy to disable the privacy restriction of the bot, so that it can receive all messages in the group.

Complete configuration file

Configuration file is stored at <profile directory>/blueset.telegram/config.yaml.

A sample config file can be as follows:

##################
# Required items #
##################

# [Bot Token]
# This is the token you obtained from @BotFather
token: "012345678:1Aa2Bb3Vc4Dd5Ee6Gg7Hh8Ii9Jj0Kk1Ll2M"

# [List of Admin User IDs]
# ETM will only process messages and commands from users
# listed below. This ID can be obtained from various ways 
# on Telegram.
admins:
- 102938475
- 91827364

##################
# Optional items #
##################
# [Experimental Flags]
# This section can be used to toggle experimental functionality.
# These features may be changed or removed at any time.
# Options in this section is explained afterward.
flags:
    option_one: 10
    option_two: false
    option_three: "foobar"

# [Network Configurations]
# [RPC Interface]
# Refer to relevant sections afterwards for details.

Usage

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.

In a nutshell, ETM offers the following commands, you can also send it to BotFather for a command list:

help - Show commands list.
link - Link a remote chat to a group.
unlink_all - Unlink all remote chats from a group.
info - Display information of the current Telegram chat.
chat - Generate a chat head.
extra - Access additional features from Slave Channels.
update_info - Update info of linked Telegram group.
react - Send a reaction to a message, or show a list of reactors.
rm - Remove a message from its remote chat.

Note

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.

  1. Create a new group, invite your bot to the group
  2. Send /link directly to the bot, then select your preferred slave chat.
  3. Tap “Link” and select your new group. You can also choose to unlink or relink a linked chat from this menu.
  4. Tap “Start” at the bottom of your screen, and you should see a success message: “Chat linked.”

Note

You may introduce non-ETM admin users to the group, however, they:

  • Can read all messages send from the related remote chat;
  • May NOT send message on your behalf.

If the “Link” button doesn’t work for you, you may try the “Manual Link/Relink” button. To manually link a remote chat:

  1. Add the bot to the group you want to link to
  2. Copy the code provided by the bot, and send it to the group.
  3. If the group is linked successfully, you would receive a confirmation from the bot.

Also, you can send /unlink_all to a group to unlink all remote chats from it.

Also, if you want to link a chat which you just used, you can simply reply /link quoting a previous message from that chat without choosing from the long chat list.

Advanced feature: Filtering

If you have just too many chats, and being too tired for keep tapping Next >, or maybe you just want to find a way to filter out what you’re looking for, now ETM has equipped /chat and /list with filtering feature. Attach your keyword behind, and you can get a filtered result.

E.g.: /chat Eana will give you all chats has the word “Eana”.

Technical Details

The filter query is in fact a regular expression matching. We used Python’s re.search with flags re.DOTALL | re.IGNORECASE in this case, i.e.: . matches everything including line breaks, and the query is NOT case-sensitive. Each comparison is done against a specially crafted string which allows you to filter multiple criteria.

Channel: <Channel name>
Channel ID: <Channel ID>
Name: <Chat name>
Alias: (<Chat Alias>|None)
ID: <Chat Unique ID>
Type: (Private|Group|System)
Mode: [Linked]
Description: <Description>
Notification: (ALL|MENTION|NONE)
Other: <Python Dictionary String>

Note

Type can be either “User” or “Group”

Other is the vendor specific information provided by slave channels. Format of such information is specified in their documentations respectively.

Examples:

  • Look for all WeChat groups: Channel: WeChat.*Type: Group
  • Look for everyone who has no alias (and those with an alias called “None”): Alias: None
  • Look for all entries contain “John” and “Johnny” in any order: (?=.*John)(?=.*Johnny)

Send a message

Send to a linked chat

You can send message as you do in a normal Telegram chat.

What is supported:

  • Send/forward message in all supported types
  • Quote-reply to a message
  • Send message with inline bot in supported types

What is NOT supported:

  • @ reference
  • Markdown/HTML formatting
  • Inline buttons
  • Messages with unsupported types.

Note

This only applies to Telegram groups that are linked to a single remote chat, groups that are linked with multiple remote chats shall work in the same way as non-linked chats.

Send to a non-linked chat

To send a message to a non-linked chat, you should “quote-reply” to a message or a “chat head” that is sent from your recipient. Those messages should appear only in the bot conversation.

In a non-linked chat, quote-reply will not be passed on to the remote channel, everything else is supported as it does in a linked chat.

Quick reply in non-linked chats

ETM provides a mechanism that allow you to keep sending messages to the same recipient without quoting every single time. ETM will store the remote chat you sent a message to in every Telegram chat (i.e. a Telegram group or the bot), which is known as the “last known recipient” of the Telegram chat.

In case where recipient is not indicated for a message, ETM will try to deliver it to the “last known recipient” in the Telegram chat only if:

  1. your last message with the “last known recipient” is with in an hour, and
  2. the last message in this Telegram chat is from the “last known recipient”.

Edit and delete message

In EFB v2, the framework added support to message editing and removal, and so does ETM. However, due to the limitation of Telegram Bot API, although you may have selected “Delete for the bot”, or “Delete for everyone” while deleting messages, the bot would not know anything about it. Therefore, if you want your message to be removed from a remote chat, edit your message and prepend it with rm (it’s R, M, and ~, not single quote), so that the bot knows that you want to delete the message. Alternatively, you can also reply/rmto a message to remove it from its remote chat. This can be useful when you cannot edit the message directly (sticker, location, etc.), or when the message is not sent via ETM. Please also notice that some slave channels may not support editing and/or deleting messages depends on their implementations./chat: Chat head ^^^^^^^^^^^^^^^^^^^^ 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. Send/chatto the bot, and choose a chat from the list. When you see “Reply to this message to chat with ...”, it’s ready to go. Advanced feature: Filtering ''''''''''''''''''''''''''' Filter is also available in/chatcommand. Please refer to the same chapter above, under/linkfor details./extra: External commands from slave channels (“additional features”) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Some slave channels may provide commands that allows you to remotely control those accounts, and achieve extra functionality, those commands are called “additional features”. To view the list of available extra functions, send/extrato the bot, you will receive a list of commands available. Those commands are named like “\/<number>_<command_name>\ ”, and can be called like an CLI utility. (of course, advanced features like piping etc would not be supported)/update_info: Update details of linked Telegram group ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ETM can help you to update the name and profile picture of a group to match with appearance in the remote chat. This will also add a list of current members to the Telegram group description if the remote chat is a group. This functionality is available when: * This command is sent to a group * The bot is an admin of the group * The group is linked to **exactly** one remote chat * The remote chat is accessible Profile picture will not be set if it’s not available from the slave channel./react: Send reactions to a message or show a list of reactors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reply/reactto a message to show a list of chat members who have reacted to the message and what their reactions are. Reply/reactfollowed by an emoji to react to this message, e.g./react 👍. Send/react -to remove your reaction. Note that some slave channels may not accept message reactions, and some channels have a limited reactions you can send with. Usually when you send an unaccepted reaction, slave channels can provide a list of suggested reactions you may want to try instead./rm: Delete a message from its remote chat ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can reply/rmto a message to remove it from its remote chat. Comparing to prependingrm` to a message, you can use this command even when you cannot edit the message directly (sticker, location, etc.), or when the message is not sent via ETM. It can also allow you to remove messages sent by others if provided by the slave channel. Please notice that some slave channels may not support removing messages depends on their implementations. Telegram Channel support ~~~~~~~~~~~~~~~~~~~~~~~~ ETM supports linking remote chats to Telegram Channels with partial support. The bot can: - Link one or more remote chats to a Telegram Channel - Check and manage link status of the channel - Update channel title and profile pictures accordingly It cannot: - Process messages sent by you or others to the channel - Accept commands in the channel Currently the following commands are supported in channels: -/startfor manual chat linking -/linkto manage chats linked to the channel -/infoto show information of the channel -/update_infoto update the channel title and picture How to use: 1. Add the bot as an administrator of the channel 2. Send commands to the channel 3. Forward the command message to the bot privately .. admonition:: Technical Details Telegram Bot API prevents bot from knowing who actually sent a message in a channel (not including signatures as that doesn't reflect the numeric ID of the sender). In fact, that is the same for normal users in a channel too, even admins. If messages from channels are to be processed unconditionally, not only that other admins in existing channels can add malicious admins to it, anyone on Telegram, once knows your bot username, can add it to a channel and use the bot on your behalf. Thus, we think that it is not safe to process messages directly from a channel. Limitations ----------- Due to the technical constraints of both Telegram Bot API and EH Forwarder Bot framework, ETM has the following limitations: - Some Telegram message types are **not** supported: - Game messages - Invoice messages - Payment messages - Passport messages - Vote messages - ETM cannot process any message from another Telegram bot. - Some components in Telegram messages are dropped: - Original author and signature of forwarded messages - Formats, links and link previews - Buttons attached to messages - Details about inline bot used on messages - Some components in messages from slave channels are dropped: - @ references not referring to you. - The Telegram bot can only - send you any file up to 50 MB, - receive file from you up to 20 MB. Experimental flags ------------------ The following flags are experimental features, may change, break, or disappear at any time. Use at your own risk. Flags can be enabled in theflagskey of the configuration file, e.g.: .. code:: yaml flags: flag_name: flag_value -chats_per_page*(int)* [Default:10] Number of chats shown in when choosing for/chatand/linkcommand. An overly large value may lead to malfunction of such commands. -network_error_prompt_interval*(int)* [Default:100] Notify the user about network error everynerrors received. Set to 0 to disable it. -multiple_slave_chats*(bool)* [Default:true] Link more than one remote chat to one Telegram group. Send and reply as you do with an unlinked chat. Disable to link remote chats and Telegram group one-to-one. -prevent_message_removal*(bool)* [Default:true] When a slave channel requires to remove a message, EFB will ignore the request if this value istrue. -auto_locale*(str)* [Default:true] Detect the locale from admins’ messages automatically. Locale defined in environment variables will be used otherwise. -retry_on_error*(bool)* [Default:false] Retry infinitely when an error occurred while sending request to Telegram Bot API. Note that this may lead to repetitive message delivery, as the respond of Telegram Bot API is not reliable, and may not reflect the actual result. -send_image_as_file*(bool)* [Default:false] Send all image messages as files, in order to prevent Telegram’s image compression in an aggressive way. -message_muted_on_slave*(str)* [Default:normal] Behavior when a message received is muted on slave channel platform. -normal: send to Telegram as normal message -silent: send to Telegram as normal message, but without notification sound -mute: do not send to Telegram -your_message_on_slave*(str)* [Default:silent] Behavior when a message received is from you on slave channel platform. This overrides settings frommessage_muted_on_slave. -normal: send to Telegram as normal message -silent: send to Telegram as normal message, but without notification sound -mute: do not send to Telegram -animated_stickers*(bool)* [Default:false] Enable experimental support to animated stickers. Note: you need to install binary dependencylibcairoon your own, and additional Python dependencies viapip3 install "efb-telegram-master[tgs]"to enable this feature. -send_to_last_chat*(str)* [Default:warn] Enable quick reply in non-linked chats. -enabled: Enable this feature without warning. -warn: Enable this feature and issue warnings every time when you switch a recipient with quick reply. -disabled: Disable this feature. -default_media_prompt*(str)* [Default:emoji] Placeholder text when the a picture/video/file message has no caption. -emoji: Use emoji like 🖼️, 🎥, and 📄. -text: Use text like “Sent a picture/video/file”. -disabled: Use empty placeholders. -api_base_url*(str)* [Default:null] Base URL of the Telegram Bot API. Defaulted tohttps://api.telegram.org/bot. -api_base_file_url*(str)* [Default:null] Base file URL of the Telegram Bot API. Defaulted tohttps://api.telegram.org/file/bot. -local_tdlib_api*(bool)* [Default:false] Enable this option if the bot API is running in--localmode and is using the same file system with ETM. Network configuration: timeout tweaks ------------------------------------- This chapter is adapted from `Python Telegram Bot wiki`__, licensed under CC-BY 3.0.python-telegram-botperforms HTTPS requests usingurllib3.urllib3provides control overconnect_timeout&read_timeout.urllib3does not separate between what would be considered read & write timeout, soread_timeoutserves for both. The defaults chosen for each of these parameters is 5 seconds. Theconnect_timeoutvalue controls the timeout for establishing a connection to the Telegram server(s). Changing the defaults ofread_timeout&connect_timeoutcan be done by adjusting valuesrequest_kwargssection in ETM’sconfig.yaml. .. code:: yaml # ... request_kwargs: read_timeout: 6 connect_timeout: 7 Run ETM behind a proxy ---------------------- This chapter is adapted from `Python Telegram Bot wiki`__, licensed under CC-BY 3.0. You can appoint proxy specifically for ETM without affecting other channels running in together in the same EFB instance. This can also be done by adjusting valuesrequest_kwargssection in ETM’sconfig.yaml. HTTP proxy server ~~~~~~~~~~~~~~~~~ .. code:: yaml request_kwargs: # ... proxy_url: http://PROXY_HOST:PROXY_PORT/ # Optional, if you need authentication: username: PROXY_USER password: PROXY_PASS SOCKS5 proxy server ~~~~~~~~~~~~~~~~~~~ This is configuration is supported, but requires an optional/extra python package. To install: .. code:: shell pip install python-telegram-bot[socks] .. code:: yaml request_kwargs: # ... proxy_url: socks5://URL_OF_THE_PROXY_SERVER:PROXY_PORT # Optional, if you need authentication: urllib3_proxy_kwargs: username: PROXY_USER password: PROXY_PASS RPC interface ------------- A standard `Python XML RPC server`__ is implemented in ETM 2. It can be enabled by adding arpcsection in ETM’sconfig.ymlfile. .. code:: yaml rpc: server: 127.0.0.1 port: 8000 .. .. warning:: Thexmlrpcmodule is not secure against maliciously constructed data. Do not expose the interface to untrusted parties or the public internet, and turn off after use. Exposed functions ~~~~~~~~~~~~~~~~~ Functions in `the db (database manager) class`_ and `the RPCUtilities class`_ are exposed. Refer to the source code for their documentations. How to use ~~~~~~~~~~ Set up aSimpleXMLRPCClientin any Python script and call any of the exposed functions directly. For details, please consult `Python documentation on xmlrpc`__. Setup Webhook ------------- For details on how to setup a webhook, please visit this `wiki article`_. License ------- ETM is licensed under `GNU Affero General Public License 3.0`_ or later versions:: EFB Telegram Master Channel: A master channel for EH Forwarder Bot. Copyright (C) 2016 - 2020 Eana Hufwe, and the EFB Telegram Master Channel 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 ------------------- ETM supports translated user interface with the help of community. The bot detects languages of Telegram Client of the admins from their messages, and automatically matches with a supported language on the go. Otherwise, you can set your language by turning off theauto_localefeature, and then setting the locale environmental variable (LANGUAGE,LC_ALL,LC_MESSAGESorLANG) to one of our supported languages. Meanwhile, you can help to translate this project into your languages on `our Crowdin page`_. .. note:: If your are installing from source code, you will not get translations of the user interface without manual compile of message catalogs (.mo``) prior to installation.

efb-telegram-master's People

Contributors

blueset avatar cxumol avatar jamzumsum avatar leavesster avatar specter119 avatar whtsky avatar wolfsilver avatar wydwww avatar yqt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

efb-telegram-master's Issues

Unable to send gif animation in telegram

I saw the following in the log file when I tried to send gif animation. Can someone explain what is wrong? Running ehForwarderBot on Ubuntu 17.04.

2018-04-01 18:24:15,251 [ERROR]: telegram.ext.dispatcher (dispatcher.process_update; dispatcher.py:301) 
    An uncaught error was raised while processing the update
  File "/usr/local/lib/python3.6/dist-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.6/dist-packages/moviepy/video/VideoClip.py", line 491, in write_gif
    dispose=dispose, colors=colors)
  File "<decorator-gen-12>", line 2, in write_gif
  File "/usr/local/lib/python3.6/dist-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "<decorator-gen-11>", line 2, in write_gif
  File "/usr/local/lib/python3.6/dist-packages/moviepy/decorators.py", line 137, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "/usr/local/lib/python3.6/dist-packages/moviepy/video/io/gif_writers.py", line 184, in write_gif
    '-r', "%.02f"%fps, filename], **popen_params)
  File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1275, in _execute_child
    restore_signals, start_new_session, preexec_fn)
TypeError: expected str, bytes or os.PathLike object, not _TemporaryFileWrapper
2018-04-01 18:24:15,251 [ERROR]: telegram.ext.dispatcher (dispatcher.process_update; dispatcher.py:301)
    An uncaught error was raised while processing the update
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/dispatcher.py", line 279, in process_update
    handler.handle_update(update, self)
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/messagehandler.py", line 169, in handle_update
    return self.callback(dispatcher.bot, update, **optional_args)
  File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/master_message.py", line 70, in msg_thread_creator
    threading.Thread(target=self.msg, args=(bot, update)).run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/master_message.py", line 108, in msg
    return self.process_telegram_message(bot, update)
  File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/master_message.py", line 325, in process_telegram_message
    m.file, m.mime, m.filename, m.path = self._download_gif(message.document)
  File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/master_message.py", line 440, in _download_gif
    VideoFileClip(path).write_gif(gif_file, program="ffmpeg")
  File "<decorator-gen-56>", line 2, in write_gif
  File "/usr/local/lib/python3.6/dist-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "<decorator-gen-55>", line 2, in write_gif
  File "/usr/local/lib/python3.6/dist-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.6/dist-packages/moviepy/video/VideoClip.py", line 491, in write_gif
    dispose=dispose, colors=colors)
  File "<decorator-gen-12>", line 2, in write_gif
  File "/usr/local/lib/python3.6/dist-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "<decorator-gen-11>", line 2, in write_gif
  File "/usr/local/lib/python3.6/dist-packages/moviepy/decorators.py", line 137, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "/usr/local/lib/python3.6/dist-packages/moviepy/video/io/gif_writers.py", line 184, in write_gif
    '-r', "%.02f"%fps, filename], **popen_params)
  File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1275, in _execute_child
    restore_signals, start_new_session, preexec_fn)
TypeError: expected str, bytes or os.PathLike object, not _TemporaryFileWrapper

KeyError: 'access_token'

After I login wechat , I saw this:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/dist-packages/ehforwarderbot/main.py", line 207, in
main()
File "/usr/local/lib/python3.6/dist-packages/ehforwarderbot/main.py", line 202, in main
init()
File "/usr/local/lib/python3.6/dist-packages/ehforwarderbot/main.py", line 95, in init
(instance_id=instance_id))
File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/init.py", line 126, in init
self.voice_recognition: VoiceRecognitionManager = VoiceRecognitionManager(self)
File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/voice_recognition.py", line 49, in init
self.voice_engines.append(BaiduSpeech(self.channel, tokens['baidu']))
File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/voice_recognition.py", line 120, in init
self.access_token = r['access_token']
KeyError: 'access_token'

How should I do?

[ERROR]: telegram.ext.dispatcher (dispatcher.process_update; dispatcher.py:301)

出现了一个不影响使用的 error :


2019-04-09 13:03:39,298 [ERROR]: telegram.ext.dispatcher (dispatcher.process_update; dispatcher.py:301)
    An uncaught error was raised while processing the update
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/telegram/ext/dispatcher.py", line 279, in process_update
    handler.handle_update(update, self)
  File "/usr/local/lib/python3.6/site-packages/telegram/ext/commandhandler.py", line 173, in handle_update
    return self.callback(dispatcher.bot, update, **optional_args)
  File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/commands.py", line 132, in extra_listing
    msg += "\n\n<b>%s %s (%s)</b>" % (i.channel_emoji, i.module_name, i.module_id)
AttributeError: 'WeChatChannel' object has no attribute 'module_name'

This mistake happened when wechat logining successful

And efb_telegram_master seems goes wrong,I don't know how to slove this

Traceback (most recent call last):
File "/usr/local/bin/ehforwarderbot", line 11, in sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/ehforwarderbot/main.py", line 190, in main init()
File "/usr/local/lib/python3.6/dist-packages/ehforwarderbot/main.py", line 94, in init
(instance_id=instance_id)) File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/init.py", line 126, in init
self.voice_recognition: VoiceRecognitionManager = VoiceRecognitionManager(self)
File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/voice_recognition.py", line 49, in init
self.voice_engines.append(BaiduSpeech(self.channel, tokens['baidu']))
File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/voice_recognition.py", line 116, in init
"client_id": key_dict['api_key'],
TypeError: 'NoneType' object is not subscriptable

Doesn't delete original file after converting to GIF

From @xiadong1994 on December 27, 2017 2:25

When I send a saved GIF from Telegram, the filename extension is .mp4. The EFB will convert it to .gif and send to WeChat. After sending to WeChat, the .gif file will be deleted but the original .mp4 file is remained. I think the file should be deleted after converting in _download_gif function in plugins/eh_telegram_master/__init__.py.

Copied from original issue: ehForwarderBot/ehForwarderBot#105

An error during voice recog

Here is the log:

2018-07-14 00:13:48,454 [ERROR]: telegram.ext.dispatcher (dispatcher.process_update; dispatcher.py:301)
    An uncaught error was raised while processing the update
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/dispatcher.py", line 279, in process_update
    handler.handle_update(update, self)
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/commandhandler.py", line 173, in handle_update
    return self.callback(dispatcher.bot, update, **optional_args)
  File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/voice_recognition.py", line 74, in recognize_speech
    file, _, _ = self._download_file(update.message, update.message.reply_to_message.voice, MsgType.Audio)
AttributeError: 'VoiceRecognitionManager' object has no attribute '_download_file'

Currently does not support multiple 'admin'

Currently does not support multiple 'admin'

For example, I want everyone in my tg group to send messages through my bot.

Can I add multiple 'admin's via '|'?

Or delete 'admin'

Language Code of Chinese family

According to the newest standard, the language code scheme should be:
[Macro Language]-[Language]-[Script]-[Region Varient].
For example:
Mandarin written in Simplifed Chinese of mainland China: zh-cmn-Hans-CN
Mandarin written in Traditional Chinese of Hong Kong: zh-cmn-Hant-HK
Cantonese written in Simplifed Chinese of Taiwan: zh-yue-Hans-TW
Hakka language written in Simplifed Chinese of mainland China: zh-hak-Hans-CN

Parts can be ignore in case the information is not important.

In the case of speed recognition, we want to focus on the oral language, so we should use:
(zh-)cmn, (zh-)yue to represent Mandarin and Cantonese. If we want to control the output script used to write the language, script code(Hans, Hant) should also be added.

PS: at least, we should use yue instead of ct as the code for cantonese.

TypeError: 'NoneType' object is not subscriptable

when I want to send message in my group, I get
捕获

when I pick one of my contact, the log shows:

2019-04-09 09:05:37,715 [ERROR]: telegram.ext.dispatcher (dispatcher.process_update; dispatcher

.py:301)
    An uncaught error was raised while processing the update
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/dispatcher.py", line 279, in process_update
    handler.handle_update(update, self)
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/conversationhandler.py", line 305, in handle_update
    new_state = self.current_handler.handle_update(update, dispatcher)
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/callbackqueryhandler.py", line 143, in handle_update
    return self.callback(dispatcher.bot, update, **optional_args)
  File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/chat_binding.py", line 822, in suggested_recipient
    chat = self.msg_storage[storage_id].candidates[int(param.split(' ', 1)[1])]
TypeError: 'NoneType' object is not subscriptable

Database is locked

From @Gontid on July 27, 2017 14:31

Doesn't seem to affect functionality but I saw the following in the log file. Can someone explain what is wrong? Running ehForwarderBot on Centos 7.

return self.database.execute_sql(sql, params, self.require_commit)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3775, in execute_sql
    self.commit()
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3598, in __exit__
    reraise(new_type, new_type(*exc_args), traceback)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 135, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3768, in execute_sql
    cursor.execute(sql, params or ())
peewee.OperationalError: database is locked

Appreciate your help!

Copied from original issue: ehForwarderBot/ehForwarderBot#68

[BUG REPORT] ValueError: Deliver_to is not valid.

BUG description:

  • When:

It occurs when attempting to login WeChat.

  • Details:

Console logs ValueError: Deliver_to is not valid. after successfully logging in with QR code, while no Web-WeChat using status in WeChat app and the bot doesn't work.

Log:

.......................... upper logs has been ignored .....................................

Please scan the QR code to log in.
2018-04-22 12:18:18,281 [INFO]: itchat (login.login; login.py:50) 
    Please scan the QR code to log in.
2018-04-22 12:18:26,909 [Level 99]: plugins.blueset.wechat.WeChatChannel (__init__.console_qr_code; __init__.py:203) 
    Confirm on your phone.
Please press confirm on your phone.
2018-04-22 12:18:26,910 [INFO]: itchat (login.login; login.py:60) 
    Please press confirm on your phone.
2018-04-22 12:18:29,145 [Level 99]: plugins.blueset.wechat.WeChatChannel (__init__.console_qr_code; __init__.py:206) 
    Successfully logged in.
Loading the contact, this may take a little while.
2018-04-22 12:18:29,145 [INFO]: itchat (login.login; login.py:70) 
    Loading the contact, this may take a little while.
Login successfully as 
2018-04-22 12:18:29,206 [INFO]: itchat (login.login; login.py:80) 
    Login successfully as 
2018-04-22 12:18:29,212 [Level 99]: ehforwarderbot.__main__ (__main__.init; __main__.py:87) 
     Slave channel WeChat Slave (blueset.wechat) # None is initialized. 
2018-04-22 12:18:29,212 [Level 99]: ehforwarderbot.__main__ (__main__.init; __main__.py:90) 
     Initializing master blueset.telegram... 
Traceback (most recent call last):
  File "/usr/local/bin/ehforwarderbot", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/ehforwarderbot/__main__.py", line 190, in main
    init()
  File "/usr/local/lib/python3.6/site-packages/ehforwarderbot/__main__.py", line 94, in init
    (instance_id=instance_id))
  File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/__init__.py", line 124, in __init__
    self.db: DatabaseManager = DatabaseManager(self)
  File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/db.py", line 20, in __init__
    self.db.connect()
  File "/usr/local/lib/python3.6/site-packages/peewee.py", line 2505, in connect
    self._state.set_connection(self._connect())
  File "/usr/local/lib/python3.6/site-packages/peewee.py", line 2737, in _connect
    raise ImproperlyConfigured('SQLite driver not installed!')
peewee.ImproperlyConfigured: SQLite driver not installed!
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.6/site-packages/itchat/components/login.py", line 281, in maintain_loop
    exitCallback()
  File "/usr/local/lib/python3.6/site-packages/efb_wechat_slave/__init__.py", line 286, in exit_callback
    coordinator.send_message(msg)
  File "/usr/local/lib/python3.6/site-packages/ehforwarderbot/coordinator.py", line 103, in send_message
    msg.verify()
  File "/usr/local/lib/python3.6/site-packages/ehforwarderbot/message.py", line 128, in verify
    raise ValueError("Deliver_to is not valid.")
**ValueError: Deliver_to is not valid.**

Environment:

1. System:

Linux VM-68-189-ubuntu 4.14.11-041411-generic #201801022143 SMP Tue Jan 2 21:44:21 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

2. Software version:

EH Forwarder Bot
Version: 2.0.0b10
Python version:
3.6.1 (default, Apr 22 2018, 09:34:19) 
[GCC 5.4.0 20160609]

Master channel:
    Telegram Master (blueset.telegram) 2.0.0b11 # Default profile

Slave channel:
    WeChat Slave (blueset.wechat) 2.0.0a12

Middlewares:
    No middleware is enabled.

Additional information(config files):

  • ~/.ehforwarderbot/profiles/default/config.yaml
master_channel: blueset.telegram
slave_channels:
- blueset.wechat
  • ~/.ehforwarderbot/profiles/default/blueset.telegram/config.yaml
token: "AAAAAAAAAAAAAAA:AAAAAAAAAAAAAAA"
admins:
- 111111111

# API tokens required for speech recognition
speech_api:
    # https://azure.microsoft.com/en-us/try/cognitive-services/
    bing: "VOICE_RECOGNITION_TOKEN"
    # http://yuyin.baidu.com/
    baidu:
        app_id: 1111111
        api_key: "AAAAAAAAAAAAAAA"
        secret_key: "AAAAAAAAAAAAAAA"


# Experimental Flags
flags:
    no_conversion: false
  • ~/.ehforwarderbot/profiles/default/blueset.wechat/config.yaml
flags:
    delete_on_edit: true

Thanks for your extraordinary work, @blueset .
Best.

FreeBSD got error : AttributeError: 'NoneType' object has no attribute 'startswith'

I installed all the depends , and configured the .yaml ,the I run eFB,but got the following error

    from moviepy.video.VideoClip import VideoClip                                                       
  File "/usr/local/lib/python3.6/site-packages/moviepy/video/VideoClip.py", line 18, in <module>        
    from ..config import get_setting                                                                    
  File "/usr/local/lib/python3.6/site-packages/moviepy/config.py", line 35, in <module>                 
    FFMPEG_BINARY = get_exe()                                                                           
  File "/usr/local/lib/python3.6/site-packages/imageio/plugins/ffmpeg.py", line 104, in get_exe         
    if plat.startswith("win"):                                                                          
AttributeError: 'NoneType' object has no attribute 'startswith'                                         
Error in atexit._run_exitfuncs:                                                                         
Traceback (most recent call last):                                                                      
  File "/usr/local/lib/python3.6/site-packages/ehforwarderbot/__main__.py", line 48, in stop_gracefully 
    if isinstance(coordinator.master, EFBChannel):                                                      
AttributeError: module 'ehforwarderbot.coordinator' has no attribute 'master'   

Why I got “ if plat.startswith("win"): ” , but I am on freebsd os

No prompt, no retry when ETM times out while sending file

From @blueset on November 9, 2017 10:37

Log
2017-11-09 10:28:54,822: itchat [DEBUG]
    No uins in 51 message
2017-11-09 10:28:54,823: itchat [DEBUG]

2017-11-09 10:28:54,823: plugins.eh_wechat_slave.WeChatChannel [DEBUG]
    WeChat "System" message:
<Message: {'SystemInfo': 'uins', 'Url': '', 'Status': 3, 'PlayLength': 0, 'ImgStatus': 1, 'Content': '', 'FileName': '', 'AppInfo': {'Type': 0, 'AppID': ''}, 'ImgWidth': 0, 'Ticket': '', 'FromUserName': '@4cbf265ac22d857f11523b24730b0a2b', 'AppMsgType': 0, 'SubMsgType': 0, 'HasProductId': 0, 'User': <User: {'MemberList': <ContactList: []>, 'UserName': 'filehelper'}>, 'Type': 'System', 'ImgHeight': 0, 'ForwardFlag': 0, 'StatusNotifyCode': 2, 'RecommendInfo': {'Alias': '', 'AttrStatus': 0, 'QQNum': 0, 'NickName': '', 'Content': '', 'Sex': 0, 'City': '', 'Ticket': '', 'Scene': 0, 'VerifyFlag': 0, 'OpCode': 0, 'Province': '', 'Signature': '', 'UserName': ''}, 'FileSize': '', 'MsgType': 51, 'MsgId': '5125997940070499124', 'NewMsgId': 5125997940070499124, 'VoiceLength': 0, 'CreateTime': 1510223334, 'OriContent': '', 'MediaId': '', 'Text': [], 'StatusNotifyUserName': 'filehelper', 'ToUserName': 'filehelper'}>
2017-11-09 10:29:00,129: plugins.eh_wechat_slave.wechat_msg_meta [DEBUG]
    Raw message: <Message: {'Url': '', 'Status': 3, 'PlayLength': 0, 'ImgStatus': 1, 'Content': '<?xml version="1.0"?>\n<msg>\n\t<appmsg appid="wx6618f1cfc6c132f8" sdkver="0">\n\t\t<title>complete-info20003-database-systems-subject-notes.pdf</title>\n\t\t<des />\n\t\t<username />\n\t\t<action>view</action>\n\t\t<type>6</type>\n\t\t<showtype>0</showtype>\n\t\t<content />\n\t\t<url />\n\t\t<lowurl />\n\t\t<dataurl />\n\t\t<lowdataurl />\n\t\t<contentattr>0</contentattr>\n\t\t<streamvideo>\n\t\t\t<streamvideourl />\n\t\t\t<streamvideototaltime>0</streamvideototaltime>\n\t\t\t<streamvideotitle />\n\t\t\t<streamvideowording />\n\t\t\t<streamvideoweburl />\n\t\t\t<streamvideothumburl />\n\t\t\t<streamvideoaduxinfo />\n\t\t\t<streamvideopublishid />\n\t\t</streamvideo>\n\t\t<canvasPageItem>\n\t\t\t<canvasPageXml><![CDATA[]]></canvasPageXml>\n\t\t</canvasPageItem>\n\t\t<appattach>\n\t\t\t<totallen>2183828</totallen>\n\t\t\t<attachid>@cdn_30590201000452305002010002041eab456502030f52590204c394cdcb02045a042d40042b6175706174746163685f363238303562613137353139393064645f313531303232333136363839325f31300204010c00050201000400_d00a1b50fe924d6f86807e2777311dfb_1</attachid>\n\t\t\t<cdnattachurl>30590201000452305002010002041eab456502030f52590204c394cdcb02045a042d40042b6175706174746163685f363238303562613137353139393064645f313531303232333136363839325f31300204010c00050201000400</cdnattachurl>\n\t\t\t<emoticonmd5 />\n\t\t\t<aeskey>d00a1b50fe924d6f86807e2777311dfb</aeskey>\n\t\t\t<fileext>pdf</fileext>\n\t\t\t<islargefilemsg>0</islargefilemsg>\n\t\t</appattach>\n\t\t<extinfo />\n\t\t<androidsource>3</androidsource>\n\t\t<thumburl />\n\t\t<mediatagname />\n\t\t<messageaction><![CDATA[]]></messageaction>\n\t\t<messageext><![CDATA[]]></messageext>\n\t\t<emoticongift>\n\t\t\t<packageflag>0</packageflag>\n\t\t\t<packageid />\n\t\t</emoticongift>\n\t\t<emoticonshared>\n\t\t\t<packageflag>0</packageflag>\n\t\t\t<packageid />\n\t\t</emoticonshared>\n\t\t<weappinfo>\n\t\t\t<username />\n\t\t\t<appid />\n\t\t</weappinfo>\n\t\t<designershared>\n\t\t\t<designeruin>0</designeruin>\n\t\t\t<designername>null</designername>\n\t\t\t<designerrediretcturl>null</designerrediretcturl>\n\t\t</designershared>\n\t\t<emotionpageshared>\n\t\t\t<tid>0</tid>\n\t\t\t<title>null</title>\n\t\t\t<desc>null</desc>\n\t\t\t<iconUrl>null</iconUrl>\n\t\t\t<secondUrl />\n\t\t\t<pageType>0</pageType>\n\t\t</emotionpageshared>\n\t\t<webviewshared>\n\t\t\t<shareUrlOriginal />\n\t\t\t<shareUrlOpen />\n\t\t\t<jsAppId />\n\t\t\t<publisherId />\n\t\t</webviewshared>\n\t\t<template_id>0</template_id>\n\t\t<statextstr>GhQKEnd4NjYxOGYxY2ZjNmMxMzJmOA==</statextstr>\n\t\t<md5>9f8bf94a54db4094a5596e14ac1b165c</md5>\n\t</appmsg>\n\t<fromusername>blueset</fromusername>\n\t<scene>0</scene>\n\t<appinfo>\n\t\t<version>7</version>\n\t\t<appname>微信电脑版</appname>\n\t</appinfo>\n\t<commenturl></commenturl>\n</msg>\n', 'FileName': 'complete-info20003-database-systems-subject-notes.pdf', 'AppInfo': {'Type': 0, 'AppID': 'wx6618f1cfc6c132f8'}, 'ImgWidth': 0, 'Ticket': '', 'FromUserName': '@4cbf265ac22d857f11523b24730b0a2b', 'AppMsgType': 6, 'SubMsgType': 0, 'HasProductId': 0, 'User': <User: {'MemberList': <ContactList: []>, 'UserName': 'filehelper'}>, 'Type': 'Attachment', 'ImgHeight': 0, 'ForwardFlag': 0, 'StatusNotifyCode': 0, 'RecommendInfo': {'Alias': '', 'AttrStatus': 0, 'QQNum': 0, 'NickName': '', 'Content': '', 'Sex': 0, 'City': '', 'Ticket': '', 'Scene': 0, 'VerifyFlag': 0, 'OpCode': 0, 'Province': '', 'Signature': '', 'UserName': ''}, 'FileSize': '2183828', 'MsgType': 49, 'MsgId': '511218672271321680', 'NewMsgId': 511218672271321680, 'VoiceLength': 0, 'CreateTime': 1510223339, 'OriContent': '', 'MediaId': '@crypt_6a80f494_7569bf0780148248ea33855c99e082337bed75ccabb3321e8765c06e33f9bf0d1d142386f75843341b80f8f389f2a124bd928aeae4b549b7f7223cc8cb9078152a0c33b3ec3a685d516fe0741c0c3ddaff4feccf6af246cab315e06b58ba7a32d85dbc8fae405e2810b5793bb32e3bac5a1b117159b302de716334634b20147564cb0a9cf0015729a65cddcc7776cf21bb16dcdee283eb01656505de4c21b26c4558061ea760caa0d385489783e2a5ccdcf9e65bcf62a60f8f9a7cdfe4d5ec34abe009dd1394b824010e766f2651d57cb940ece5decbbb45d49acd7fb78eaa03', 'Text': <function produce_msg.<locals>.download_atta at 0x7f04300821e0>, 'StatusNotifyUserName': '', 'ToUserName': 'filehelper'}>
2017-11-09 10:29:01,436: plugins.eh_wechat_slave.WeChatChannel [INFO]
    File saved from WeChat
Full path: storage/eh_wechat_slave/File_511218672271321680_1510223340.pdf
MIME: application/pdf
2017-11-09 10:29:01,436: plugins.eh_wechat_slave.wechat_msg_meta [DEBUG]
    me, True
2017-11-09 10:29:01,436: plugins.eh_wechat_slave.wechat_msg_meta [DEBUG]
    From user, {'Uin': 'filehelper', 'RemarkName': 'System (filehelper)', 'UserName': 'filehelper', 'NickName': 'System (filehelper)'}
2017-11-09 10:29:01,450: plugins.eh_wechat_slave.wechat_msg_meta [DEBUG]
    dest: {'alias': '\u2006', 'name': '\u2006', 'uid': '1786733442'}
2017-11-09 10:29:01,450: plugins.eh_wechat_slave.wechat_msg_meta [INFO]
    WeChat incoming message:
Type: File
Text: <function produce_msg.<locals>.download_atta at 0x7f04300821e0>
UserName: filehelper
uid: filehelper
name: System (filehelper)
2017-11-09 10:29:01,451: plugins.eh_telegram_master.TelegramChannel [INFO]
    Got message from queue
Type: File
Text: You: complete-info20003-database-systems-subject-notes.pdf
----
2017-11-09 10:29:01,451: plugins.eh_telegram_master.TelegramChannel [DEBUG]
    1510223341.451574, Msg text: You: complete-info20003-database-systems-subject-notes.pdf
2017-11-09 10:29:01,451: plugins.eh_telegram_master.TelegramChannel [INFO]
    Msg sent to TG, task_done marked.
2017-11-09 10:29:01,451: plugins.eh_telegram_master.TelegramChannel [DEBUG]
    1510223341.451574, process_msg_step_0
2017-11-09 10:29:01,452: peewee [DEBUG]
    ('SELECT "t1"."id", "t1"."master_uid", "t1"."slave_uid" FROM "chatassoc" AS t1 WHERE ("t1"."slave_uid" = ?)', ['eh_wechat_slave.filehelper'])
2017-11-09 10:29:01,453: plugins.eh_telegram_master.TelegramChannel [DEBUG]
    1510223341.451574, process_msg_step_1, tg_dest=57995782, msg.origin={'alias': 'System (filehelper)', 'name': 'System (filehelper)', 'uid': 'filehelper'}
2017-11-09 10:29:01,453: plugins.eh_telegram_master.TelegramChannel [DEBUG]
    1510223341.451574, process_msg_step_2
2017-11-09 10:29:08,007: plugins.eh_telegram_master.TelegramChannel [ERROR]
    NetworkError()Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 617, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 390, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.5/http/client.py", line 1107, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1152, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.5/http/client.py", line 1103, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.5/http/client.py", line 936, in _send_output
    self.send(message_body)
  File "/usr/lib/python3.5/http/client.py", line 908, in send
    self.sock.sendall(data)
  File "/usr/lib/python3.5/ssl.py", line 899, in sendall
    v = self.send(data[count:])
  File "/usr/lib/python3.5/ssl.py", line 869, in send
    return self._sslobj.write(data)
  File "/usr/lib/python3.5/ssl.py", line 594, in write
    return self._sslobj.write(data)
socket.timeout: The write operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 190, in _request_wrapper
    resp = self._con_pool.request(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/request.py", line 70, in request
    **urlopen_kw)
  File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/request.py", line 148, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/poolmanager.py", line 244, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 666, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/util/retry.py", line 347, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 617, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 390, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.5/http/client.py", line 1107, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1152, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.5/http/client.py", line 1103, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.5/http/client.py", line 936, in _send_output
    self.send(message_body)
  File "/usr/lib/python3.5/http/client.py", line 908, in send
    self.sock.sendall(data)
  File "/usr/lib/python3.5/ssl.py", line 899, in sendall
    v = self.send(data[count:])
  File "/usr/lib/python3.5/ssl.py", line 869, in send
    return self._sslobj.write(data)
  File "/usr/lib/python3.5/ssl.py", line 594, in write
    return self._sslobj.write(data)
telegram.vendor.ptb_urllib3.urllib3.exceptions.ProtocolError: ('Connection aborted.', timeout('The write operation timed out',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/ehforwarderbot/plugins/eh_telegram_master/__init__.py", line 385, in process_msg
    filename=file_name)
  File "/usr/local/lib/python3.5/dist-packages/telegram/bot.py", line 57, in decorator
    result = func(self, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/bot.py", line 82, in decorator
    result = self._request.post(url, data, timeout=kwargs.get('timeout'))
  File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 264, in post
    'POST', url, body=data.to_form(), headers=data.headers, **urlopen_kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 196, in _request_wrapper
    raise NetworkError('urllib3 HTTPError {0}'.format(error))
telegram.error.NetworkError: urllib3 HTTPError ('Connection aborted.', timeout('The write operation timed out',))

Copied from original issue: ehForwarderBot/ehForwarderBot#93

Problems with markdown conversion from the user

  • Message w/o text / caption causes exceptions
  • Links not overridden with text should not be converted. issue

Instead of having monkey patch here, I'll try to send PR to PTB.

Monkey patching will be added If PR was not accepted by PTB.

Related feature is available at PTB, will fix in next version.

'PhotoSize' object has no attribute 'msg_type'

File: <tempfile._TemporaryFileWrapper object at 0x7fcf9c5b0390> (None @ /tmp/tmpfcyd0592), image/jpeg; Vendor: {}>
AttributeError("'PhotoSize' object has no attribute 'msg_type'",)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/slave_message.py", line 202, in send_message
mime=attachment.msg_type)
AttributeError: 'PhotoSize' object has no attribute 'msg_type'

File transfer failed when file name contains non-ASCII characters.

Issue that exists in upstream library python-telegram-bot since 11.0.

The issue is now fixed in 12.0 beta, along with multiple compatibility changes.

Timeline

  • Include a workaround / notification to user.
  • ETM adopt to PTB 12.0 API
  • PTB finalizes their API for 12.0, and release stable version.
  • ETM release new version
  • Issue (properly) fixed.

Relevant traceback

2019-04-20 04:05:04,518 [ERROR]: efb_telegram_master.slave_message (slave_message.send_message; slave_message.py:214)
    [3454101684214458072] Error occurred while processing message from slave channel.
Message: [Redacted]
BadRequest()
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/slave_message.py", line 149, in send_message
    tg_msg = self.slave_message_file(msg, tg_dest, msg_template, old_msg_id, target_msg_id, reply_markup)
  File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/slave_message.py", line 418, in slave_message_file
    reply_markup=reply_markup)
  File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/bot_manager.py", line 230, in caption_affix
    return fn(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/bot_manager.py", line 342, in send_document
    return self.updater.bot.send_document(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/telegram/bot.py", line 65, in decorator
    result = func(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/telegram/bot.py", line 90, in decorator
    result = self._request.post(url, data, timeout=kwargs.get('timeout'))
  File "/usr/local/lib/python3.6/site-packages/telegram/utils/request.py", line 305, in post
    result = self._request_wrapper('POST', url, fields=data, **urlopen_kwargs)
  File "/usr/local/lib/python3.6/site-packages/telegram/utils/request.py", line 223, in _request_wrapper
    raise BadRequest(message)
telegram.error.BadRequest: Wrong url host

I got the following error after restarting the host.

I got the following error after restarting the host.Before that it works fine.
The error is about missing ffmpeg ? But I have installed it.

root@:# cat /etc/debian_version
9.5
root@:
# uname -a
Linux xx-vm 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u5 (2018-09-30) x86_64 GNU/Linux

root@:# apt-get install ffmpeg
Reading package lists... Done
Building dependency tree
Reading state information... Done
ffmpeg is already the newest version (7:3.2.12-1
deb9u1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

root@:~# ehforwarderbot
Traceback (most recent call last):
File "/usr/local/bin/ehforwarderbot", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/ehforwarderbot/main.py", line 202, in main
init()
File "/usr/local/lib/python3.6/dist-packages/ehforwarderbot/main.py", line 75, in init
conf = config.load_config()
File "/usr/local/lib/python3.6/dist-packages/ehforwarderbot/config.py", line 33, in load_config
channel = utils.locate_module(data['master_channel'], 'master')
File "/usr/local/lib/python3.6/dist-packages/ehforwarderbot/utils.py", line 134, in locate_module
return i.load()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2291, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2297, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/init.py", line 27, in
from .master_message import MasterMessageProcessor
File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/master_message.py", line 13, in
from moviepy.video.io.VideoFileClip import VideoFileClip
File "/usr/local/lib/python3.6/dist-packages/moviepy/video/io/VideoFileClip.py", line 3, in
from moviepy.video.VideoClip import VideoClip
File "/usr/local/lib/python3.6/dist-packages/moviepy/video/VideoClip.py", line 18, in
from ..config import get_setting
File "/usr/local/lib/python3.6/dist-packages/moviepy/config.py", line 35, in
FFMPEG_BINARY = get_exe()
File "/usr/local/lib/python3.6/dist-packages/imageio/plugins/ffmpeg.py", line 127, in get_exe
"Need ffmpeg exe. "
imageio.core.fetching.NeedDownloadError: Need ffmpeg exe. You can obtain it with either:

  • install using conda: conda install ffmpeg -c conda-forge
  • download using the command: imageio_download_bin ffmpeg
  • download by calling (in Python): imageio.plugins.ffmpeg.download()

Message is not found in database. Please try with another one. (UC03)

From @jqqqqqqqqqq on September 25, 2017 11:22

issue

"Message is not found in database. Please try with another one. (UC03)" occurs when replying to a document message(e.g. someone sent a GIF in group).

part of the error message:

2017-09-25 20:14:34,670: plugins.eh_telegram_master.db [INFO]
    get_msg_log 164884364.1718
2017-09-25 20:14:34,671: peewee [DEBUG]
    ('SELECT "t1"."master_msg_id", "t1"."slave_message_id", "t1"."text", "t1"."slave_origin_uid", "t1"."slave_origin_display_name", "t1"."slave_member_uid", "t1"."slave_member_display_name", "t1"."msg_type", "t1"."sent_to", "t1"."time" FROM "msglog" AS t1 WHERE ("t1"."master_msg_id" = ?) ORDER BY "t1"."time" DESC LIMIT 1', ['164884364.1718'])

Copied from original issue: ehForwarderBot/ehForwarderBot#86

AttributeError: 'Message' object has no attribute 'message'

My coding skill is poor,I spent two hours to try solving this,But I failed.

The error message like this

ERROR]: telegram.ext.dispatcher (dispatcher.process_update; dispatcher.py:370)
    An uncaught error was raised while processing the update
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/dispatcher.py", line 329, in process_update
    check = handler.check_update(update)
  File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/global_command_handler.py", line 34, in check_update
    res = self.filters(message)
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/filters.py", line 75, in __call__
    return self.filter(update)
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/filters.py", line 823, in filter
    return update.message is not None or update.edited_message is not None
AttributeError: 'Message' object has no attribute 'message'

Can you help me?
Thanks

Add support to message reactions

Interface

Receiving reaction updates

Append the message with box in fomat like [😄 , 👍 x3, 🤣x2]

Sending reaction updates

Reply to a message with /react <emoji> to send reaction. Reply with error message if the reaction is not possilbe

Something wrong with the linked chat

After linking a chat to a group successfully, it doesn't work. When the chat sends a new message, it can't forward to the group and shows the following error:

BadRequest()
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/slave_message.py", line 138, in send_message
tg_msg = self.slave_message_file(msg, tg_dest, msg_template, old_msg_id, target_msg_id, reply_markup)
File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/slave_message.py", line 374, in slave_message_file
reply_markup=reply_markup)
File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/bot_manager.py", line 201, in caption_affix
return fn(self, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/bot_manager.py", line 312, in send_document
return self.updater.bot.send_document(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/telegram/bot.py", line 65, in decorator
result = func(self, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/telegram/bot.py", line 90, in decorator
result = self._request.post(url, data, timeout=kwargs.get('timeout'))
File "/usr/local/lib/python3.6/site-packages/telegram/utils/request.py", line 305, in post
result = self._request_wrapper('POST', url, fields=data, **urlopen_kwargs)
File "/usr/local/lib/python3.6/site-packages/telegram/utils/request.py", line 223, in _request_wrapper
raise BadRequest(message)
telegram.error.BadRequest: Wrong url host

Operating system: | Centos 7 x86_64 bbr

Conflicted polling detected

After update to 2.0.0b15. The bot repeat a message

Conflicted polling detected. If this error persists, please ensure you are running only one instance of this Telegram bot

However, message can be sended to wechat.

ETM is asking for module_name from a channel.

2019-04-22 17:14:23,301 [ERROR]: telegram.ext.dispatcher (dispatcher.process_update; dispatcher.py:301)
    An uncaught error was raised while processing the update
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/dispatcher.py", line 279, in process_update
    handler.handle_update(update, self)
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/commandhandler.py", line 173, in handle_update
    return self.callback(dispatcher.bot, update, **optional_args)
  File "/usr/local/lib/python3.6/dist-packages/efb_telegram_master/commands.py", line 132, in extra_listing
    msg += "\n\n<b>%s %s (%s)</b>" % (i.channel_emoji, i.module_name, i.module_id)
AttributeError: 'WeChatChannel' object has no attribute 'module_name'

Stack for undelivered messages

Create a queue for all undelivered messages, have a thread in parallel that checks if if there is message in the queue in a fixed in a fixed interval. If found, dequeue and resend, enqueue it back when failed.

Original content (chatlog) liwanglin12 Unofficial: @blueset 话说

telegram 服务器临时连接不上造成的丢消息

能重发么

Eana Hufwe:
目前是使用的 PTB 的5次重试策略

5次重试都不行就输出到 log

liwanglin12 Unofficial:
感觉能不能有一个机制

比如定期检测一下连通性

(比如利用updates

这个五次重试不行的

拉个库存起来

一旦链接恢复就重发

另外给main.py加一个让他重发的能力

主动重连

Eana Hufwe:
倒是可以搞一个 stack 隔一段时间检查一次

nice idea

到 ETM v2 repo 丢一个 issue 吧(俺可能会忘……((

话说这个「主动重连」是什么意思

liwanglin12 Unofficial:
比如 python3 main.py command updateetm

Eana Hufwe:
哦哦

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.