generated from pavel.muhortov/template-bash
	added Telegram chat topics support
This commit is contained in:
		
							parent
							
								
									bc2498addd
								
							
						
					
					
						commit
						b06619e6a0
					
				|  | @ -237,7 +237,8 @@ wp_user_pass = pass | |||
| wp_update_page_id = 4848  | ||||
| # | ||||
| # Optionality you can enable or disable publishing by Telegram: | ||||
| #   true - Wordpress enabled, false - Telegram disbaled. | ||||
| #   true - Telegram enabled, false - Telegram disbaled. | ||||
| tg_enabled = true | ||||
| tg_api_key = TELEGRAM_API_KEY | ||||
| tg_chat_id = @blackhole | ||||
| tg_chat_id = @blackhole | ||||
| #tg_chat_id = -100123456789_123 | ||||
|  | @ -2771,6 +2771,9 @@ class Telegram: | |||
|                 "parse_mode": parse_mode, | ||||
|                 "disable_notification": True | ||||
|                 } | ||||
|             if '_' in chat: | ||||
|                 data["chat_id"] = chat.split('_')[0] | ||||
|                 data["message_thread_id"] = chat.split('_')[1] | ||||
|             response = requests.post(url=url, json=data, timeout=15) | ||||
|             if response.status_code == 200: | ||||
|                 response = response.json() | ||||
|  | @ -2857,7 +2860,12 @@ class Telegram: | |||
|                 media_type == 'video' or | ||||
|                 media_type == 'audio' | ||||
|             ): | ||||
|                 if '_' in chat: | ||||
|                     thrd = chat.split('_')[1] | ||||
|                     chat = chat.split('_')[0] | ||||
|                 url = self.api_path + '/send' + media_type + '?chat_id=' + chat | ||||
|                 if thrd: | ||||
|                     url = url + '?message_thread_id=' + thrd | ||||
|             else: | ||||
|                 raise ValueError("'media_type' value is wrong: " + media_type) | ||||
| 
 | ||||
|  | @ -3074,6 +3082,9 @@ class Telegram: | |||
|                 'media': json.dumps(group), | ||||
|                 "disable_notification": disable_notification | ||||
|                 } | ||||
|             if '_' in chat: | ||||
|                 data["chat_id"] = chat.split('_')[0] | ||||
|                 data["message_thread_id"] = chat.split('_')[1] | ||||
| 
 | ||||
|             response = requests.post(url=url, data=data, files=files, timeout=300) | ||||
|             if response.status_code == 200: | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user