Skip to content

Commit da4ee94

Browse files
committed
Merge branch 'release/3.5.0'
2 parents afe1f3a + 583068b commit da4ee94

36 files changed

+7150
-8927
lines changed

Delphinus.Info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": [],
1313
"author": "M.E.Sysoev",
1414
"description": "Telegram Bot API for Delphi",
15-
"version": "3.4.1",
15+
"version": "3.5.0",
1616
"first_version": "2.3.1",
1717
"project_url": "https://github.com/ms301/TelegAPI",
1818
"homepage_url": "https://t.me/telegaPiBotTest",

Demo/Console/ConsoleBot.dpr

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,56 @@
11
program ConsoleBot;
22

33
{$APPTYPE CONSOLE}
4-
54
{$R *.res}
65

76
uses
87
TelegAPI.Bot,
9-
TelegAPI.Bot.Recesiver.Console,
8+
Rest.Json,
9+
TelegAPI.Recesiver.Console,
10+
System.SysUtils,
1011
TelegAPI.Types,
11-
System.SysUtils;
12+
TelegAPI.Types.Impl;
1213

1314
procedure Main;
1415
var
15-
LBot: TTelegramBot;
16-
LRecesiver: TTgBotRecesiverConsole;
16+
LBot: ITelegramBot;
17+
LRecesiver: TtgRecesiverConsole;
1718
LStop: string;
1819
begin
19-
LBot := TTelegramBot.Create(nil);
20-
LBot.Token := {$I ..\token.inc};
21-
LRecesiver := TTgBotRecesiverConsole.Create(nil);
22-
LRecesiver.Bot := LBot;
20+
LBot := CreateTelegramBot('283107814:AAF9VZC6TRv6qKmOMCsLFoI8SBlV_xFMI80');
21+
LRecesiver := TtgRecesiverConsole.Create(LBot);
2322
try
23+
LRecesiver.OnStart :=
24+
procedure
25+
begin
26+
Writeln('started');
27+
end;
28+
LRecesiver.OnStop :=
29+
procedure
30+
begin
31+
Writeln('stoped');
32+
end;
2433
LRecesiver.OnMessage :=
25-
procedure(AMessage: TTgMessage)
34+
procedure(AMessage: ITgMessage)
2635
begin
2736
Writeln(AMessage.From.Username, ': ', AMessage.Text);
37+
LBot.SendMessage(AMessage.Chat.ID, AMessage.Text);
2838
end;
2939
with LBot.GetMe do
3040
begin
3141
Writeln('Bot nick: ', Username);
32-
Free;
3342
end;
34-
LRecesiver.IsReceiving := True;
43+
LRecesiver.IsActive := True;
3544
while LStop.ToLower.Trim <> 'exit' do
45+
begin
3646
Readln(LStop);
47+
if LStop.ToLower.Trim = 'stop' then
48+
LRecesiver.IsActive := False
49+
else if LStop.ToLower.Trim = 'start' then
50+
LRecesiver.IsActive := True;
51+
end;
3752
finally
3853
LRecesiver.Free;
39-
LBot.Free;
4054
end;
4155
end;
4256

@@ -46,7 +60,8 @@ begin
4660
Main;
4761
except
4862
on E: Exception do
49-
Writeln(E.ClassName, ': ', E.Message);
63+
Writeln(E.ClassName, ': ', E.message);
5064
end;
65+
5166
end.
5267

0 commit comments

Comments
 (0)