Skip to content

Commit

Permalink
feat: Version command
Browse files Browse the repository at this point in the history
  • Loading branch information
gcarreno committed Dec 9, 2024
1 parent 10c0ecf commit 4de4492
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The initial idea is to have all the logging of the `IRC` channel dumped into a `

Not sure if it's worth having the bot itself serve the website, but due to the fact that `SQLite` will be locked during the bot's operation, then this will have to be the path, for the time being.

# Usage
## Usage

```console
$ paslogbot -h
Expand All @@ -37,4 +37,8 @@ PARAMS:
-h/--help This help message.
-c/--config=FILE Use provided FILE as config. ( default: ~/.pasirclogbot )
-d/--debug Turn debug On. (default: Off)
```
```

## About the author

I'm usually on `irc.libera.chat` on the `#objectpascal`, `#lazarus` and `#pascal` channels. On `IRC` I use the nick name `[Batch]`.
16 changes: 16 additions & 0 deletions src/bot/irclogbot.bot.pas
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ TIRCLogBot = class(TObject)
ATarget, AMessage: String);

procedure Help(const ATarget: String);
procedure Version(const ATarget: String);
procedure Replay(const ATarget: String; ACount: Integer);
protected
public
Expand Down Expand Up @@ -140,6 +141,11 @@ procedure TIRCLogBot.OnPrivateMessage(ASender: TIdContext; const ANickname,
Help(ANickname);
exit;
end;
if Pos('.version', Trim(AMessage)) = 1 then
begin
Version(ANickname);
exit;
end;
if Pos('.replay', Trim(AMessage)) = 1 then
begin
strings:= AMessage.Split([' ']);
Expand Down Expand Up @@ -178,9 +184,19 @@ procedure TIRCLogBot.Help(const ATarget: String);
debug('Help command.');
FIRC.Say(ATarget, 'Commands:');
FIRC.Say(ATarget, '.help - This help information.');
FIRC.Say(ATarget, '.version - Version and info about the bot.');
FIRC.Say(ATarget, '.replay [count] - Raplays last <count> lines. Default is last 10 lines.');
end;

procedure TIRCLogBot.Version(const ATarget: String);
begin
debug('Version command.');
FIRC.Say(ATarget, Format('Version: %s, %s',[
cVersion,
cRepoURL
]));
end;

procedure TIRCLogBot.Replay(const ATarget: String; ACount: Integer);
var
lines: TStringList;
Expand Down
4 changes: 4 additions & 0 deletions src/common/irclogbot.common.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ interface
SysUtils
;

const
cVersion = 'v0.0.3';
cRepoURL = 'https://github.com/ObjectPascal-Community/pasirclogbot';

var
DebugOn: Boolean;

Expand Down

0 comments on commit 4de4492

Please sign in to comment.