Skip to content

Commit

Permalink
I forget changes
Browse files Browse the repository at this point in the history
  • Loading branch information
A1Gard committed Dec 16, 2016
1 parent b4d2a41 commit 3de63b5
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 45 deletions.
Binary file added lib/i386-linux/uFileCls.ppu
Binary file not shown.
2 changes: 1 addition & 1 deletion tgbp.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
dateutils,
Process,
// internal classes
uKeyboardCls, uOtherFunctions;
uKeyboardCls, uOtherFunctions, uFileCls;

type

Expand Down
81 changes: 37 additions & 44 deletions tgbp.lps
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,56 @@
<ProjectSession>
<Version Value="9"/>
<BuildModes Active="Default"/>
<Units Count="3">
<Units Count="6">
<Unit0>
<Filename Value="tgbp.lpr"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<TopLine Value="116"/>
<CursorPos Y="132"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="118"/>
<CursorPos X="49" Y="128"/>
<UsageCount Value="23"/>
</Unit0>
<Unit1>
<Filename Value="uKeyboardCls.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="-1"/>
<TopLine Value="-1"/>
<CursorPos X="-1" Y="-1"/>
<UsageCount Value="22"/>
<TopLine Value="49"/>
<CursorPos X="40" Y="47"/>
<UsageCount Value="23"/>
</Unit1>
<Unit2>
<Filename Value="uOtherFunctions.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="22"/>
<CursorPos X="9" Y="50"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="10"/>
<CursorPos X="20" Y="8"/>
<UsageCount Value="23"/>
</Unit2>
<Unit3>
<Filename Value="uFileCls.pas"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="28" Y="8"/>
<UsageCount Value="10"/>
</Unit3>
<Unit4>
<Filename Value="/usr/share/fpcsrc/3.0.0/packages/fcl-process/src/process.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="167"/>
<CursorPos X="10" Y="181"/>
<UsageCount Value="10"/>
</Unit4>
<Unit5>
<Filename Value="/usr/share/fpcsrc/3.0.0/rtl/objpas/classes/classesh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="951"/>
<CursorPos X="3" Y="965"/>
<UsageCount Value="10"/>
</Unit5>
</Units>
<JumpHistory Count="4" HistoryIndex="3">
<Position1>
<Filename Value="tgbp.lpr"/>
<Caret Line="119" Column="11" TopLine="94"/>
</Position1>
<Position2>
<Filename Value="tgbp.lpr"/>
<Caret Line="95" Column="15" TopLine="70"/>
</Position2>
<Position3>
<Filename Value="tgbp.lpr"/>
<Caret Line="67" Column="3" TopLine="119"/>
</Position3>
<Position4>
<Filename Value="tgbp.lpr"/>
<Caret Line="162" TopLine="143"/>
</Position4>
</JumpHistory>
<General>
<ActiveWindowIndexAtStart Value="-1"/>
</General>
<JumpHistory HistoryIndex="-1"/>
</ProjectSession>
<Debugging>
<BreakPoints Count="1">
<Item1>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="tgbp.lpr"/>
<Line Value="132"/>
</Item1>
</BreakPoints>
</Debugging>
</CONFIG>
72 changes: 72 additions & 0 deletions uFileCls.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
unit uFileCls;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils,process;

type
TgFile = class(TObject)
public
constructor Create(tgUrl:String);
function SendFileFromUrl(chat_id,fileUrl,caption:String;var mem: TMemoryStream):Boolean;
function SendFileFromLocation(chat_id,fullAddPath,caption:String;var mem: TMemoryStream):Boolean;
//function
private
var
_TgURL_ : String;
protected

end;

implementation

constructor TgFile.Create(tgUrl:String);
begin
_TgURL_ := tgUrl;
end;



function TgFile.SendFileFromLocation(chat_id,fullAddPath,caption:String;var mem: TMemoryStream):Boolean;
var
r: string;
begin
if RunCommand('/usr/bin/curl', ['-o', ExtractFileDir(ExeName) +
'/catch', _TgURL_ + 'chat_id='+ chat_id + '&caption='+ caption, '-H',
'Content-Type:multipart/form-data','--form','photo=@'+fullAddPath+';type=image/jpeg'],
r) then
begin
mem.LoadFromFile(ExtractFileDir(ExeName) + '/catch');
end;
Result := True;

end;



function TgFile.SendFileFromUrl(chat_id,fileUrl,caption:String;var mem: TMemoryStream):Boolean;
var
r: string;
begin

if RunCommand('/usr/bin/curl', ['-o', ExtractFileDir(ExeName) +
'/tmp', fileUrl, r) then
begin
Result := SendFileFromLocation(chat_id,ExtractFileDir(ExeName) +
'/tmp',caption,mem);
end
else
begin
Result := False;
Exit;
end;
//WriteLn('/usr/bin/curl',['-o',ExtractFileDir(ExeName)+'/catch',url]);

end;

end.


0 comments on commit 3de63b5

Please sign in to comment.