Compare commits

...

19 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
Daniel Berteaud 92b8451f95 Automatic commit of package [patrix] release [0.1.8-1].
Created by command:

/usr/bin/tito tag
2017-11-24 12:42:40 +01:00
Daniel Berteaud 8efee98548 Typo in README 2017-11-24 12:30:55 +01:00
Daniel Berteaud 5207d794b5 Add support for --send-code 2017-11-24 12:30:29 +01:00
4 changed files with 83 additions and 8 deletions

View File

@ -1 +1 @@
0.1.7-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
@ -41,6 +42,7 @@ Here're the vailable options:
* send-msg (default): send the text message
* send-message: an alias for send-msg
* send-notice: send a notice. Very similar to send-msg but the client may display it differently. Eg Riot will not notify you for notices
* send-code: same as send-msg, but text will be presented like code (<pre><code>text</code></pre>)
* send-file: send a binary file. --file must be set
* create-room: create a new room
* modify-room: change an existing room (add an alias, set name, topic, join_rules, invite)
@ -85,7 +87,7 @@ patrix --modify-room --join-rules=public --topic='New topic' --room='!uXfknaWNcA
```
* Change power level needed for the ban action. Set the default power levels of new users to 10. Set power level for @dani:matrix.example.com to 90
```
patrix -modify-room --perm "ban=70" --perm "users_default=10" --user-perm "@dani:matrix.example.com=90"
patrix --modify-room --perm "ban=70" --perm "users_default=10" --user-perm "@dani:matrix.example.com=90"
```
* Set the required power level to send the m.room.name event to 80 (you can change the room name if you have a power level of at least 80)
```

View File

@ -1,5 +1,5 @@
Name: patrix
Version: 0.1.7
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,37 @@ 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)
* Thu Nov 23 2017 Daniel Berteaud <daniel@firewall-services.com> 0.1.7-1
- Fix get-room-id, Room ID is already resolved at this point (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},
@ -30,6 +33,7 @@ GetOptions(
"action=s" => \$opt->{action},
"send-msg|send-message" => \$opt->{'send-msg'},
"send-notice" => \$opt->{'send-notice'},
"send-code" => \$opt->{'send-code'},
"send-file" => \$opt->{'send-file'},
"create-room" => \$opt->{'create-room'},
"modify-room" => \$opt->{'modify-room'},
@ -50,18 +54,35 @@ 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(
send-msg
send-notice
send-code
send-file
create-room
modify-room
@ -80,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");
@ -226,8 +258,17 @@ 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>';
$json->{format} = 'org.matrix.custom.html';
}
my $resp = send_request({
uri => $uri,
content => to_json($json)
@ -549,7 +590,7 @@ elsif ($opt->{action} eq 'get-room-list'){
elsif ($opt->{action} eq 'get-room-id'){
print $opt->{room} . "\n";
}
elsif ($opt->{action} =~ m/^send\-(msg|message|notice)$/){
elsif ($opt->{action} =~ m/^send\-(msg|message|notice|code)$/){
join_room();
send_msg();
}