'How To Obtain Username/chatname of a telegram group With Python-Telegram-Bot?

I'm Creating A Telegram Bot Using Python-Telegram-Bot I need to know the group username or chatname so that I can code such a way to my bot only work in my group. How do I get a group username or chatname using python? I just do like this let's say my Telegram group name 'A'

if chatname=='A':
     #do something

let's say my Telegram group username @abc

if usename=='abc':
       #do something

Is there any way to get a group username or chatname in python telebot?



Solution 1:[1]

update.message.chat.title

This will return Title, for supergroups, channels and group chats

Solution 2:[2]

There are two things at play here: Operator precedence and Order of expression-evaluation. Operator precedence in case of << is left-to-right. The Order of evaluation was not defined in previous versions of the compiler; now it is.

As described in this excellent answer, the Order of evaluation is now compatible with Operator precedence, which means it happens left-to-right:

  1. cout << "Res = " happens first. The << operator returns an instance of cout itself.
  2. Then cout << get_input() happens, at which point in time get_input is called. ...and so on.

It used to differ based on the compiler, but now it's standardized.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Паван Викаситха
Solution 2 Sudeep Prasad