Skip to content

Commit

Permalink
Merge branch 'release/3.4.0'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	Source/TelegAPI.Utils.Params.pas
#	Source/TelegAPi.Helpers.pas
#	Source/TelegAPi.Types.pas
  • Loading branch information
rareMaxim committed Oct 11, 2017
2 parents bd87de4 + 81d62a0 commit 3d425ef
Show file tree
Hide file tree
Showing 8 changed files with 499 additions and 234 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": "M.E.Sysoev",
"description": "Telegram Bot API for Delphi",
"version": "3.3.1",
"version": "3.4.0",
"first_version": "2.3.1",
"project_url": "https://github.com/ms301/TelegAPI",
"homepage_url": "https://t.me/telegaPiBotTest",
Expand Down
3 changes: 2 additions & 1 deletion Install/TelegaPiBot.dpk
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ contains
TelegAPI.Utils.Json in '..\Source\TelegAPI.Utils.Json.pas',
TelegAPI.Bot.Recesiver in '..\Source\TelegAPI.Bot.Recesiver.pas',
TelegAPI.Utils.Converters in '..\Source\TelegAPI.Utils.Converters.pas',
TelegAPI.Utils in '..\Source\TelegAPI.Utils.pas';
TelegAPI.Utils in '..\Source\TelegAPI.Utils.pas',
TelegAPi.Ext.Planer in '..\Source\TelegAPi.Ext.Planer.pas';

end.

367 changes: 183 additions & 184 deletions Install/TelegaPiBot.dproj

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

Version Bot API: *3.3.1*
Version Bot API: *3.4.0*

## Support project

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

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

Версия Bot API: *3.3.1*
Версия Bot API: *3.4.0*

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

Expand All @@ -53,7 +53,9 @@ Telega π - Библиотека для работы с Telegram Bot API в Delp
[![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)

## Боты, работающие на TelegaPi
* [🤖ChallengeOfTheDay](https://t.me/cotdbot?start=245903278)

* [🤖ChallengeOfTheDay](https://goo.gl/4TbFH9)


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

Expand Down
270 changes: 244 additions & 26 deletions Source/TelegAPI.Bot.pas

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions Source/TelegAPi.Ext.Planer.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
unit TelegAPi.Ext.Planer;

interface

uses
System.SysUtils;

type
TTimeAction = class
private
FOnAction: TProc;
published
property OnAction: TProc read FOnAction write FOnAction;
end;

implementation

end.

29 changes: 17 additions & 12 deletions Source/TelegAPi.Helpers.pas
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ TtgTMultipartFormDataHelper = class helper for TMultipartFormData
/// file name: "File.ext"
/// </param>
procedure AddStream(const AFieldName: string; Data: TStream; const AFileName: string = '');

end;

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

{ TtgTMultipartFormDataHelper }


procedure TtgTMultipartFormDataHelper.AddStream(const AFieldName: string; Data: TStream; const AFileName: string);
var
lFileName: string;
LFileStream: TFileStream;
LFileStream : TFileStream;
LTmpDir : string;
LTmpFilename : string;
begin
if AFieldName.IsEmpty then
lFileName := TPath.GetTempFileName
else
lFileName := TPath.Combine(TPath.GetTempPath, AFieldName);
//get filename for tmp folder e.g. ..\AppData\local\temp\4F353A8AC6AB446D9F592A30B157291B
LTmpDir := IncludeTrailingPathDelimiter(TPath.GetTempPath)+TPath.GetGUIDFileName(false);
LTmpFilename := IncludeTrailingPathDelimiter(LTmpDir)+ExtractFileName(AFileName);
try
LFileStream := TFileStream.Create(lFileName, fmCreate);
TDirectory.CreateDirectory(LTmpDir);
try
LFileStream.CopyFrom(Data, 0);
LFileStream := TFileStream.Create(LTmpFilename, fmCreate);
try
LFileStream.CopyFrom(Data, 0);
finally
LFileStream.Free;
end;
AddFile(AFieldName, LTmpFilename);
finally
LFileStream.Free;
TFile.Delete(LTmpFilename);
end;
AddFile(AFieldName, lFileName);
finally
TFile.Delete(lFileName);
TDirectory.Delete(LTmpDir);
end;
end;

Expand Down
35 changes: 28 additions & 7 deletions Source/TelegAPi.Types.pas
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,20 @@ TtgChat = class
/// </summary>
[djName('pinned_message')]
PinnedMessage: TTgMessage;
/// <summary>
/// Optional. For supergroups, name of Group sticker set. Returned only
/// in <see cref="TelegAPI.Bot|TTelegramBot.GetChat(TValue)">getChat</see>
/// .
/// </summary>
[djName('sticker_set_name')]
StickerSetName: string;
/// <summary>
/// Optional. True, if the bot can change group the sticker set. Returned
/// only in <see cref="TelegAPI.Bot|TTelegramBot.GetChat(TValue)">getChat</see>
/// .
/// </summary>
[djName('can_set_sticker_set')]
CanSetStickerSet: Boolean;
end;

/// <summary>
Expand Down Expand Up @@ -824,6 +838,12 @@ TTgMessage = class
[djName('entities')]
Entities: TObjectList<TtgMessageEntity>;
/// <summary>
/// Optional. For messages with a caption, special entities like
/// usernames, URLs, bot commands, etc. that appear in the caption
/// </summary>
[djName('caption_entities')]
CaptionEntities: TObjectList<TtgMessageEntity>;
/// <summary>
/// Optional. Message is an audio file, information about the file
/// </summary>
[djName('audio')]
Expand Down Expand Up @@ -1061,7 +1081,6 @@ TtgFileToSend = class
Content: TStream;
constructor Create(const AFileName: string); overload;
constructor Create(AContent: TStream; const AFileName: string = ''); overload;
destructor Destroy; override;
end;

/// <summary>
Expand Down Expand Up @@ -1633,14 +1652,15 @@ constructor TtgFileToSend.Create(AContent: TStream; const AFileName: string);
begin
FileName := AFileName;
Content := AContent;
//I guess, in most cases, AFilename param should contain a non-empty string.
//It is odd to receive a file with filename and
//extension which both are not connected with its content.
if AFileName.IsEmpty then
raise Exception.Create('TtgFileToSend: Filename is empty!');
if not Assigned(AContent) then
raise EStreamError.Create('Stream not assigned!');
end;

destructor TtgFileToSend.Destroy;
begin
FreeAndNil(Content);
inherited;
FileName := AFileName;
Content := AContent;
end;

{ TtgGame }
Expand Down Expand Up @@ -1713,6 +1733,7 @@ destructor TTgMessage.Destroy;
FreeAndNil(Contact);
FreeAndNil(Document);
FreeAndNil(Entities);
FreeAndNil(CaptionEntities);
FreeAndNil(ForwardFrom);
FreeAndNil(ForwardFromChat);
FreeAndNil(ForwardFromChat);
Expand Down

0 comments on commit 3d425ef

Please sign in to comment.