Skip to content

Commit 3d425ef

Browse files
committed
Merge branch 'release/3.4.0'
# Conflicts: # README.md # Source/TelegAPI.Utils.Params.pas # Source/TelegAPi.Helpers.pas # Source/TelegAPi.Types.pas
2 parents bd87de4 + 81d62a0 commit 3d425ef

File tree

8 files changed

+499
-234
lines changed

8 files changed

+499
-234
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.3.1",
15+
"version": "3.4.0",
1616
"first_version": "2.3.1",
1717
"project_url": "https://github.com/ms301/TelegAPI",
1818
"homepage_url": "https://t.me/telegaPiBotTest",

Install/TelegaPiBot.dpk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ contains
4848
TelegAPI.Utils.Json in '..\Source\TelegAPI.Utils.Json.pas',
4949
TelegAPI.Bot.Recesiver in '..\Source\TelegAPI.Bot.Recesiver.pas',
5050
TelegAPI.Utils.Converters in '..\Source\TelegAPI.Utils.Converters.pas',
51-
TelegAPI.Utils in '..\Source\TelegAPI.Utils.pas';
51+
TelegAPI.Utils in '..\Source\TelegAPI.Utils.pas',
52+
TelegAPi.Ext.Planer in '..\Source\TelegAPi.Ext.Planer.pas';
5253

5354
end.
5455

Install/TelegaPiBot.dproj

Lines changed: 183 additions & 184 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Telega π - Library for working with Telegram Bot API in Delphi
44

5-
Version Bot API: *3.3.1*
5+
Version Bot API: *3.4.0*
66

77
## Support project
88

@@ -33,7 +33,7 @@ as well as many others who ask / suggest features / points bugs.
3333

3434
Telega π - Библиотека для работы с Telegram Bot API в Delphi
3535

36-
Версия Bot API: *3.3.1*
36+
Версия Bot API: *3.4.0*
3737

3838
## Помощь проекту
3939

@@ -53,7 +53,9 @@ Telega π - Библиотека для работы с Telegram Bot API в Delp
5353
[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5ASFXPC68MS2U)
5454

5555
## Боты, работающие на TelegaPi
56-
* [🤖ChallengeOfTheDay](https://t.me/cotdbot?start=245903278)
56+
57+
* [🤖ChallengeOfTheDay](https://goo.gl/4TbFH9)
58+
5759

5860
## Зависимости
5961

Source/TelegAPI.Bot.pas

Lines changed: 244 additions & 26 deletions
Large diffs are not rendered by default.

Source/TelegAPi.Ext.Planer.pas

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
unit TelegAPi.Ext.Planer;
2+
3+
interface
4+
5+
uses
6+
System.SysUtils;
7+
8+
type
9+
TTimeAction = class
10+
private
11+
FOnAction: TProc;
12+
published
13+
property OnAction: TProc read FOnAction write FOnAction;
14+
end;
15+
16+
implementation
17+
18+
end.
19+

Source/TelegAPi.Helpers.pas

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ TtgTMultipartFormDataHelper = class helper for TMultipartFormData
4040
/// file name: "File.ext"
4141
/// </param>
4242
procedure AddStream(const AFieldName: string; Data: TStream; const AFileName: string = '');
43-
4443
end;
4544

4645
TtgMessageHelper = class helper for TTgMessage
@@ -99,25 +98,31 @@ function TAllowedUpdatesHelper.ToString: string;
9998

10099
{ TtgTMultipartFormDataHelper }
101100

101+
102102
procedure TtgTMultipartFormDataHelper.AddStream(const AFieldName: string; Data: TStream; const AFileName: string);
103103
var
104-
lFileName: string;
105-
LFileStream: TFileStream;
104+
LFileStream : TFileStream;
105+
LTmpDir : string;
106+
LTmpFilename : string;
106107
begin
107-
if AFieldName.IsEmpty then
108-
lFileName := TPath.GetTempFileName
109-
else
110-
lFileName := TPath.Combine(TPath.GetTempPath, AFieldName);
108+
//get filename for tmp folder e.g. ..\AppData\local\temp\4F353A8AC6AB446D9F592A30B157291B
109+
LTmpDir := IncludeTrailingPathDelimiter(TPath.GetTempPath)+TPath.GetGUIDFileName(false);
110+
LTmpFilename := IncludeTrailingPathDelimiter(LTmpDir)+ExtractFileName(AFileName);
111111
try
112-
LFileStream := TFileStream.Create(lFileName, fmCreate);
112+
TDirectory.CreateDirectory(LTmpDir);
113113
try
114-
LFileStream.CopyFrom(Data, 0);
114+
LFileStream := TFileStream.Create(LTmpFilename, fmCreate);
115+
try
116+
LFileStream.CopyFrom(Data, 0);
117+
finally
118+
LFileStream.Free;
119+
end;
120+
AddFile(AFieldName, LTmpFilename);
115121
finally
116-
LFileStream.Free;
122+
TFile.Delete(LTmpFilename);
117123
end;
118-
AddFile(AFieldName, lFileName);
119124
finally
120-
TFile.Delete(lFileName);
125+
TDirectory.Delete(LTmpDir);
121126
end;
122127
end;
123128

Source/TelegAPi.Types.pas

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,20 @@ TtgChat = class
244244
/// </summary>
245245
[djName('pinned_message')]
246246
PinnedMessage: TTgMessage;
247+
/// <summary>
248+
/// Optional. For supergroups, name of Group sticker set. Returned only
249+
/// in <see cref="TelegAPI.Bot|TTelegramBot.GetChat(TValue)">getChat</see>
250+
/// .
251+
/// </summary>
252+
[djName('sticker_set_name')]
253+
StickerSetName: string;
254+
/// <summary>
255+
/// Optional. True, if the bot can change group the sticker set. Returned
256+
/// only in <see cref="TelegAPI.Bot|TTelegramBot.GetChat(TValue)">getChat</see>
257+
/// .
258+
/// </summary>
259+
[djName('can_set_sticker_set')]
260+
CanSetStickerSet: Boolean;
247261
end;
248262

249263
/// <summary>
@@ -824,6 +838,12 @@ TTgMessage = class
824838
[djName('entities')]
825839
Entities: TObjectList<TtgMessageEntity>;
826840
/// <summary>
841+
/// Optional. For messages with a caption, special entities like
842+
/// usernames, URLs, bot commands, etc. that appear in the caption
843+
/// </summary>
844+
[djName('caption_entities')]
845+
CaptionEntities: TObjectList<TtgMessageEntity>;
846+
/// <summary>
827847
/// Optional. Message is an audio file, information about the file
828848
/// </summary>
829849
[djName('audio')]
@@ -1061,7 +1081,6 @@ TtgFileToSend = class
10611081
Content: TStream;
10621082
constructor Create(const AFileName: string); overload;
10631083
constructor Create(AContent: TStream; const AFileName: string = ''); overload;
1064-
destructor Destroy; override;
10651084
end;
10661085

10671086
/// <summary>
@@ -1633,14 +1652,15 @@ constructor TtgFileToSend.Create(AContent: TStream; const AFileName: string);
16331652
begin
16341653
FileName := AFileName;
16351654
Content := AContent;
1655+
//I guess, in most cases, AFilename param should contain a non-empty string.
1656+
//It is odd to receive a file with filename and
1657+
//extension which both are not connected with its content.
1658+
if AFileName.IsEmpty then
1659+
raise Exception.Create('TtgFileToSend: Filename is empty!');
16361660
if not Assigned(AContent) then
16371661
raise EStreamError.Create('Stream not assigned!');
1638-
end;
1639-
1640-
destructor TtgFileToSend.Destroy;
1641-
begin
1642-
FreeAndNil(Content);
1643-
inherited;
1662+
FileName := AFileName;
1663+
Content := AContent;
16441664
end;
16451665

16461666
{ TtgGame }
@@ -1713,6 +1733,7 @@ destructor TTgMessage.Destroy;
17131733
FreeAndNil(Contact);
17141734
FreeAndNil(Document);
17151735
FreeAndNil(Entities);
1736+
FreeAndNil(CaptionEntities);
17161737
FreeAndNil(ForwardFrom);
17171738
FreeAndNil(ForwardFromChat);
17181739
FreeAndNil(ForwardFromChat);

0 commit comments

Comments
 (0)