<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Telegram bot API]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16624&amp;type=atom" />
	<updated>2021-09-29T07:39:03Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16624</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Telegram bot API]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149789#p149789" />
			<content type="html"><![CDATA[<p>Справился сам, однако сам текст не выводится: <span class="postimg"><img src="https://i.imgur.com/ScuAcEN.png" alt="https://i.imgur.com/ScuAcEN.png" /></span><br /></p><div class="codebox"><pre><code>#include json.ahk					; include to process JSON strings as objects

token := &quot;токен&quot;

q::		; press q to get updates
update := GetUpdates(token, , 1)				; limit result to 1 message
oUpd := JSON.Load(update)		; load JSON response string as an AHK object
msgbox % update

return

Esc::ExitApp

GetUpdates(botToken, offset=&quot;&quot;, updlimit=100, timeout=0){							
	If (updlimit&gt;100)
		updlimit := 100
	; Offset = Identifier of the first update to be returned.
	url := &quot;https://api.telegram.org/bot&quot; botToken &quot;/getupdates?offset=&quot; offset &quot;&amp;limit=&quot; updlimit &quot;&amp;timeout=&quot; timeout
	updjson := URLDownloadToVar(url)					
	return updjson
}

URLDownloadToVar(url,ByRef variable=&quot;&quot;){			
	try
	{	
		hObject:=ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
		hObject.Open(&quot;GET&quot;,url)
		hObject.Send()
		variable:=hObject.ResponseText
		return variable
	}
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[AterEX]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39925</uri>
			</author>
			<updated>2021-09-29T07:39:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149789#p149789</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Telegram bot API]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149787#p149787" />
			<content type="html"><![CDATA[<p>Тогда лучше в той теме и спросили бы. Здесь я не припомню, чтобы кто-то этим занимался.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-09-28T19:31:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149787#p149787</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Telegram bot API]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149786#p149786" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>Скрипт для отправки сообщений я сделал по исходникам, исходник для чтения сообщений я нашел, но он у меня не работает, плюс этот уровень кодинга довольно выше моего, соответственно я не все понимаю: https://www.autohotkey.com/boards/viewtopic.php?f=76&amp;t=42031#p192355</p>]]></content>
			<author>
				<name><![CDATA[AterEX]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39925</uri>
			</author>
			<updated>2021-09-28T18:46:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149786#p149786</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Telegram bot API]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149785#p149785" />
			<content type="html"><![CDATA[<p>Если сумели написать скрипт для отправки сообщений, в чём проблема написать для чтения?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-09-28T18:01:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149785#p149785</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Telegram bot API]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149784#p149784" />
			<content type="html"><![CDATA[<p>Приветствую. Я сделал скрипт, который заставляет писать бота в телеграм, как мне сделать так,&nbsp; чтобы бот мог читать мои сообщения через ахк?<br /></p><div class="codebox"><pre><code> bot_token := &quot;токен&quot;
            Global chat_id := чат ид
            Global msg_api := Format(&quot;https://api.telegram.org/bot{1}/sendMessage&quot;, bot_token)
            
            PostMsg(clipboard)
            
            PostMsg(msg_text)
            {
                WinHttpObj := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
                WinHttpObj.Open(&quot;POST&quot;, msg_api)
                WinHttpObj.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0&quot;)
                WinHttpObj.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/json; charset=UTF-8&quot;)
                mJson := Format(&quot;{ &quot;&quot;chat_id&quot;&quot;: &quot;&quot;{1}&quot;&quot;, &quot;&quot;text&quot;&quot;: &quot;&quot;{2}&quot;&quot;, &quot;&quot;parse_mode&quot;&quot; : &quot;&quot;{3}&quot;&quot; }&quot;, chat_id, msg_text, parse_mode)
                WinHttpObj.Send(mJson)
            }</code></pre></div>]]></content>
			<author>
				<name><![CDATA[AterEX]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39925</uri>
			</author>
			<updated>2021-09-28T17:49:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149784#p149784</id>
		</entry>
</feed>
