:)
{ TMyAction }
TMyAction = class(TWebhookAction)
public
constructor Create(ARequest: TBrookRequest; AResponse: TBrookResponse); overload;
override;
procedure Post; override;
end;
Stando alla descrizione della libreria devi modificare qui dentro le configurazioni per poter puntare al tuo bot.
constructor TMyAction.Create(ARequest: TBrookRequest; AResponse: TBrookResponse
);
begin
inherited Create(ARequest, AResponse);
{ This isnt real telegram token! Please get token from
https://core.telegram.org/bots#botfather }
Token:='123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11';
StartText:='Hi! It is simplest HelloBot based on brookframeork and TGBotLazarus!';
HelpText:='This help text for the bot...';
{ Please enter XXXXXX - [your ]user ID (integer value) for availabality of
admin commands (/stat, /statf /terminate)}
UserPermissions.Add('XXXXXX=a');
{ You can do not create this log. If its value is nil,
then the logging just will not be maintained }
StatLogger.Paused:=False; // run statistics log
Logger:=BLogger;
end;
Per il resto è un'applicazione basata su Brook.
;) NoMore ... qui sei più bravo tu
Ciao a tutti,
ho scaricato i sorgenti da qui: https://github.com/Al-Muhandis/fp-telegram
Ho provato a fare girare il progetto di esempio "getMe", impostando il token di un bot creato da me, e funziona.
Il problema è che non ho capito come si usa ....
La mia esigenza è, almeno spero, abbastanza semplice: dovrei solo mandare un messaggio su quel bot creato da me, non mi interessa ricevere e/o gestire risposte.
E' da ieri sera che ci sto provando, ma non ci sono ancora riuscito.
Qualcuno mi sa dare una dritta o un programmino di esempio?
P.S. Non ho provato a scaricare l'altro, quello del framework Brook, perché vorrei fare il tutto usando meno componenti possibile.
Questo è quello che ho provato io:
WrkBot:=TTelegramSender.Create(CstTokenNewsGandiniLodiBot);
try
WrkBot.sendMessage('Prova');
finally
FreeAndNil(WrkBot);
end;
Il risultato è questo errore:
{"ok":false,"error_code":400,"description":"Bad Request: chat not found"}
Grazie in anticipo, Mario
CAsomai servisse ad altri in futuro, ci sono riuscito così:
function InviaMsgBot(TestoMessaggio:String):Boolean;
var WrkBot: TTelegramSender;
begin
Result:=False;
WrkBot:=TTelegramSender.Create(CstTokenNewsGandiniLodiBot);
try
if WrkBot.getMe then begin
WrkBot.getUpdates();
if WrkBot.sendMessage(WrkBot.CurrentChatId, '/start') then begin
if WrkBot.sendMessage(WrkBot.CurrentChatId, TestoMessaggio) then begin
Result:=True;
end;
end;
end;
finally
bmt_LastErrorDescription:=WrkBot.LastErrorDescription;
bmt_LasterrorCode:=WrkBot.LastErrorCode;
FreeAndNil(WrkBot);
end;
end;
Devo però capire perché, delle 3 persone che usano il bot, solo 2 ricevono i messaggi che invio ...
Ciao, Mario