Skip to content

Commit 83b62dd

Browse files
committed
/delete command for file manager
and new deb version
1 parent 4a0f1ab commit 83b62dd

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ DefaultDir=
5757
3. Run as a console program or daemon/service.
5858

5959
### DEB package
60-
You can easily install using a .deb file on Debian/Ubuntu/etc.
60+
You can easily install/upgrade using a .deb file on Debian/Ubuntu/etc.
61+
62+
#### installation with deb
6163
Download deb package from release section https://github.com/Al-Muhandis/ShellRemoteBot/releases
6264
Then install for example:
63-
``` BASH
64-
sudo dpkg --install tgshd_1.2.4-1_amd64.deb
65+
```SH
66+
sudo dpkg --install tgshd_1.2.5-2_amd64.deb
6567
# After package installation set up at least token and admin user id in the INI file located at /etc/tgshd/tgshd.ini
6668
# for example with Nano editor
6769
sudo nano /etc/tgshd/tgshd.ini
@@ -70,6 +72,14 @@ sudo nano /etc/tgshd/tgshd.ini
7072
systemctl enable tgshd
7173
systemctl start tgshd
7274
```
75+
#### Upgrade with deb
76+
77+
```SH
78+
sudo systemctl stop tgshd
79+
sudo dpkg --install tgshd_1.2.5-2_amd64.deb
80+
sudo systemctl daemon-reload
81+
systemctl start tgshd
82+
```
7383

7484
## Users rights and telegram user ID
7585
You can define user access in configuration file `tgshd.ini` by adding string like `user_id=a` where user_id is telegram user id of administrator.
@@ -91,6 +101,8 @@ Calls the menu for executing the prepared script from the list of files. Scripts
91101
or you can set the folder in the settings in the the `[Scripts]` section / `Directory`
92102
### /dir
93103
Calls the file Manager. You can set the default value in the configuration file
104+
### /delete
105+
With the command (`/delete` `/fullpath/to/file`) You can delete file
94106

95107
## Possible problems
96108

deb.staging/DEBIAN/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: tgshd
22
Priority: optional
3-
Version: 1.2.1.4-1
3+
Version: 1.2.5.1-2
44
Maintainer: Renat Suleymanov <[email protected]>
55
Architecture: amd64
66
Section: utils

src/shellthread.pas

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ TShellThread=class(TThread)
2121
FProc: TProcess;
2222
FTerminated: Boolean;
2323
FLPTimeout: Integer;
24-
procedure BotReceiveCallbackQuery({%H-}ASender: TObject; ACallback: TCallbackQueryObj);
24+
procedure BotReceiveCallbackQuery({%H-}ASender: TObject; ACallback: TCallbackQueryObj);
25+
procedure BotReceiveDeleteCommand({%H-}ASender: TObject; const {%H-}ACommand: String;
26+
AMessage: TTelegramMessageObj);
2527
procedure BotReceiveMessage({%H-}ASender: TObject; AMessage: TTelegramMessageObj);
2628
function BotReceiveDocument(aDocument: TTelegramDocument; const aPath: String): Boolean;
2729
{ Read output from shell terminal by command }
@@ -89,11 +91,13 @@ implementation
8991
_ScriptFileExt='.script';
9092

9193
emj_FileFolder='📁';
94+
emj_Wrnng='⚠️';
9295

9396
dt_script='script';
9497
dt_dir='dir';
9598
dt_file='file';
96-
dt_input='input';
99+
dt_input='input';
100+
dt_dlt='delete';
97101

98102

99103
{ TShellThread }
@@ -183,6 +187,22 @@ procedure TShellThread.BotReceiveCallbackQuery(ASender: TObject; ACallback: TCal
183187
end;
184188
end;
185189

190+
procedure TShellThread.BotReceiveDeleteCommand(ASender: TObject; const ACommand: String; AMessage: TTelegramMessageObj);
191+
var
192+
aPath: String;
193+
begin
194+
if not CommandStart then
195+
Exit;
196+
aPath:=ExtractDelimited(2, AMessage.Text, [' ']);
197+
if aPath.IsEmpty then
198+
FBot.sendMessage('Use command line format like /delete `/path-to-the-file/file-name.ext`', pmMarkdown)
199+
else
200+
if DeleteFileUTF8(aPath) then
201+
FBot.sendMessage(Format('File (%s) succesfully deleted', [aPath]))
202+
else
203+
FBot.sendMessage(emj_Wrnng+' '+Format('File (%s) deletion error', [aPath]))
204+
end;
205+
186206
procedure TShellThread.BotReceiveReadCommand(ASender: TObject;
187207
const ACommand: String; AMessage: TTelegramMessageObj);
188208
begin
@@ -481,7 +501,8 @@ constructor TShellThread.Create;
481501
FBot.CommandHandlers['/sigkill']:=@BotReceiveSIGKILLCommand;
482502
FBot.CommandHandlers['/sigquit']:=@BotReceiveSIGQUITCommand;
483503
FBot.CommandHandlers['/sigterm']:=@BotReceiveSIGTERMCommand;{$ENDIF}
484-
FBot.CommandHandlers['/'+dt_dir]:=@BotReceiveFileCommand;
504+
FBot.CommandHandlers['/'+dt_dir]:=@BotReceiveFileCommand;
505+
FBot.CommandHandlers['/'+dt_dlt]:=@BotReceiveDeleteCommand;
485506
FBot.OnReceiveCallbackQuery:=@BotReceiveCallbackQuery;{$IFDEF MSWINDOWS}
486507
SetConsoleOutputCP(CP_UTF8);{$ENDIF}
487508
FBot.ServiceUser:=Cnfg.ServiceUser;

src/tgshd.lpi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
<AutoIncrementBuild Value="True"/>
2121
<MajorVersionNr Value="1"/>
2222
<MinorVersionNr Value="2"/>
23-
<RevisionNr Value="2"/>
24-
<BuildNr Value="1"/>
23+
<RevisionNr Value="5"/>
24+
<BuildNr Value="3"/>
2525
</VersionInfo>
2626
<BuildModes Count="4">
2727
<Item1 Name="Default" Default="True"/>

0 commit comments

Comments
 (0)