Skip to content

Commit

Permalink
Merge branch 'release/3.5.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
MAXIM-SYSOEV\WorkPC committed May 21, 2018
2 parents c226296 + 1d3bb88 commit b19cbe6
Show file tree
Hide file tree
Showing 42 changed files with 4,912 additions and 2,650 deletions.
2 changes: 1 addition & 1 deletion Delphinus.Info.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": [],
"author": "Maxim Sysoev",
"description": "Telegram Bot API for Delphi",
"version": "3.5.4",
"version": "3.5.5",
"first_version": "2.3.1",
"project_url": "https://github.com/ms301/TelegAPI",
"homepage_url": "https://t.me/telegaPiBotTest",
Expand Down
57 changes: 25 additions & 32 deletions Demo/Console/ConsoleBot.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@

{/$DEFINE USE_INDY_CORE}
uses
{$IFDEF USE_INDY_CORE}
//Indy Http Core
{$IFDEF USE_INDY_CORE} //Indy Http Core
CrossUrl.Indy.HttpClient,
{$ELSE}
// System.Net HTTP Core
{$ELSE} // System.Net HTTP Core
CrossUrl.SystemNet.HttpClient,
{$ENDIF}

Expand All @@ -19,16 +17,11 @@ uses
TelegAPI.Bot,
TelegAPI.Types,
TelegAPI.Bot.Impl,
TelegAPI.Exceptions;
TelegAPI.Logger,
TelegAPI.Logger.Old;

procedure SMG(ABot: ITelegramBot; AMessage: ITgMessage);
var
Test: TtgInputMediaPhoto;
begin
Test := TtgInputMediaPhoto.Create(TtgFileToSend.FromFile('D:\Repositories\Мои проекты\ms301-TelegAPI\Install\pJNqeRflXYU.png'),
'Test');
ABot.sendMediaGroup(AMessage.Chat.ID, [Test, Test])
end;
const
TOKEN = 'YOUR_TOKEN';

procedure Main;
var
Expand All @@ -37,24 +30,25 @@ var
LExcp: TtgExceptionManagerConsole;
LStop: string;
begin
LBot := TTelegramBot.Create('YOUR_TOKEN',
{$IFDEF USE_INDY_CORE}
TcuHttpClientIndy.Create(nil)
{$ELSE}
TcuHttpClientSysNet.Create(nil)
{$ENDIF});
{$IFDEF USE_INDY_CORE}
LBot := TTelegramBot.Create(TOKEN, TcuHttpClientIndy.Create(nil));
{$ELSE}
LBot := TTelegramBot.Create(TOKEN, TcuHttpClientSysNet.Create(nil));
{$ENDIF}
LReceiver := TtgReceiverConsole.Create(LBot);
LBot.Logger := TtgExceptionManagerConsole.Create(nil);
try
LExcp := LBot.ExceptionManager as TtgExceptionManagerConsole;
LExcp.OnApiException :=
procedure(AMethod: string; AExp: EApiRequestException)
begin
Writeln(AExp.ToString);
end;
LExcp.OnGlobalException :=
procedure(AMethod: string; AExp: Exception)
LExcp := LBot.Logger as TtgExceptionManagerConsole;
LExcp.OnLog :=
procedure(level: TLogLevel; msg: string; e: Exception)
begin
Writeln(AExp.ToString);
if level >= TLogLevel.Error then
begin
if Assigned(e) then
Writeln('[' + e.ToString + '] ' + msg)
else
Writeln(msg);
end;
end;
LReceiver.OnStart :=
procedure
Expand All @@ -70,8 +64,7 @@ begin
procedure(AMessage: ITgMessage)
begin
Writeln(AMessage.From.ID, ': ', AMessage.Text);
// LBot.SendMessage(AMessage.From.ID, AMessage.Text);
SMG(LBot, AMessage);
LBot.SendMessage(AMessage.From.ID, AMessage.Text);
end;
Writeln('Bot nick: ', LBot.GetMe.Username);
LReceiver.IsActive := True;
Expand All @@ -93,8 +86,8 @@ begin
{ TODO -oUser -cConsole Main : Insert code here }
Main;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.message);
on e: Exception do
Writeln(e.ClassName, ': ', e.message);
end;

end.
Expand Down
Loading

0 comments on commit b19cbe6

Please sign in to comment.