Jump to content

Recommended Posts

On ‎06‎.‎01‎.‎2017 at 1:10 PM, Jos said:

I took one of the examples posted by trancexx and modified it to the below alternative UDF for SendPhoto:

#include <WinHttp.au3>

;~ ConsoleWrite("Test _SendMsg      -> "  & @TAB & _SendMsg($ChatID,"Test _SendMsg") & @CRLF)
;~ ConsoleWrite("Test _SendPhoto    -> " & @TAB & _SendPhoto($ChatID, "d:\temp\image.jpg", "Test _SendPhoto") & @CRLF)
ConsoleWrite("Test _SendPhoto    -> " & @TAB & _SendPhotoN($ChatID, "d:\temp\image.jpg", "Test _SendPhoto") & @CRLF)


; @SEND MEDIA FUNCTION using WINHTTP ================================================================================
Func _SendPhotoN($ChatID, $Path, $Caption = "")
    Local $Query = $URL & '/sendPhoto'
    $sForm = _
            '<form action="' & $Query & '" method="post" enctype="multipart/form-data">' & _
            ' <input type="text" name="chat_id"/>' & _
            ' <input type="file" name="photo"/>' & _
            ' <input type="text" name="caption"/>' & _
            '</form>'

    ; Initialize and get session handle
    $hOpen = _WinHttpOpen()
    $hConnect = $sForm ; will pass form as string so this is for coding correctness because $hConnect goes in byref
    ; Register callback function
    _WinHttpSimpleFormFill_SetUploadCallback(UploadCallback)
    ; Fill form
    $sHTML = _WinHttpSimpleFormFill($hConnect, $hOpen, _
            Default, _
            "name:chat_id", $ChatID, _
            "name:photo", $Path, _
            "name:caption", $Caption)
    ; Collect error number
    $iErr = @error
    ; Unregister callback function
    _WinHttpSimpleFormFill_SetUploadCallback(0)
    ; Kill progress bar window
    ; Close handles
    _WinHttpCloseHandle($hConnect)
    _WinHttpCloseHandle($hOpen)

    If $iErr Then
        MsgBox(4096, "Error", "Error number = " & $iErr)
        ConsoleWrite("! error:" & $iErr & @CRLF & $sHTML & @CRLF)
    Else
        ConsoleWrite($sHTML & @CRLF)
    EndIf
    Return $iErr

EndFunc   ;==>_SendPhotoN

This is working nicely for me :)

Jos

Hi jos thank you for your modifications for this udf but i'm still having the problem  when I try to send pictures or files ... but now with your udf I've an error 4..do you have a idea?? thank you for your help

mas

Share this post


Link to post
Share on other sites
1 hour ago, maskat said:

Hi jos thank you for your modifications for this udf but i'm still having the problem  when I try to send pictures or files ... but now with your udf I've an error 4..do you have a idea?? thank you for your help

mas

I've found the problem it came from our proxy... I tried your script with a conneciotn without proxy it' works perfectly thank you

Share this post


Link to post
Share on other sites

I downloaded telegram UDF files from github.  I ran the sample code and most telegram functions failed.

Only the "send message" working well , the others such as send audio/image/video.... all failed.

I don't know what's wrong. Could some give me suggestion?

note: I used autoit v3.3.14.5

Share this post


Link to post
Share on other sites

@karson_chan, you have to do better than that for anybody to be able to help you!
If it works on one PC, it should also work on the other given the files are on the exact same place.
So what about you show what you are doing by sharing the script etc?

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

@Jos

Actually all 5 pc is in same setting using same WiFi ssid. Firewall is off. Running in windows 10 64 bit. Using Autoit v3.3.14.5. 

Is there need to some setting i forgot?  i feel strange too. why only one pc work for me. It is just a simply script to test.

here are the script i am tesing: 

 

 

#include "../Telegram.au3"
$Token = '1111111:aaaaaaaaaaaaaaaaaaaavsog9RO4' ;owen2
$ChatID = '412777023' ;owen2

_InitBot($Token)

_SendPhoto($ChatID,'image.png',"This is a photo5.")
 

Edited by Jos

Share this post


Link to post
Share on other sites

I removed part of the token assuming you do not want to share that and have others using your bot! 
Are you getting any errors?
are you sure the file image.png is available in the default directory?

Jos 


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Yes. image.png is available in same floder

Now I try to run Test.au3 inside test floder. The script spend arround 2 mins to run. Because every false status take arround 20-30 seconds. 

here is the capture sceen 

2018-09-26_100537.png

Share this post


Link to post
Share on other sites

Hello

I've downloaded telegram UDF files from github. It works perfect, but I can only send messages to private chats and groups, not to channels. I get the chatid's with the web telegram, as explained in https://github.com/GabrielRF/telegram-id, but it doesn't work. Do you know if there is any limitation with channels? Or am I doing something wrong?

Thks

Share this post


Link to post
Share on other sites
21 hours ago, Gespo said:

I've found the solution. I had to include the bot in the administrators of the channel

 

 

Share this post


Link to post
Share on other sites

When adding my bot to any channel - cant recieve any messages :(( 

log gives like this:

MSG#-1001195506482# - testbot: 
MSG#-1001195506482# - testbot: 
MSG#-1001195506482# - testbot: 
MSG#-1001195506482# - testbot: 
MSG#477888592# - Johnnie: test
MSG#477888592# - Johnnie: -301864711Хьюстон
MSG#477888592# - Johnnie: -301864711Хьюстон
MSG#271673891# - Denis: -301864711Хьюстон
MSG#271673891# - Denis: -301864711Хьюстон

 

Bot source look like this:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Cryply.ico
#AutoIt3Wrapper_UseUpx=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include "../Telegram.au3"
#include <Inet.au3>
#include <Array.au3>
#include <String.au3>
#include <StringConstants.au3>

HotKeySet("{PAUSE}","_Exit") ;Press 'PAUSE' on your keyboard to force-exit the script

$Token = '558290450:AAFEAM2pfNr7j0IFME-nJTBfCNeiuNNaAmE' ;Insert here your token
_InitBot($Token)


;-------------------------------------- %0A
Global $price = ""
Global $status = ""
Global $lowhigh = ""
Global $altprice = ""
;-------------------------------------- %0A


While 1
    $msgData = _Polling()
   ;;;;; ConsoleWrite("Incoming message from " & $msgData[3] & ": " & $msgData[5] & @CRLF)
   ;TrayTip($msgData[3]," user: " & $msgData[5],0)
    ;_SendMsg($msgData[2],$msgData[5]) <<<< https://youtu.be/30g356XW-nQ

    FileWrite(@ScriptDir&"\Cryply.log","MSG#"& $msgData[2] &"# - " & $msgData[4] & ": " & $msgData[5] & $msgData[6] & $msgData[7] & @CRLF)

if StringInStr($msgData[5],"!test" ) or StringInStr($msgData[5],"!тест") Then ;--------------------------------------
_SendMsg($msgData[2],"Works fine...")
endif

if StringInStr($msgData[5],"!admin") or StringInStr($msgData[5],"!author") or StringInStr($msgData[5],"!about") or StringInStr($msgData[5],"!автор") or StringInStr($msgData[5],"!админ") Then ;--------------------------------------
_SendMsg($msgData[2],"Неофициальный Крипли Бот v1.2 %0AАвтор Johnnie Walker %0AЕ-мейл: xbitnik@gmail.com")
endif

if StringInStr($msgData[5],"!mining") or StringInStr($msgData[5],"!майнинг") Then ;--------------------------------------
_SendMsg($msgData[2],"Обучающее видео по майнингу для новичков:%0A https://youtu.be/30g356XW-nQ")
endif

if StringInStr($msgData[5],"!moon") or StringInStr($msgData[5],"!tothemoon") or StringInStr($msgData[5],"/moon") or StringInStr($msgData[5],"/tothemoon") or StringInStr($msgData[5],"/themoon") Then ;--------------------------------------
_SendMsg($msgData[2],"If you want CRYPLY to the moon, start doing something. Anyone can help and every donat is important to us :) И Я, конечно, ни на что не намекаю... ")
endif

if StringInStr($msgData[5],"!links") or StringInStr($msgData[5],"!gettingstarted") or StringInStr($msgData[5],"!ссылки") or StringInStr($msgData[5],"!urls") Then ;--------------------------------------
_SendMsg($msgData[2],"" & _
"Сайт: https://cryply.io"& _
"%0AФорум: https://bitcointalk.org/index.php?topic=2634468.0;all"& _
"%0AОбменник: https://crex24.com/ru/exchange/CRP-BTC"& _
"%0AСтаты: https://www.coingecko.com/en/price_charts/cryply/usd"& _
"%0A%0AКошельки: https://goo.gl/gfx5Xv"& _
"%0AМайнеры: https://goo.gl/rb2zRb"& _
"%0AПулы: https://cryply.luckypool.org  и  https://p2pool.work%0A%0A")

endif


if StringInStr($msgData[5],"!info" ) or StringInStr($msgData[5],"!инфо") or StringInStr($msgData[5],"/start") Then ;-------------------------------------- ;"%0A!stats / !статы - полезная статистика манетки"& _
_SendMsg($msgData[2],"Список доступнык комманд: " & _
"%0A!info / !инфо - данная справка"& _
"%0A!links / !ccылки - ссылки на полезные ресурсы"& _
"%0A!price / !цена - текущая цена манетки"& _
"%0A!mining / !майнинг - майнинг видео для новичков"& _
"%0A!author / !автор - контактные данные автора")
endif


if StringInStr($msgData[5],"!time") or StringInStr($msgData[5],"!время") Then ;--------------------------------------
_SendMsg($msgData[2],"The time is: "&@HOUR&":"&@MIN&":"&@SEC)
endif


if StringInStr($msgData[5],"!price") or StringInStr($msgData[5],"!цена") Then ;--------------------------------------

$Text = _INetGetSource('https://coinlib.io/coin/CRP/Cryply',true)

$source = _StringBetween($Text, "$&nbsp;"," </span>")
If Not @error Then
    $price = "$ "&$source[0]
Else
$price = "?"
endif

$source = _StringBetween($Text, 'id="coin-price-delta">','</span>')
If Not @error Then
    $status = StringReplace($source[0],@LF,"")
Else
$status = "?"
endif

$source = _StringBetween($Text, 'coin-high-low">',' </div>')
If Not @error Then
    $lowhigh = StringReplace(StringReplace($source[0],"&nbsp;"," "),@LF,"")
Else
$lowhigh = "?"
endif

$source = _StringBetween($Text, 'price text-left pl-2">BTC','</span>')
If Not @error Then
    $altprice = StringReplace($source[0],@LF,"")
Else
$altprice = "?"
endif

;MsgBox(0,"Price",$price)
;MsgBox(0,"Status",$status)
;MsgBox(0,"LowHigh",$lowhigh)
;MsgBox(0,"ALtprice","BTC "&$altprice)
_SendMsg($msgData[2], "" _
&"Цена крипли в USD: "&StringStripWS($price,8) _
&"%0AЦена крипли в BTC: "&StringStripWS($altprice,8) _
&"%0AУровни за сутки: "&StringStripWS($lowhigh,8)&@CRLF _
&"%0AРейтинг: "&StringStripWS($status,8) _
&"%0AЗа 1000 CRP вы получите: "&StringStripWS(StringReplace($price,"$ ",""),8)*1000&" $")

;_SendMsg($msgData[2],"Cryply rate: "&$status)
;_SendMsg($msgData[2]," - - - - - - - - - - - ")
;_SendMsg($msgData[2],"10 Cryply = "&StringReplace($price,"$ ","")*10)
;_SendMsg($msgData[2],"50 Cryply = "&StringReplace($price,"$ ","")*50)
;_SendMsg($msgData[2],"100 Cryply = "&StringReplace($price,"$ ","")*100)
;_SendMsg($msgData[2],"1000 Cryply = "&StringReplace($price,"$ ","")*1000)
;_SendMsg($msgData[2],"1500 Cryply = "&StringReplace($price,"$ ","")*1500)
;_SendMsg($msgData[2],"2000 Cryply = "&StringReplace($price,"$ ","")*2000)
;_SendMsg($msgData[2],"5000 Cryply = "&StringReplace($price,"$ ","")*5000)
;_SendMsg($msgData[2],"10000 Cryply = "&StringReplace($price,"$ ","")*10000)
;_SendMsg($msgData[2]," - - - - - - - - - - - ")
;_SendMsg($msgData[2],"Stats based on coinlib.io/coin/CRP/Cryply")
endif





;--------------------------------------------------------------------------

WEnd

Func _Exit()
    Exit 0
EndFunc

 

 

Please HELP !

Edited by Enforcer

[RU] Zone

Share this post


Link to post
Share on other sites

Probably you already solved the problem, anyway... you must change the privacy on the botFather, like explained in this quote from stackoverflow:

Quote

Sequence within a BotFather chat:

You: /setprivacy

BotFather: Choose a bot to change group messages settings.

You: @your_name_bot

BotFather: 'Enable' - your bot will only receive messages that either start with the '/' symbol or mention the bot by username.

'Disable' - your bot will receive all messages that people send to groups.

Current status is: ENABLED

You: Disable

BotFather: Success! The new status is: DISABLED. /help

 

Share this post


Link to post
Share on other sites

I was trying to edit a previously sent message with a Photo with SendPhoto(), with a new photo with this Func:

Func _editMessageMedia($ChatID, $Message_id, $Path, $Reply_markup = Default )
    Local $Query = $URL & '/editMessageMedia'
    Local $hOpen = _WinHttpOpen()
    Local $Form = '<form action="' & $Query & '" method="post" enctype="multipart/form-data">' & _
                  '<input type="text" name="chat_id"/>' & _
                  '<input type="text" name="message_id"/>' & _
                  '<input type="file" name="photo"/>' & _
                  '<input type="text" name="caption"/>'
    If $Reply_markup <> Default Then $Form &= '<input type="text" name="reply_markup"/>'
    $Form &= '</form>'
    Local $Response = _WinHttpSimpleFormFill($Form,$hOpen,Default, _
                       "name:chat_id", $ChatID, _
                       "name:message_id", $Message_id, _
                       "name:photo"  , $Path,   _
                       "name:caption", "", _
                       "name:reply_markup", $Reply_markup)

    _WinHttpCloseHandle($hOpen)
    Local $Json = Json_Decode($Response)
    ConsoleWrite("RES:" & $Response & " ______ " & $Json &  @CRLF)
    If Not (Json_IsObject($Json)) Then Return SetError(2,0,False) ;Check if json is valid
    Return __GetFileID($Json,'photo')
EndFunc ;==> _editMessageMedia

$Message_id is on the JSON answer of polling with _GetUpdates(). 

I use like this uploading a pic from the pc:

_editMessageMedia($ChatID, $telegramMsgData[7] , $sPath & $nomeFile, $ikeyb )

and I get this error:

{"ok":false,"error_code":400,"description":"Bad Request: can't parse InputMedia: Media is not specified"}

Share this post


Link to post
Share on other sites

thank you for the UDF.

but it seems like im having an issue.

Test file for Telegram UDF by LinkOut. (https://github.com/xLinkOut)
This file need a valid ChatID of a Telegram User to send messages to and a valid bot token given by BotFather.
Insert this data in the source code.

! Initializing bot... True

Who am I? Oh, yeah, my name is Project-X, you can find me at @Ray_ProjectXBot. For developers, my Telegram ID is xxxxxxxx
Let's do some test:
    Sending a simple text message. The function _SendMsg return the Message ID: False
    Now I'll forward the same message to you, with the message id saved before: False
    Awesome. Use the other _Send functions to send photos, videos, documents. Each function return the FileID assigned by Telegram.
!       Sending photo: 0
!       Sending video: 
!       Sending audio: 
!       Sending documents: 
!       Sending voice: 
!       Sending sticker: 
!       Sending video note: 
!       Sending location: False
!       Sending contact: False

You can send a 'Chat Action', that mean the user see 'Bot is typing...' or 'Bot is sending a photo...'.

To use a custom keyboard, there is an useful function that contruct and encode the keyboard itself.
You have to create an array and insert the text of your buttons. To line break, leave a position empty. 
Example, try to pass this array $keyboard[4] = ['TopLeft','TopRight','','SecondRow'] to the _CreateKeyboard function, then send the message.

In encoded format, the $keyboard look like {"keyboard":[["TopLeft","TopRight"],["SecondRow"]]}
I'll send this keyboard to you as this: _SendMsg($ChatID,'Hey! Choose one:',Default,$markup)
_CreateKeyboard function accept two other boolean args, resize and one time keyboard, both false by default.

This is all folks! For all the other methods read the Telegram Documentation and the Telegram.au3 file, it's commented. You can find some examples in the example folder.
Don't forget to ? star this repo on GitHub, this mean a lot for me.+>01:54:58 AutoIt3.exe ended.rc:0

any idea?

Share this post


Link to post
Share on other sites
9 hours ago, Raywando said:

but it seems like im having an issue.

Great ....  care to share details in case you want assistance with that issue? :) 

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
4 hours ago, Jos said:

Great ....  care to share details in case you want assistance with that issue? :) 

Jos

im not really sure what info you need exactly, but i only modified the test.au3, put my token which i got from @BotFather and added my ChatID which i got from @get_id_bot 

when i try the url below i get 

{"ok":true,"result":[]}

idk if that helps but i thought it might.

https://api.telegram.org/bot<MyBotToken>/getUpdates

if there is anything else i need to share please let me know.

Share this post


Link to post
Share on other sites

You must create a chat, i.e. a group, get the chat_id and insert into the autoit prog, then insert the bot as a member of that group. Then you can send your messages with the bot or receive the msg from the group.

With getUpdates to see something, you must first send a msg into that group in which there is your bot.

Edited by frank10

Share this post


Link to post
Share on other sites
On 3/2/2019 at 7:13 PM, frank10 said:

You must create a chat, i.e. a group, get the chat_id and insert into the autoit prog, then insert the bot as a member of that group. Then you can send your messages with the bot or receive the msg from the group.

With getUpdates to see something, you must first send a msg into that group in which there is your bot.

thank you

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Colduction
      Hi guys, i'm using Telegram UDF by @LinkOut from github with latest update, but this UDF has not any parse_mode ability in SendDocument and other send file's functions to make texts bold, italic or underline and i can't send Emojis via these functions too. i've tried to change HTML section of multipart/form-data but i did not get correct results.

      For example, i can't get correct results by sending a document with this URL Encoded caption: %F0%9F%93%84%20*Test*%20%F0%9F%93%84

      I will be happy to help me in this section. Thanks!
    • By pat4005
      A tiny UDF that can shoot magic packets at your computers to wake them the heck up. All credits to Olish.
      The only parameter it needs to be specified – is your machine's MAC-address (ip address (the second parameter), at which you will be sending magic packet is generating automatically from @IPAddress1 macro)
      Example:
      _WoL_WakeDevice('001CC0CAED7A') ; the second parameter (if necessery) must be a broadcast address of your local network segment (i.e. 192.168.0.255 for a network 192.168.0.0)  
      _WakeOnLan.au3
    • By MrCreatoR
      This UDF allows to create formatted label using pseudo element RichLabel (RichEdit actually). Formating is set by using special modificator similar to <font> tag in Html.
      Notes: This UDF is a transformation-continuation of related UDF


      Example:
      Download:
      GUIRichLabel_1.2.zip
      Small syntax related fix: GUIRichLabel_1.1.zip
      GUIRichLabel_1.1.zip
       
      History version:
    • By Stormgrade
      Hello,
      I'm searching the UDF GDIpProgress.au3 from ProgAndy
      None of the links in topic
       works
      Can't someone upload it please ?
×
×
  • Create New...