telegram bot

telegram bot

Postby Sistem » Wed Jun 19, 2019 11:41 pm

https://www.youtube.com/watch?time_cont ... JBYojK7DO4

Code: Select all  Expand view
Function Telegram()
 Local oDlg, oFont, oFont2, lEnvia:=.f., cMsg:=Space(500), cUrl, aArray, oHost, oBtn, oSay, x1
 Local cToken := "AQUI COLOQUE SEU TOKEN", cChat_id := "AQUI CHAT ID"
 Local xMsg := "*AQUI SUA MSG*%0A"+;
               "MAIS MSG%0A"

  DEFINE FONT oFont  NAME "Lucida Console" SIZE 0,-14
  DEFINE FONT oFont2 NAME "Lucida Console" SIZE 0,-10

  DEFINE DIALOG oDlg FROM 4, 4 TO 8, 90 TITLE "msg p/bot Telegram"

  @  4,  6 GET oMsg VAR cMsg PIXEL OF oDlg COLOR CLR_BLACK,CLR_WHITE SIZE 290, 16 FONT oFont CUEBANNER "Sua mensagem aqui"

  @ 4, 300 BUTTON "Enviar" PIXEL OF oDlg SIZE 34, 16 ACTION (lEnvia:=.t., oDlg:End())

  oDlg:lHelpIcon := .f.

 ACTIVATE DIALOG oDlg CENTERED

  If lEnvia .and. !Empty(cMsg)
     cUrl := "https://api.telegram.org/bot"+cToken+"/sendMessage?chat_id="+cChat_id+"&parse_mode=Markdown&text="+xMsg+cMsg
     Try
         oHost := CreateObject( 'MSXML2.ServerXMLHTTP.6.0' )
     Catch erro
         ? erro:Description
         return nil
     End

     oHost:open('GET', cUrl, .f.)
     oHost:send()

     If oHost:Status != 200
        MsgStop(Alltrim(STR(oHost:Status))+" - "+oHost:StatusText , "Erro")
        Return nil
     Endif

     While oHost:readyState != 4
        oHost:WaitForResponse(1000)
     End

     x1 := hb_jsondecode( oHost:responseText, @aArray )

     If aArray == nil
         MsgStop("Erro ao retornar os dados. Tente novamente.")
         Return nil
     Endif

     If aArray['ok'] = .f.
       MsgStop("Erro no envio da messagem.", "Aviso!")
     Else
       MsgInfo("Sucesso no envio da messagem.", "Aviso!")
     Endif
  Endif

Return nil

group fivewin brasil
https://t.me/fivewinbr
group fivewin espanha
https://t.me/fivewines
FWH2008 | xHarbour | BCC74 | SQLRDD
User avatar
Sistem
 
Posts: 226
Joined: Sun May 13, 2012 7:52 am

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: carlos vargas and 32 guests