Recently Telegram added support for Topics in Groups in Bot API version 6.3 and this support added into python-telegram-bot version 13.15 (please find changelog https://docs.python-telegram-bot.org/en/stable/changelog.html)
It's not clear how to get a Topic ID (message_thread_id) for topics in Grpups where topics enabeled.
Any suggestion?
I'm trying to find a way how to get topic id for telegram group chats. Please be aware that I talking about message_thread_id, please do not confuse with chat_id.
You can try to get the message_thread_id from the message link
send a message to the topic you need from the application
right click on the sent message and choose "Copy message link"
paste link somewhere
you will see something like this: https://t.me/c/1112223334/25/33
the value 25(value after long number) from the link will be message_thread_id
I assume that -100 + 1112223334 - will be equal chat_id
The number after will be message_thread_id
And the last one should be message_id
I have a bot that I have added to a group. I messages the group to get the group ID from the following:
https://api.telegram.org/bot1856444417:AAH4vG6lkAbFNkM41e4444k-3s42f0-abgs/getUpdates
but I just get the result:
{"ok":true,"result":[]}
I have tried removing the bot and re-addng it and I have tried # the bot but neither gives me a result.
When I originally created the bot I was able to get an ID from a chat I had with it directly but now even that has stopped working.
This method of getting the chatID seems so flakey. Am I doing something wrong or is there any other way to get the chatid?
For anyone having this issue, it is because your bot have the Privacy Group mode enabled.
On BotFather chat, list your created bots and select the respective bot where you to change the Group Privacy setting. Turn it off and there you go, now the result array from Telegram API will be properly displayed.
I got around this by creating another bot, adding it to the group, getting the ID from it and then deleting it.
Use getMe instead of getupdates. It worked for me.
Let's say, I've joined TELEGRAM group...
I am just a typical member of GROUP (and thus, cant use any bots there.. ?) so, I am unable to find out the way, how to get GROUP ID.
New Update
Just Simply Forward a message from your channel to This Bot: (https://telegram.me/getidsbot)
Update
1: Goto (https://web.telegram.org)
2: Goto your Gorup and Find your link of Gorup(https://web.telegram.org/#/im?p=g154513121)
3: Copy That number after g and put a (-) Before That -154513121
4: Send Your Message to Gorup
bot.sendMessage(-154513121, "Hi")
I Tested Now and Work like a Charm
Node.js:
Try using TelegramBot#getChat():
bot.getChat("#channelusername").then(function(chat) {
// 'chat' is a Chat object
console.log(chat.id);
});
See API getChat() method and Chat object.
Hope that helps.
There is a unofficicl Plus Messenger client for Android users, and you can see ID in group/channel info.
Supergroup and Channel will looks like 1068773197, which is -1001068773197 for bots (with -100 prefix).
If you just want to obtain channel/user ID, forward message to #RawDataBot.
there are lots of ways to do so.
simplest one: download plus messenger which is a fork of telegram. it shows every channel's id in the about page of that channel.
https://play.google.com/store/apps/details?id=org.telegram.plus&hl=en
thanks to #Sean:
Supergroup and Channel will looks like 1068773197, which is -1001068773197 for bots (with -100 prefix).
Above method works for channels, for groups you may use this method:
Just forward a single message from that chat to #RawDataBot. it will reply you with a json data containing chatid.
via code:
If you are a member of a group, you should receive updates from that group when ever there is any activity from that group. The updates will contain a chats list-element from which you can get a Channel which has the following relevant fields:
id: group_id,
title: "the_group_title",
username: "group_username"
As of my experience ,there are two popular libraries,
python-Telethon --->Telegram Client Library(uses api_id,api_hash)
python-Telegram-bot ---->Telegram Bot (uses api token)
There are lot of ways to get the user_id ,group_id,channel_id .
To get the these ids use Telethon client library
from telethon import TelegramClient,sync
api_id="xxx" #get from telegram website
api_hash="yyy" #get from telegram website
client=TelegramClient(session_object,api_id,api_hash)
client.start()
#To get the channel_id,group_id,user_id
for chat in client.get_dialogs():
print('name:{0} ids:{1} is_user:{2} is_channel{3} is_group:{4}'.format(chat.name,chat.id,chat.is_user,chat.is_channel,chat.is_group))
That is all about, it will print name and id of channel,group,user.
Also, it will check wheather the id is belong to channel or group or user
generally, Channel id starts with negrative(eg:-1001109500936) starts with (-100)
group id is normal and starts with negative
user id starts with positve
Another way is to use 'plus messanger app'
To see all the group,channel,user id
Cheers
Another Simple Way,
client=TelegramClient(session,api_id,api_hash)
client.start()
destination_entity_name="Type User(may be bot) or group or channel name"
entity=client.get_entity(destination_entity_name)
print(entity.stringify()) #All paratmeters
print(entity.id) #user(bot also considered as user) or group
That should be obtainable using tg-messenger-cli: https://github.com/vysheng/tg I haven't had time to try it out yet but friend has made some automated messages for his daughter. Should be quite versatile.
After hours spent, I was able to find the ID of GROUPS using CuteGram app.
Open group there, and click "COPY" icon, that opens a folder, and in the address you will see the ID.
Invite your bot to your group
and use ur bot to text /myid
then use the GetUpdates api, you shall have your group ID
I'm in a situation in which i need to be able to create a topics using self created bot. My forum has a special category and user, which can create a topics in that category.
Technology i'm using to create that bot is ruby + mechanize gem but it's not important right now. That bot works in a following way:
Sign in as previously mentioned user:
visit - /ucp.php?mode=login
fill the sign-in form using user credentials
if, after submiting a form, there is a sign-out link somewhere on the page, threat this whole process as "successfull"
Create a topic
visit - /posting.php?mode=post&f=21
fill subject field with desired subject
fill message field with desired message
submit a form using Submit button
And now, while first point works just great, the second one behaves in a strange way. After submiting a form, there is no error message or anything like that, i'm just getting redirected to /viewforum.php?f=21 (log's says that it's 302 Moved Temporarily status) page and the topic is not there.
Can anyone tell me what such behaviour means? Is there any security mechanism i don't know about? Please also note that the new topic form has form_token and creation_time fields filled correctly while form is beeing submited.
Thanks in advance for any clues.
According to this thread: https://stackoverflow.com/a/11713867/552936, user is treated as a bot if he sends a form without any delay (and it end's up with a 302 redirect). I can't find any info on google what's the exact delay, carck3r says that it's 8 seconds but for me, it was 2 seconds.
I am trying to run a test on selenium IDE to enter to my Gmail, select the specific new email from all my email enter and click on a specific link that the email has.
I've been going round and round this and cannot find and answer!
I have read another post that has this help:
//div[#class = 'y6']/span[contains(., 'subject here')]
This does not help because the same email has been sent lots of times.
This case has the following particularities:
1. Since is a case that it will be run several times, emails with the same sender, subject and body will be send.
There should only be one new email every time the test is fun, since the idea is to enter and check the last email.
Inside the email there is a button that needed to be press, which I have the id, but I just need to enter the email to do so.
I have used the following CSS that so far has found what i need to click, but when I ask Selenium IDE to click it, it does nothing (clickAt, clickAndWait, clickAtAndWait... nothing!)
css=div[class=yW] > span.zF:[email='myemail#myemail.com']
I have also notice that the class="zA zE" in Gmail indicates that the email has not yet been read.
Help!
Thanks,
This is strange, because clickAt | css=div.yW > span.zF[email='myemail#myemail.com'] works fine for me. More than that, clickAt | css=span[email='myemail#myemail.com'] will always open first message(last one) with this email in the list.
BarbSchael,
A similar solution can be drawn by using Xpath of the FROM field.
I used this command:
clickAt | //table/tbody/tr/td[5]/div[#class='yW'] |
Click at the FROM field of first/recent/top most mail to go to mail detail page. // note: tr for first mail, tr[2] for second and so on.