Compare commits

...

16 Commits

Author SHA1 Message Date
Daniel Berteaud 0c3d8eb501 Automatic commit of package [patrix] release [0.1.16-1].
Created by command:

/usr/bin/tito tag
2023-02-13 10:58:37 +01:00
Daniel Berteaud 5eceadb587 Add HTML::Strip to Required 2023-02-13 10:58:19 +01:00
Daniel Berteaud 90f43a6ce6
Merge pull request #2 from ImagoTrigger/master
Add HTML::Strip and always support HTML messages
2023-02-13 10:57:29 +01:00
Allegiance Zone pusher 0fb7bf849e
Add HTML::Strip and always support HTML messages
Does not mess with send-code
2023-02-11 18:54:24 -06:00
Daniel Berteaud 2ea3589c4c Automatic commit of package [patrix] release [0.1.15-1].
Created by command:

/usr/bin/tito tag
2022-07-26 15:08:50 +02:00
Daniel Berteaud 8fad3895b1 Automatic commit of package [patrix] release [0.1.14-1].
Created by command:

/usr/bin/tito tag
2022-01-11 15:18:16 +01:00
Daniel Berteaud 63152190a8 Automatic commit of package [patrix] release [0.1.13-1].
Created by command:

/usr/bin/tito tag
2022-01-03 14:02:40 +01:00
Daniel Berteaud 1fc700a56e Check config readability and global /etc/patrixrc 2022-01-03 12:23:15 +01:00
Daniel Berteaud 5aec50e85e Automatic commit of package [patrix] release [0.1.12-1].
Created by command:

/usr/bin/tito tag
2021-12-09 19:18:32 +01:00
Daniel Berteaud d757280823 Revert requiring LWP::Protocol::connect 2021-12-09 19:18:12 +01:00
Daniel Berteaud 27581dec38 Automatic commit of package [patrix] release [0.1.11-1].
Created by command:

/usr/bin/tito tag
2021-12-08 17:29:37 +01:00
Daniel Berteaud 75131a5222 Automatic commit of package [patrix] release [0.1.10-1].
Created by command:

/usr/bin/tito tag
2018-11-28 11:43:08 +01:00
Daniel Berteaud f79d98b75c Require LWP::Protocol::connect for EL distro 2018-11-28 11:41:08 +01:00
Daniel Berteaud cb688ca984 USe LWP::Protocol::connect to handle https proxy if available 2018-11-28 11:40:35 +01:00
Daniel Berteaud be6cc12f2f Automatic commit of package [patrix] release [0.1.9-1].
Created by command:

/usr/bin/tito tag
2018-02-22 13:05:07 +01:00
Daniel Berteaud ea83e268b4 Support using an HTTP proxy 2018-02-22 12:05:33 +01:00
4 changed files with 69 additions and 6 deletions

View File

@ -1 +1 @@
0.1.8-1 ./
0.1.16-1 ./

View File

@ -21,6 +21,7 @@ Here're the vailable options:
* --user: specify the user you want to login as
* --password: the password to auth against the HS
* --server: the HS you want to connect to. Default is https://matrix.org
* --proxy: use an HTTP proxy to access the HS. If not specified, will try to get system wide proxy (see LWP::UserAgent->env_proxy)
* --access-token: can be used instead of --user and --password. Use --get-access-token to get one first for example.
* --room: the room to which the message must be sent. Can be a room ID or a room alias
* --message: the text message you want to send. If you send something on stdin, it's assumed to be the text to send and this option is ignored

View File

@ -1,5 +1,5 @@
Name: patrix
Version: 0.1.8
Version: 0.1.16
Release: 1%{?dist}
Summary: Command line client for Matrix
@ -23,6 +23,7 @@ Requires: perl(URI::Escape)
Requires: perl(Term::ReadKey)
Requires: perl(Hash::Merge::Simple)
Requires: perl(Scalar::Util)
Requires: perl(HTML::Strip)
%description
Patrix is a simple (and quite limited) client for the Matrix communication network
@ -52,6 +53,33 @@ room via the command line.
%{_bindir}/patrix
%changelog
* Mon Feb 13 2023 Daniel Berteaud <dbd@ehtrace.com> 0.1.16-1
- Add HTML::Strip to Required (dbd@ehtrace.com)
- Add HTML::Strip and always support HTML messages (imagotrigger@gmail.com)
* Tue Jul 26 2022 Daniel Berteaud <dbd@ehtrace.com> 0.1.15-1
- Resign with new key
* Tue Jan 11 2022 Daniel Berteaud <dbd@ehtrace.com> 0.1.14-1
- Release bump for rebuild
* Mon Jan 03 2022 Daniel Berteaud <dbd@ehtrace.com> 0.1.13-1
- Check config readability and global /etc/patrixrc (dbd@ehtrace.com)
* Thu Dec 09 2021 Daniel Berteaud <dani@lapiole.org> 0.1.12-1
- Revert requiring LWP::Protocol::connect (dani@lapiole.org)
* Wed Dec 08 2021 Daniel Berteaud <dani@lapiole.org> 0.1.11-1
- Rebuild with new key
* Wed Nov 28 2018 Daniel Berteaud <daniel@firewall-services.com> 0.1.10-1
- Require LWP::Protocol::connect for EL distro (daniel@firewall-services.com)
- USe LWP::Protocol::connect to handle https proxy if available
(daniel@firewall-services.com)
* Thu Feb 22 2018 Daniel Berteaud <daniel@firewall-services.com> 0.1.9-1
- Support using an HTTP proxy (daniel@firewall-services.com)
* Fri Nov 24 2017 Daniel Berteaud <daniel@firewall-services.com> 0.1.8-1
- Typo in README (daniel@firewall-services.com)
- Add support for --send-code (daniel@firewall-services.com)

View File

@ -15,14 +15,17 @@ use URI::Escape;
use Term::ReadKey;
use Hash::Merge::Simple qw(merge);
use Scalar::Util qw(looks_like_number);
use HTML::Strip;
our $opt;
our $hs = HTML::Strip->new();
GetOptions(
"user=s" => \$opt->{user},
"password=s" => \$opt->{password},
"access_token|access-token|token=s" => \$opt->{access_token},
"server=s" => \$opt->{server},
"proxy=s" => \$opt->{proxy},
"room=s" => \$opt->{room},
"message|msg=s" => \$opt->{message},
"files=s@" => \$opt->{file},
@ -51,13 +54,29 @@ GetOptions(
"perm_reset|reset-permission" => \$opt->{perm_reset}
);
if (-e File::HomeDir->my_home . "/.patrixrc" && !$opt->{conf}){
$opt->{conf} = File::HomeDir->my_home . "/.patrixrc";
debug("Using default config file $opt->{conf}");
if (!$opt->{conf}){
# Read global config if it exists and is readable
if (-f '/etc/patrixrc' && open(CONFIG, '<', '/etc/patrixrc')){
$opt->{conf} = '/etc/patrixrc';
close CONFIG;
debug("Using global config file $opt->{conf}");
}
# If there's a user defined config, use it instead
if (-f File::HomeDir->my_home . "/.patrixrc" && open(CONFIG, '<', File::HomeDir->my_home . "/.patrixrc")){
$opt->{conf} = File::HomeDir->my_home . "/.patrixrc";
close CONFIG;
debug("Using default config file $opt->{conf}");
}
}
if ($opt->{conf} && -e $opt->{conf}){
read_conf();
}
else {
die "No configuration found.\nYou should either create one in ~/.patrixrc " .
"or give the path of a custom config with --config /path/to/patrixrc";
}
# alias for --action=foo is --foo
my @actions = qw(
@ -82,6 +101,17 @@ foreach my $action (@actions){
my $lwp = LWP::UserAgent->new;
if (not $opt->{proxy} and defined $ENV{https_proxy}){
$opt->{proxy} = $ENV{https_proxy};
}
# If a proxy is specified then use it. Else, try to get global one
if ($opt->{proxy}){
if (eval { require LWP::Protocol::connect; }){
$opt->{proxy} =~ s|^http://(.*)|connect://$1|;
}
$lwp->proxy(['https'], $opt->{proxy});
}
my $stdin = 0;
if (!-t STDIN){
debug("Reading data from stdin");
@ -228,8 +258,12 @@ sub send_msg {
}
my $json = {
msgtype => ($opt->{action} eq 'send-notice') ? 'm.notice' : 'm.text',
body => $opt->{message}
body => $hs->parse($opt->{message}),
formatted_body => $opt->{message},
format => "org.matrix.custom.html",
};
$hs->eof();
# If we send code, we have to format it correctly
if ($opt->{action} eq 'send-code'){
$json->{formatted_body} = '<pre><code>' . $opt->{message} . '</code></pre>';