Answer the question
In order to leave comments, you need to log in
How to get the number of the last post in a telegram channel?
Good evening.
Faced such a problem, how can I get the id of the last post in the telegram channel?
The api has a getUpdates method, but to get information with this method, you need to add your bot to the channel administrators with which the desired channel will be parsed.
Are there any other options? without adding a bot to administrators
Answer the question
In order to leave comments, you need to log in
No. Bots cannot parse other people's channels. And the getUpdates method doesn't work the way you'd expect. It only returns NEW posts that seem to be unread by the bot, but not the ID of the last post in the channel.
dim xmlhttp
set xmlhttp = createobject("msxml2.xmlhttp")
function getlastpostnumber2(channel, num)
on error resume next
dim chhref
dim pos
dim cyphers
dim pos1
dim symcnt
dim z
dim wi
const sl = "/"
cyphers = "1234567890"
pos = 1
getlastpostnumber2 = num
with xmlhttp
.open "get", "https://t.me/s/" & channel, false
.send
while pos > 0
pos = instr(pos, .responsetext, channel & sl)
chhref = ""
if pos > 0 then
pos1 = pos + len(channel) + 1
symcnt = pos1
while instr(cyphers, mid(.responsetext, symcnt, 1)) > 0
if err <> 0 then exit function
chhref = chhref & mid(.responsetext, symcnt, 1)
symcnt = symcnt + 1
wend
end if
if pos > 0 then
pos = pos + 1
getlastpostnumber2 = chhref
end if
wend
end function
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question