ableev / Zabbix-in-Telegram

Zabbix Notifications with graphs in Telegram
MIT License
771 stars 235 forks source link

Не отправляет сообщения #196

Closed romantonkoshkurov93 closed 1 year ago

romantonkoshkurov93 commented 4 years ago

Доброго времени суток. Я все никак не могу победить эту настройку. У меня уже руки опускаются.

Бота стартовал, группу создал, бота там упомянул и написал ему. В сеттингах вроде тоже все нормально. Что еще ему нужно то? Специально даже создал нового бота и группу.

https://pastebin.com/Pir4uR4a

Screenshot_4 Screenshot_7 Screenshot_8

ableev commented 4 years ago
  1. English
  2. Read the README, you are doing it wrong
  3. Read the wiki in case you think that README is not enough
romantonkoshkurov93 commented 4 years ago

Read the README, you are doing it wrong

I read README several times. He did everything point by point. With the --debug key, you can see that the last message is "/start@rvostok_bot", and then an error where it says that I have to write to the bot group "/start@rvostok_bot". What does it mean? I have not been able to overcome this problem for 3 days.

romantonkoshkurov93 commented 4 years ago

I do not understand anything.

Here is my zbxtg_setting.py: `

-- coding: utf-8 --

tg_key = "923641251:AAFpSM3L5XeMopaMYn_5roGjX1zM9eB1GNQ"  # telegram bot api key

zbx_tg_prefix = "zbxtg"  # variable for separating text from script info
zbx_tg_tmp_dir = "/var/tmp/" + zbx_tg_prefix  # directory for saving caches, uids, cookies, etc.
zbx_tg_signature = False

zbx_tg_update_messages = True
zbx_tg_matches = {
    "problem": "PROBLEM: ",
    "ok": "OK: "
}

zbx_server = "http://xxx.xxx.xxx.xxx/"  # zabbix server full url
zbx_api_user = "tonkoshkurov_r"
zbx_api_pass = "XXXXXXXX"
zbx_api_verify = True  # True - do not ignore self signed certificates, False - ignore

#zbx_server_version = 2  # for Zabbix 2.x version
#zbx_server_version = 3  # for Zabbix 3.x version, by default, not everyone updated to 4.x yet
zbx_server_version = 4  # for Zabbix 4.x version, default will be changed in the future with this

zbx_basic_auth = False
zbx_basic_auth_user = "Admin"
zbx_basic_auth_pass = "zabbix"

proxy_to_zbx = None
proxy_to_tg = None

# proxy_to_zbx = "http://proxy.local:3128"
proxy_to_tg = "http://XXX:XXXX@XXXX:XXXXX"

# proxy_to_tg = "socks5://user1:password2@hostname:port" # socks5 with username and password
# proxy_to_tg = "socks5://hostname:port" # socks5 without username and password
# proxy_to_tg = "socks5h://hostname:port" # hostname resolution on SOCKS proxy. 
                                          # This helps when internet provider alter DNS queries.
                                          # Found here: https://stackoverflow.com/a/43266186/957508

google_maps_api_key = None  # get your key, see https://developers.google.com/maps/documentation/geocoding/intro

zbx_tg_daemon_enabled = False
zbx_tg_daemon_enabled_ids = [462444071, ]
zbx_tg_daemon_enabled_users = ["romantonkoshkurov", ]
zbx_tg_daemon_enabled_chats = ["Р-Восток", ]

zbx_db_host = "localhost"
zbx_db_database = "zabbix"
zbx_db_user = "zabbix"
zbx_db_password = "zabpassword"

emoji_map = {
    "OK": "✅",
    "PROBLEM": "❗",
    "info": "ℹ ️",
    "WARNING": "⚠ ️",
    "DISASTER": "❌",
    "bomb": "",
    "fire": "",
    "hankey": "",
}

`

As stated in README

Send a message to your bot via Telegram, e.g. "/start" done

Screenshot_3

If you are in a group chat, start a conversation with your bot: /start@ZbxTgDevBot done
Screenshot_4

here is my request sudo -u zabbix ./zbxtg.py -367201063 test test --debug --group That's what the console answers zbxtg.py: {'ok': True, 'result': {'id': 923641251, 'is_bot': True, 'first_name': 'Р-Восток БОТ', 'username': 'rvostok_bot', 'can_join_groups': True, 'can_read_all_group_messages': False, 'supports_inline_queries': False}} zbxtg.py: Cache file with uids: /var/tmp/zbxtg/uids.txt zbxtg.py: Trying to read cached uid for -367201063, group, from /var/tmp/zbxtg/uids.txt zbxtg.py: Getting uid from /getUpdates... zbxtg.py: https://api.telegram.org/bot923641251:AAFpSM3L5XeMopaMYn_5roGjX1zM9eB1GNQ/getUpdates zbxtg.py: Content of /getUpdates: zbxtg.py: {"ok": true, "result": [{"update_id": 716207831, "channel_post": {"message_id": 2, "chat": {"id": -1001297713802, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "username": "rvostok", "type": "channel"}, "date": 1580868494, "text": "/start@rvostok_bot", "entities": [{"offset": 0, "length": 18, "type": "bot_command"}]}}, {"update_id": 716207832, "message": {"message_id": 2, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -286829388, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "type": "group", "all_members_are_administrators": true}, "date": 1580869523, "group_chat_created": true}}, {"update_id": 716207833, "message": {"message_id": 3, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -286829388, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "type": "group", "all_members_are_administrators": true}, "date": 1580869533, "text": "/start @rvostok_bot", "entities": [{"offset": 0, "length": 6, "type": "bot_command"}, {"offset": 7, "length": 12, "type": "mention"}]}}, {"update_id": 716207834, "message": {"message_id": 4, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -286829388, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "type": "group", "all_members_are_administrators": true}, "date": 1580869633, "text": "/start@rvostok_bot", "entities": [{"offset": 0, "length": 18, "type": "bot_command"}]}}, {"update_id": 716207835, "message": {"message_id": 5, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -286829388, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "type": "group", "all_members_are_administrators": true}, "date": 1580871803, "left_chat_participant": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "left_chat_member": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}}}, {"update_id": 716207836, "message": {"message_id": 6, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -367201063, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "type": "group", "all_members_are_administrators": true}, "date": 1580871848, "group_chat_created": true}}, {"update_id": 716207837, "message": {"message_id": 7, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -367201063, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "type": "group", "all_members_are_administrators": false}, "date": 1580871982, "migrate_to_chat_id": -1001107066174}}, {"update_id": 716207838, "message": {"message_id": 1, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -1001107066174, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "type": "supergroup"}, "date": 1580871982, "migrate_from_chat_id": -367201063}}, {"update_id": 716207839, "message": {"message_id": 2, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -1001107066174, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "username": "rvostok", "type": "supergroup"}, "date": 1580875598, "text": "/start@rvostok_bot", "entities": [{"offset": 0, "length": 18, "type": "bot_command"}]}}, {"update_id": 716207840, "message": {"message_id": 4, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -1001107066174, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "username": "rvostok", "type": "supergroup"}, "date": 1580875608, "text": "/start @rvostok_bot", "entities": [{"offset": 0, "length": 6, "type": "bot_command"}, {"offset": 7, "length": 12, "type": "mention"}]}}]} zbxtg.py: You need start a conversation with your bot first in '-367201063' group chat, type '/start@rvostok_bot'

Did anyone have such problems, who faced this? Can you help? Maybe I'm doing something wrong? I have not been able to configure for 2 weeks.

romantonkoshkurov93 commented 4 years ago

I wrote "R-Vostok" with the --group switch and it worked. Why? After all, I used to just write chat_id with the --group switch as well. And if the group will be called (OOO "R-Vostok"), then how to send notifications?

Before that, I had a group (OOO "R-Vostok") and I knew chat_id and used ./zbxtg -xxxxxxxx (chat_id) "Test title" "Test message" --group, and everything worked. Therefore, I now tried to do so. Immediately I apologize for my stupidity. Then tell me why now it does not work?

ridwansoursop commented 4 years ago

I do not understand anything.

Here is my zbxtg_setting.py: `

-- coding: utf-8 --

tg_key = "923641251:AAFpSM3L5XeMopaMYn_5roGjX1zM9eB1GNQ"  # telegram bot api key

zbx_tg_prefix = "zbxtg"  # variable for separating text from script info
zbx_tg_tmp_dir = "/var/tmp/" + zbx_tg_prefix  # directory for saving caches, uids, cookies, etc.
zbx_tg_signature = False

zbx_tg_update_messages = True
zbx_tg_matches = {
  "problem": "PROBLEM: ",
  "ok": "OK: "
}

zbx_server = "http://xxx.xxx.xxx.xxx/"  # zabbix server full url
zbx_api_user = "tonkoshkurov_r"
zbx_api_pass = "XXXXXXXX"
zbx_api_verify = True  # True - do not ignore self signed certificates, False - ignore

#zbx_server_version = 2  # for Zabbix 2.x version
#zbx_server_version = 3  # for Zabbix 3.x version, by default, not everyone updated to 4.x yet
zbx_server_version = 4  # for Zabbix 4.x version, default will be changed in the future with this

zbx_basic_auth = False
zbx_basic_auth_user = "Admin"
zbx_basic_auth_pass = "zabbix"

proxy_to_zbx = None
proxy_to_tg = None

# proxy_to_zbx = "http://proxy.local:3128"
proxy_to_tg = "http://XXX:XXXX@XXXX:XXXXX"

# proxy_to_tg = "socks5://user1:password2@hostname:port" # socks5 with username and password
# proxy_to_tg = "socks5://hostname:port" # socks5 without username and password
# proxy_to_tg = "socks5h://hostname:port" # hostname resolution on SOCKS proxy. 
                                        # This helps when internet provider alter DNS queries.
                                        # Found here: https://stackoverflow.com/a/43266186/957508

google_maps_api_key = None  # get your key, see https://developers.google.com/maps/documentation/geocoding/intro

zbx_tg_daemon_enabled = False
zbx_tg_daemon_enabled_ids = [462444071, ]
zbx_tg_daemon_enabled_users = ["romantonkoshkurov", ]
zbx_tg_daemon_enabled_chats = ["Р-Восток", ]

zbx_db_host = "localhost"
zbx_db_database = "zabbix"
zbx_db_user = "zabbix"
zbx_db_password = "zabpassword"

emoji_map = {
  "OK": "✅",
  "PROBLEM": "❗",
  "info": "ℹ ️",
  "WARNING": "⚠ ️",
  "DISASTER": "❌",
  "bomb": "",
  "fire": "",
  "hankey": "",
}

`

As stated in README

Send a message to your bot via Telegram, e.g. "/start" done

Screenshot_3

If you are in a group chat, start a conversation with your bot: /start@ZbxTgDevBot done Screenshot_4

here is my request sudo -u zabbix ./zbxtg.py -367201063 test test --debug --group That's what the console answers zbxtg.py: {'ok': True, 'result': {'id': 923641251, 'is_bot': True, 'first_name': 'Р-Восток БОТ', 'username': 'rvostok_bot', 'can_join_groups': True, 'can_read_all_group_messages': False, 'supports_inline_queries': False}} zbxtg.py: Cache file with uids: /var/tmp/zbxtg/uids.txt zbxtg.py: Trying to read cached uid for -367201063, group, from /var/tmp/zbxtg/uids.txt zbxtg.py: Getting uid from /getUpdates... zbxtg.py: https://api.telegram.org/bot923641251:AAFpSM3L5XeMopaMYn_5roGjX1zM9eB1GNQ/getUpdates zbxtg.py: Content of /getUpdates: zbxtg.py: {"ok": true, "result": [{"update_id": 716207831, "channel_post": {"message_id": 2, "chat": {"id": -1001297713802, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "username": "rvostok", "type": "channel"}, "date": 1580868494, "text": "/start@rvostok_bot", "entities": [{"offset": 0, "length": 18, "type": "bot_command"}]}}, {"update_id": 716207832, "message": {"message_id": 2, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -286829388, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "type": "group", "all_members_are_administrators": true}, "date": 1580869523, "group_chat_created": true}}, {"update_id": 716207833, "message": {"message_id": 3, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -286829388, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "type": "group", "all_members_are_administrators": true}, "date": 1580869533, "text": "/start @rvostok_bot", "entities": [{"offset": 0, "length": 6, "type": "bot_command"}, {"offset": 7, "length": 12, "type": "mention"}]}}, {"update_id": 716207834, "message": {"message_id": 4, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -286829388, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "type": "group", "all_members_are_administrators": true}, "date": 1580869633, "text": "/start@rvostok_bot", "entities": [{"offset": 0, "length": 18, "type": "bot_command"}]}}, {"update_id": 716207835, "message": {"message_id": 5, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -286829388, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "type": "group", "all_members_are_administrators": true}, "date": 1580871803, "left_chat_participant": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "left_chat_member": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}}}, {"update_id": 716207836, "message": {"message_id": 6, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -367201063, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "type": "group", "all_members_are_administrators": true}, "date": 1580871848, "group_chat_created": true}}, {"update_id": 716207837, "message": {"message_id": 7, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -367201063, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "type": "group", "all_members_are_administrators": false}, "date": 1580871982, "migrate_to_chat_id": -1001107066174}}, {"update_id": 716207838, "message": {"message_id": 1, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -1001107066174, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "type": "supergroup"}, "date": 1580871982, "migrate_from_chat_id": -367201063}}, {"update_id": 716207839, "message": {"message_id": 2, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -1001107066174, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "username": "rvostok", "type": "supergroup"}, "date": 1580875598, "text": "/start@rvostok_bot", "entities": [{"offset": 0, "length": 18, "type": "bot_command"}]}}, {"update_id": 716207840, "message": {"message_id": 4, "from": {"id": 462444071, "is_bot": false, "first_name": "Roman", "last_name": "Tonkoshkurov", "username": "romantonkoshkurov", "language_code": "ru"}, "chat": {"id": -1001107066174, "title": "\u0420-\u0412\u043e\u0441\u0442\u043e\u043a", "username": "rvostok", "type": "supergroup"}, "date": 1580875608, "text": "/start @rvostok_bot", "entities": [{"offset": 0, "length": 6, "type": "bot_command"}, {"offset": 7, "length": 12, "type": "mention"}]}}]} zbxtg.py: You need start a conversation with your bot first in '-367201063' group chat, type '/start@rvostok_bot'

Did anyone have such problems, who faced this? Can you help? Maybe I'm doing something wrong? I have not been able to configure for 2 weeks.

i got the same problem

matsuro-hadouken commented 3 years ago

Yes same here group messages not possible to deliver. It works with curl perfectly. Message: _You need start a conversation with your bot first in '-1234567890' group chat, type '/start@namebot' Is incorrect.

P.S. I read all wiki, all telegram channel and watched video presentation on YouTube as well and yes README file to.

shakhzod-alidjan commented 1 year ago

Проблема не решено? У меня тоже такая проблема

ableev commented 1 year ago

The wiki page: https://github.com/ableev/Zabbix-in-Telegram/wiki/How-to-send-message-to-the-group-chat

And it says that you need to put group's name, not the chatid of it.