Open paradoxicalNL opened 7 years ago
@paradoxicalNL , try to kick bot from group and invite it again
Kick does not help. I'm able to send message to chat with the curl: curl 'https://api.telegram.org/bot$bot_key/sendMessage?chat_id=$chatid&text=Hello!'
But script always returns mentioned message.
Command line: /usr/share/zabbix/alertscripts/zbxtg.py --group "$chatid" "Test message" "Hello" --debug $chatid is negative integer (e.g. -123456789)
@Perlovka this are no miracles, read README twice, read wiki articles.
Yep, there are no miracles. So I did some debug.
So I did some debug.
Nice.
that is in privacy mode
Which privacy mode? In default configuration you need only mention it. Never saw otherwise.
is just a brilliant idea
Idea comes from zabbix rules for custom media scripts, it has no specific API or something.
https://core.telegram.org/bots#privacy-mode At least for now, bots by default are in privacy mode, so mentioning a bot (sending @BotName) in a group for some reason will not be reflected in getUpdates api call response, thus the script can't found chat id by it's name. If I send a command to the group, I see message in getUpdates response, with group title and id. I'm not so familiar with telegram, so I just created a bot (https://core.telegram.org/bots#3-how-do-i-create-a-bot) and added it to my group. Nothing special.
Idea comes from zabbix rules for custom media scripts, it has no specific API or something.
Usually, options could appear anywhere in command line, they should not be treated as positional parameters in a script. The following command will fail even if there are all needed data in getUpdates response (because name variable in get_uid function will contain '--group'):
./zbxtg.py --group "$chatid" "Test message" "Hello" --debug
but this will work:
./zbxtg.py "$chatid" "Test message" "Hello" --group --debug
There are some handy libraries to do this dirty work ;) https://docs.python.org/3.3/library/argparse.html
it works on this command
./zbxtg.py GroupName “@BotName” “Test Message Here” --group
I had the same issue in a group. I created group, added bot there, setup action in Zabbix and all worked for a month.
Then suddenly messages were gone.
After i removed bot from a group and add it again, the problem was fixed. @ableev how i can avoid these problem in the future?
Changing zbx_tg_tmp_dir to "/var/tmp/" + zbx_tg_prefix
and updating zbxtg.py helped.
Using Zabbix 4.0 is failing (using private cahannel).
The thing is, that Zabbix 4.0 is using "PrivateTmp", so the file gets mapped to /var/tmp/systemd-private-<some_random>-zabbix-server.service-<another random?>
Private channels needs manually hacked uid list. I would pass it as an argument, but the if zbx_to.isdigit()
fails, because the id starts with an -
.
Following the https://github.com/ableev/Zabbix-in-Telegram/wiki/Change-zbx_tg_tmp_dir-in-settings helped :).
I would recommend to split persistant and non-persistant data. uid mapping should (I guess) be in /var/lib/zabbix
, while everything else could be in /tmp
.
Justmy 5 cents :) (its quite late right now :D )
When using Channel ID its mention
You need start a conversation with your bot first in '[CHANNEL ID]' group chat, type '/start@abcbot'.
How to mention start conversation to bot in channel. (Public Channel)
When using Channel ID its mention
You need start a conversation with your bot first in '[CHANNEL ID]' group chat, type '/start@abcbot'.
How to mention start conversation to bot in channel. (Public Channel)
I have the same problem...
@azriomar @execcr , the sending is the same as for regular username.
I do encounter the same issue as well. Either
zbxtg.py: User 'admin' needs to send some text bot in private
or zbxtg.py: You need start a conversation with your bot first in '' group chat, type '/start@zabbix2231Bot'
No idea on how to resolve it I do check on Youtube which they are using Ubuntu to setup Telegram Notification but I am using CentOS, suppose no issue on that. Just curious the issue is persist on my side
Work perfectly when use @username or groupname in media\action\send to:
First of all, great work on these scripts. Love using them, but i'm having the same issue or simular.
At first, all works fine. We receive alerts and graphs in telegram (group where bot is member of), but after some period of not sending alerts (we don't send many), we have to re-initiate the bot for some reason. This message appears in Zabbix:
You need start a conversation with your bot first in '[CHANNEL ID]' group chat, type '/start@abcbot'.
Any idea how we can permanently activate the bot?
First of all, great work on these scripts. Love using them, but i'm having the same issue or simular.
At first, all works fine. We receive alerts and graphs in telegram (group where bot is member of), but after some period of not sending alerts (we don't send many), we have to re-initiate the bot for some reason. This message appears in Zabbix:
You need start a conversation with your bot first in '[CHANNEL ID]' group chat, type '/start@abcbot'.
Any idea how we can permanently activate the bot?
I have the same error. I have been strugling with the problem for one week. I couldn't solve it also. I use Zabbix 5.2.2 version. Could it be regarding to the zabbix version?
I found how to fix this!
Is has to do with this parameter: zbx_tg_tmp_dir
. It has to be a directory where Zabbix has write access. The script tries to write the ID of the telegram-group to a tmp file. If it can't do that, it relies on the cache on the telegram server side which runs out after X couple of days.
I changed the zbx_tg_tmp_dir
to zabbix home folder /var/lib/zabbix
and now it is able to write it's local cache file and it keeps on working (for several months allready).
I had the same problem, resolve this with replace 'channel' to 'group' in line https://github.com/ableev/Zabbix-in-Telegram/blob/master/zbxtg.py#L797
Not sure about the fix, but it worked for me right away.
I had the same problem, resolve this with replace 'channel' to 'group' in line https://github.com/ableev/Zabbix-in-Telegram/blob/master/zbxtg.py#L797
Not sure about the fix, but it worked for me right away.
It`s work for me
I had the same problem, resolve this with replace 'channel' to 'group' in line https://github.com/ableev/Zabbix-in-Telegram/blob/master/zbxtg.py#L797 Not sure about the fix, but it worked for me right away.
It`s work for me
It works for me too. I can recommend it as fix. Thank you partizanes
Hi everyone! I had some problem: "You need start a conversation with your bot first in 'name group chat' group chat, type '/start@company_bot
I fix this problem to add uids telegram groups or peaple into the file /var/tmp/zbxtg/uids.txt on zabbix server: example: cat /var/tmp/zbxtg/uids.txt GroupName;group;-387654322 UserName;private;823456781
So I have worked with this script before - and it worked perfectly!
For some reason, all I get is: 'You need to mention your bot in 'username' group chat (i.e. type @YourBot)'. I (of course) mentioned the bot in the group chat, that did not help. I re-registered the bot, disabled privacy mode, nothing seems to help.. Any ideas what I might be doing wrong, or some recent update to Telegram?
So the steps:
Create bot, fill in API key in zbxtg_settings.py Create a group channel and add bot to it
Test group functionality with '--group' (test without the --group param works):