Problem Description
I’m trying to use this with a Telegram Bot, on a channel, but I can’t make it work, even if
- the channel is created
- the config seems right
- ???
Your Environment
Operating System: Debian 8
Python Version: (use python -V) python 2.7.9
PokemonGo-Map startup command: <cmd>
PokeAlarm startup command: <cmd> python runwebhook.py -L fr
Did the issue persist after restarting the script?: yes
Console Output
PokeAlarm# python runwebhook.py -L fr
2016-09-13 09:28:15,236 [ alarm_manager] [ INFO] You will be notified of the following pokemon:
[...]
2016-09-13 09:28:15,238 [ alarm_manager] [ INFO] Mew (Unl)
2016-09-13 09:28:15,238 [ alarm_manager] [ INFO] Alarm not activated: boxcar because value not set to "True"
2016-09-13 09:28:16,561 [ pushbullet_alarm] [ INFO] Pushing to channel None.
2016-09-13 09:28:16,561 [ pushbullet_alarm] [ INFO] Pushing to channel None.
2016-09-13 09:28:16,562 [ pushbullet_alarm] [ INFO] Pushing to channel None.
2016-09-13 09:28:17,546 [ pushbullet_alarm] [ INFO] Pushbullet Alarm intialized.
2016-09-13 09:28:17,546 [ alarm_manager] [ INFO] Alarm not activated: pushover because value not set to "True"
2016-09-13 09:28:17,546 [ alarm_manager] [ INFO] Alarm not activated: slack because value not set to "True"
2016-09-13 09:28:17,557 [ connectionpool] [ INFO] Starting new HTTPS connection (1): api.telegram.org
Traceback (most recent call last):
File "runwebhook.py", line 93, in <module>
alarm_thread = Alarm_Manager()
File "/var/www/PokeAlarm/alarms/alarm_manager.py", line 61, in __init__
self.alarms.append(Telegram_Alarm(alarm))
File "/var/www/PokeAlarm/alarms/Telegram/telegram_alarm.py", line 53, in __init__
self.client.sendMessage(self.pokemon['chat_id'], 'PokeAlarm activated! We will alert this chat about pokemon.')
File "/usr/local/lib/python2.7/dist-packages/telepot/__init__.py", line 240, in sendMessage
return self._api_request('sendMessage', _rectify(p))
File "/usr/local/lib/python2.7/dist-packages/telepot/__init__.py", line 229, in _api_request
return api.request((self._token, method, params, files), **kwargs)
File "/usr/local/lib/python2.7/dist-packages/telepot/api.py", line 131, in request
return _parse(r)
File "/usr/local/lib/python2.7/dist-packages/telepot/api.py", line 126, in _parse
raise exception.TelegramError(description, error_code, data)
telepot.exception.TelegramError: (u'Forbidden: bot is not a member of the channel chat', 403, {u'error_code': 403, u'ok': False, u'description': u'Forbidden: bot is not a member of the channel chat'})
Your Alarms Config
{
"active": "True",
"type":"telegram",
"chat_id":"@CHANNEL_NAME",
"bot_token":"BOT_TOKEN",
"header":"Un <pkmn> sauvage est apparu !",
"body_text":"<gmaps> n Disponible jusqu'à <24h_time> (<time_left>)."
},
Troubleshooting Checklist
[x] Most recent version of PokemonGo-Map
[x] Most recent version of PokeAlarm
[x] Checked the Wiki page for service in question
I am trying to send a message on a chat on telegram.
I want telegram setups to be done only with the official UI as I want it to be possibly done by by an end user.
Here are telegram setup I do:
- I created the bot
XXXXXXX_botwith Botfather by getting the token: no problem - I created a Channel:
- click «new channel»
- channel name:
TestChannel - click «Next»
- select «Private channel»
- click «Save»
- Add my bot
XXXXXXX_bot - Click «Make admin»
- Click «Save»
- I create the chat:
- open the channel
TestChannel - on the channel menu, select «Manage Channel»
- click on «Add a group» in the discussion
- click on «Create a new group»
- group name:
TestChannelChat - click «Create»
- click «Save»
- open the channel
- I add the bot to the new group:
- open the group
TestChannelChat - on the right panel, I click «add member»
- Add my bot
XXXXXXX_bot - click «Add»
- right click on the newly added user in the chat and select «Promote to admin»
- click «Save»
- open the group
Here is the setup of admins of the channel:

At the end of the day, the setup of the chat/group is the following in the telegram UI:

I make the following http call :
GET https://api.telegram.org/botXXXXXXTOKENXXXXXXX/sendMessage?chat_id=@TestChannelChat&text=coucou
that gives me the following answer:
{
"ok": false,
"error_code": 403,
"description": "Forbidden: bot is not a member of the supergroup chat"
}
I also made the following (to bypass the actual chat and directly publish a message in the channel):
GET https://api.telegram.org/botXXXXXXTOKENXXXXXXX/sendMessage?chat_id=@TestChannel&text=coucou
that gives me the following answer:
{
"ok": false,
"error_code": 403,
"description": "Forbidden: bot is not a member of the channel chat"
}
One simple question, as a bot is also meant to broadcast messages, what part of its setup am I missing?
Приветствую!
Дал боту максимальные права администратора, пытаюсь отправить от его имени
сообщение, попадаю в исключение aiogram.utils.exceptions.Unauthorized: Forbidden: bot is not a member of the channel chat.
Подскажите, пожалуйста, в чем может быть проблема?
russian
programming
aiogram
7
ответов
При этом, бот действительно администратор, соответствующие права есть, айди канала верный.
Перевыдал боту права, все заработало
иногда тг тупит, надо перевыдать боту админку или передобавить в чат
Похожие вопросы
описание проблемы
Я пытаюсь использовать это с ботом Telegram на канале, но не могу заставить его работать, даже если
1) канал создан
2) конфиг вроде правильный
3) ???
Ваша среда
Операционная система: Дебиан 8
Версия Python: (используйте python -V ) Python 2.7.9
Команда запуска PokemonGo-Map: <cmd>
Команда запуска PokeAlarm: <cmd> python runwebhook.py -L fr
Проблема осталась после перезапуска скрипта?: да
Консольный вывод
PokeAlarm# python runwebhook.py -L fr
2016-09-13 09:28:15,236 [ alarm_manager] [ INFO] You will be notified of the following pokemon:
[...]
2016-09-13 09:28:15,238 [ alarm_manager] [ INFO] Mew (Unl)
2016-09-13 09:28:15,238 [ alarm_manager] [ INFO] Alarm not activated: boxcar because value not set to "True"
2016-09-13 09:28:16,561 [ pushbullet_alarm] [ INFO] Pushing to channel None.
2016-09-13 09:28:16,561 [ pushbullet_alarm] [ INFO] Pushing to channel None.
2016-09-13 09:28:16,562 [ pushbullet_alarm] [ INFO] Pushing to channel None.
2016-09-13 09:28:17,546 [ pushbullet_alarm] [ INFO] Pushbullet Alarm intialized.
2016-09-13 09:28:17,546 [ alarm_manager] [ INFO] Alarm not activated: pushover because value not set to "True"
2016-09-13 09:28:17,546 [ alarm_manager] [ INFO] Alarm not activated: slack because value not set to "True"
2016-09-13 09:28:17,557 [ connectionpool] [ INFO] Starting new HTTPS connection (1): api.telegram.org
Traceback (most recent call last):
File "runwebhook.py", line 93, in <module>
alarm_thread = Alarm_Manager()
File "/var/www/PokeAlarm/alarms/alarm_manager.py", line 61, in __init__
self.alarms.append(Telegram_Alarm(alarm))
File "/var/www/PokeAlarm/alarms/Telegram/telegram_alarm.py", line 53, in __init__
self.client.sendMessage(self.pokemon['chat_id'], 'PokeAlarm activated! We will alert this chat about pokemon.')
File "/usr/local/lib/python2.7/dist-packages/telepot/__init__.py", line 240, in sendMessage
return self._api_request('sendMessage', _rectify(p))
File "/usr/local/lib/python2.7/dist-packages/telepot/__init__.py", line 229, in _api_request
return api.request((self._token, method, params, files), **kwargs)
File "/usr/local/lib/python2.7/dist-packages/telepot/api.py", line 131, in request
return _parse(r)
File "/usr/local/lib/python2.7/dist-packages/telepot/api.py", line 126, in _parse
raise exception.TelegramError(description, error_code, data)
telepot.exception.TelegramError: (u'Forbidden: bot is not a member of the channel chat', 403, {u'error_code': 403, u'ok': False, u'description': u'Forbidden: bot is not a member of the channel chat'})
Ваша конфигурация сигналов тревоги
{
"active": "True",
"type":"telegram",
"chat_id":"@CHANNEL_NAME",
"bot_token":"BOT_TOKEN",
"header":"Un <pkmn> sauvage est apparu !",
"body_text":"<gmaps> n Disponible jusqu'à <24h_time> (<time_left>)."
},
Контрольный список устранения неполадок
[x] Самая последняя версия PokemonGo-Map
[x] Самая последняя версия PokeAlarm
[x] Проверил вики-страницу на наличие соответствующего сервиса.
{
"ok": false,
"error_code": 400,
"description": "Bad Request: BOT_SCORE_NOT_MODIFIED"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: CHAT_ADMIN_REQUIRED"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: ENTITY_MENTION_USER_INVALID"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: MESSAGE_ID_INVALID"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: QUERY_ID_INVALID"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: RESULT_TYPE_INVALID"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: USER_ID_INVALID"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: can't demote chat creator"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: can't parse entities in message text: Can't find end of the entity starting at byte offset X"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: can't parse entities in message text: Can't found end tag corresponding to start tag at byte offset X"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: can't parse entities in message text: Expected end tag at byte offset X"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: can't parse entities in message text: Expected equal sign in declaration of attribute of the tag "foo" at byte offset X"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: can't parse entities in message text: Unclosed end tag at byte offset X"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: can't parse entities in message text: Unclosed start tag at byte offset X"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: can't parse entities in message text: Unexpected end of name token at byte offset X"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: can't parse entities in message text: Unexpected end tag at byte offset X"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: can't parse entities in message text: Unmatched end tag at byte offset X, expected "", found"""
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: can't parse entities in message text: Unsupported start tag foo at byte offset X"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: channel members are unavailable"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: chat not found"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: failed to get HTTP URL content"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: have no rights to send a message"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: message can't be edited"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: message can't be forwarded"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: message is not modified"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: message must be non-empty"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: message text is empty"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: message to delete not found"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: message to forward not found"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: reply message not found"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: wrong file identifier/HTTP URL specified"
}
{
"ok": false,
"error_code": 400,
"description": "Bad Request: wrong persistent file_id specified: can't unserialize it. Wrong last symbol"
}
{
"ok": false,
"error_code": 401,
"description": "Unauthorized"
}
{
"ok": false,
"error_code": 403,
"description": "Forbidden: bot can't initiate conversation with a user"
}
{
"ok": false,
"error_code": 403,
"description": "Forbidden: bot can't send messages to bots"
}
{
"ok": false,
"error_code": 403,
"description": "Forbidden: bot is not a member of the supergroup chat"
}
{
"ok": false,
"error_code": 403,
"description": "Forbidden: bot was blocked by the user"
}
{
"ok": false,
"error_code": 403,
"description": "Forbidden: bot was kicked from the group chat"
}
{
"ok": false,
"error_code": 403,
"description": "Forbidden: bot was kicked from the supergroup chat"
}
{
"ok": false,
"error_code": 409,
"description": "Conflict: can't use getUpdates method while webhook is active"
}
{
"ok": false,
"error_code": 429,
"description": "Too Many Requests: retry after X",
"parameters": {
"retry_after": "X"
}
}
Решения вопроса 1
Если ссылка на чат — t.me/your_channel_name, то это должно выглядеть следующим образом:
chat_id=@your_channel_name
Пригласить эксперта
Похожие вопросы
-
Показать ещё
Загружается…
30 янв. 2023, в 00:44
500 руб./за проект
29 янв. 2023, в 22:56
10000 руб./за проект
29 янв. 2023, в 22:48
500 руб./за проект