From 5acd4d5a4e64bffebf4917853825749ff26b7f30 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Mon, 18 Apr 2022 23:13:25 +0000 Subject: [PATCH 001/133] Initial commit --- LICENSE | 339 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 339 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. From e3579d5fde5c4aaedb6308d67f08eb9e64b6c08b Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 18 Apr 2022 23:13:25 +0000 Subject: [PATCH 002/133] Initial commit --- LICENSE | 339 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 339 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. From 9ac219a8f4fe24b8ea4710ded6741be56f39ed8c Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Mon, 18 Apr 2022 23:14:02 +0000 Subject: [PATCH 003/133] Added files matrix-send matrix-send.conf Makefile --- Makefile | 4 ++ matrix-send | 138 +++++++++++++++++++++++++++++++++++++++++++++++ matrix-send.conf | 17 ++++++ 3 files changed, 159 insertions(+) create mode 100644 Makefile create mode 100644 matrix-send create mode 100644 matrix-send.conf diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7d39ff7 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +install: + cp matrix-send /bin +config: + cp matrix-send.conf ~/.config/ diff --git a/matrix-send b/matrix-send new file mode 100644 index 0000000..96e3392 --- /dev/null +++ b/matrix-send @@ -0,0 +1,138 @@ +#!/bin/sh +# matrix-send: a super-simple command-line matrix client + +[ -e /usr/bin/curl ] || printf "\033[31;1merror:\033[0m curl not found\n" + +########################### +#### Generic Functions #### +########################### + +error () { + printf "\033[31;1merror:\033[0m $1\n" + exit 1 +} + +conf_error () { + printf "\033[31;1mconfiguration error:\033[0m $1\n" + exit 2 +} + +vargrep () { + printf "$2\n" | grep "$1" $3 +} + +################################## +#### Configuration Directives #### +################################## + +Homeserver () { + [ -z $1 ] && conf_error "Homeserver not specified in directive Homeserver" + homeserver="$1" +} + +Username () { + [ -z $1 ] && conf_error "Username not specified in directive Username" + username="$1" +} + +Password () { + [ -z $1 ] && conf_error "Password not specified in directive Password" + password="$1" +} + +AccessToken () { + [ -z $1 ] && conf_error "Token not specified in directive AccessToken" + manualAuth="true" + token="$1" +} + +CacheLocation () { + [ -z $1 ] && conf_error "Cache Location not specified in directive CacheLocation" + if vargrep "^/.+$" "$1" -Eq || \ + vargrep "^~.+$" "$1" -Eq; + then cacheloc="$1"; + else conf_error "Cache Location is not valid (does not begin with / or ~) in directive CacheLocation"; fi +} + +################################## +#### Configuration Statements #### +################################## + +Color () { + color="true" +} + +NoCache () { + nocache="true" +} + +################################### +#### Matrix-specific Functions #### +################################### + +GetAccessToken () { + [ -z "$manualAuth" ] && printf "Getting access token...\n" + if [ "$manualAuth" = "true" ]; + then printf ""; # printf "" basically means do nothing + else token=$(curl -XPOST -d "{"'"'"type"'"'":"'"'"m.login.password"'"'", "'"'"user"'"'":"'"'"$username"'"'", "'"'"password"'"'":"'"'"$password"'"'"}" "https://$homeserver/_matrix/client/r0/login" | grep -oE 'syt_.+_...................._......'); + fi +} + +CacheAccessToken () { + if [ "$nocache" = "true" ]; + then printf ""; + else + mkdir -p "$cacheloc/matrix-send" + printf "$token\n" > "$cacheloc/matrix-send/access-token"; + fi +} + +ClearCache () { + [ -e "$cacheloc/matrix-send/access-token" ] || printf "There is no cache to be cleared.\n" + [ -e "$cacheloc/matrix-send/access-token" ] && rm -rf "$cacheloc/matrix-send/" && printf "Cleared cache\n" + exit 0 +} + +Send () { + curl -XPOST -d "{"'"'"msgtype"'"'":"'"'"m.text"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$homeserver/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" +} + +############################### +#### Configuration loading #### +############################### + +# Set default config settings +CacheLocation "$HOME/.cache" + +# Load configuration +if [ -e $HOME/.config/matrix-send.conf ]; +then . $HOME/.config/matrix-send.conf; +else + mkdir -p $HOME/.config + touch $HOME/.config/matrix-send.conf +fi + +# Run checks for essential directives +[ -z $homeserver ] && conf_error "Homeserver directive is not present" +[ -z $username ] && conf_error "Username directive is not present" +[ -z $password ] && conf_error "Password directive is not present" + +############## +#### Main #### +############## + +[ -z "$1" ] && error "Message not specified" + +# Get token and cache it (unless NoCache is set) +[ "$1" = "-c" ] && ClearCache +[ -e "$cacheloc/matrix-send/access-token" ] && token=$(cat $cacheloc/matrix-send/access-token) +[ -e "$cacheloc/matrix-send/access-token" ] || GetAccessToken +CacheAccessToken + +if [ -z "$2" ]; +then error "Room ID not specified (Leave out the '!')."; +else + message="$1" + roomid="$2" + Send; +fi diff --git a/matrix-send.conf b/matrix-send.conf new file mode 100644 index 0000000..89cd43b --- /dev/null +++ b/matrix-send.conf @@ -0,0 +1,17 @@ +## Example basic configuration for matrix-send +# A line with an option (e.g. 'Username jeremy') is a "directive". +# A line with only one word (e.g. 'Color') is a "statement". +# Comments start with a pound (#) +# Additional options can be found in config.md in the Git repository + +# The Homeserver directive is for your homeserver's Matrix URL. matrix-send assumes that this is valid. +# matrix.org's would be matrix-client.matrix.org. +# You can find it by typing it into Element's sign in page and hovering your mouse over it. +Homeserver matrix-client.matrix.org + +# The Username directive is for your username for that homeserver. +Username john_doe + +# The Password directive is your password for your account. +# If your password has spaces, put speech marks ("") around it. +Password supersecretpassword From a25621251b868105a763e9ce75a35aa9851d4ca6 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 18 Apr 2022 23:14:02 +0000 Subject: [PATCH 004/133] Added files matrix-send matrix-send.conf Makefile --- Makefile | 4 ++ matrix-send | 138 +++++++++++++++++++++++++++++++++++++++++++++++ matrix-send.conf | 17 ++++++ 3 files changed, 159 insertions(+) create mode 100644 Makefile create mode 100644 matrix-send create mode 100644 matrix-send.conf diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7d39ff7 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +install: + cp matrix-send /bin +config: + cp matrix-send.conf ~/.config/ diff --git a/matrix-send b/matrix-send new file mode 100644 index 0000000..96e3392 --- /dev/null +++ b/matrix-send @@ -0,0 +1,138 @@ +#!/bin/sh +# matrix-send: a super-simple command-line matrix client + +[ -e /usr/bin/curl ] || printf "\033[31;1merror:\033[0m curl not found\n" + +########################### +#### Generic Functions #### +########################### + +error () { + printf "\033[31;1merror:\033[0m $1\n" + exit 1 +} + +conf_error () { + printf "\033[31;1mconfiguration error:\033[0m $1\n" + exit 2 +} + +vargrep () { + printf "$2\n" | grep "$1" $3 +} + +################################## +#### Configuration Directives #### +################################## + +Homeserver () { + [ -z $1 ] && conf_error "Homeserver not specified in directive Homeserver" + homeserver="$1" +} + +Username () { + [ -z $1 ] && conf_error "Username not specified in directive Username" + username="$1" +} + +Password () { + [ -z $1 ] && conf_error "Password not specified in directive Password" + password="$1" +} + +AccessToken () { + [ -z $1 ] && conf_error "Token not specified in directive AccessToken" + manualAuth="true" + token="$1" +} + +CacheLocation () { + [ -z $1 ] && conf_error "Cache Location not specified in directive CacheLocation" + if vargrep "^/.+$" "$1" -Eq || \ + vargrep "^~.+$" "$1" -Eq; + then cacheloc="$1"; + else conf_error "Cache Location is not valid (does not begin with / or ~) in directive CacheLocation"; fi +} + +################################## +#### Configuration Statements #### +################################## + +Color () { + color="true" +} + +NoCache () { + nocache="true" +} + +################################### +#### Matrix-specific Functions #### +################################### + +GetAccessToken () { + [ -z "$manualAuth" ] && printf "Getting access token...\n" + if [ "$manualAuth" = "true" ]; + then printf ""; # printf "" basically means do nothing + else token=$(curl -XPOST -d "{"'"'"type"'"'":"'"'"m.login.password"'"'", "'"'"user"'"'":"'"'"$username"'"'", "'"'"password"'"'":"'"'"$password"'"'"}" "https://$homeserver/_matrix/client/r0/login" | grep -oE 'syt_.+_...................._......'); + fi +} + +CacheAccessToken () { + if [ "$nocache" = "true" ]; + then printf ""; + else + mkdir -p "$cacheloc/matrix-send" + printf "$token\n" > "$cacheloc/matrix-send/access-token"; + fi +} + +ClearCache () { + [ -e "$cacheloc/matrix-send/access-token" ] || printf "There is no cache to be cleared.\n" + [ -e "$cacheloc/matrix-send/access-token" ] && rm -rf "$cacheloc/matrix-send/" && printf "Cleared cache\n" + exit 0 +} + +Send () { + curl -XPOST -d "{"'"'"msgtype"'"'":"'"'"m.text"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$homeserver/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" +} + +############################### +#### Configuration loading #### +############################### + +# Set default config settings +CacheLocation "$HOME/.cache" + +# Load configuration +if [ -e $HOME/.config/matrix-send.conf ]; +then . $HOME/.config/matrix-send.conf; +else + mkdir -p $HOME/.config + touch $HOME/.config/matrix-send.conf +fi + +# Run checks for essential directives +[ -z $homeserver ] && conf_error "Homeserver directive is not present" +[ -z $username ] && conf_error "Username directive is not present" +[ -z $password ] && conf_error "Password directive is not present" + +############## +#### Main #### +############## + +[ -z "$1" ] && error "Message not specified" + +# Get token and cache it (unless NoCache is set) +[ "$1" = "-c" ] && ClearCache +[ -e "$cacheloc/matrix-send/access-token" ] && token=$(cat $cacheloc/matrix-send/access-token) +[ -e "$cacheloc/matrix-send/access-token" ] || GetAccessToken +CacheAccessToken + +if [ -z "$2" ]; +then error "Room ID not specified (Leave out the '!')."; +else + message="$1" + roomid="$2" + Send; +fi diff --git a/matrix-send.conf b/matrix-send.conf new file mode 100644 index 0000000..89cd43b --- /dev/null +++ b/matrix-send.conf @@ -0,0 +1,17 @@ +## Example basic configuration for matrix-send +# A line with an option (e.g. 'Username jeremy') is a "directive". +# A line with only one word (e.g. 'Color') is a "statement". +# Comments start with a pound (#) +# Additional options can be found in config.md in the Git repository + +# The Homeserver directive is for your homeserver's Matrix URL. matrix-send assumes that this is valid. +# matrix.org's would be matrix-client.matrix.org. +# You can find it by typing it into Element's sign in page and hovering your mouse over it. +Homeserver matrix-client.matrix.org + +# The Username directive is for your username for that homeserver. +Username john_doe + +# The Password directive is your password for your account. +# If your password has spaces, put speech marks ("") around it. +Password supersecretpassword From f5a582fa668bdb4f2d474a33012138a998399280 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 19 Apr 2022 02:44:16 +0000 Subject: [PATCH 005/133] Create README.md --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b3a31e8 --- /dev/null +++ b/README.md @@ -0,0 +1,66 @@ +# matrix-send +A script to send a message to a Matrix room. + +--- + +**Syntax:** `matrix-send ` + +**For example:** `matrix-send "Hello world\!" aBcDeFgHiJkLmNoP:matrix.org` + +--- + +`matrix-send` is a simple script to interact with a Matrix homeserver in order to send a message to a room hosted by it. + +If you don't understand, `matrix-send` is an oversimplified Matrix client. + +It is designed for automation, for example you could set a cron job for `matrix-send "$(curl ifconfig.co)" yourmatrixroom:matrix.org` and that would automatically send your device's public IP address to a Matrix room. It seems like doxxing yourself, but I use it for ssh'ing into my home server when I'm somewhere else. + +## Get started + +In order to start using `matrix-send` you need a config file. To copy the configuration to .config, clone this repository and type: + + make config + +The configuration has now been copied to ~/.config, so open the file ~/.config/matrix-send.conf with your favourite text editor. + +You will see three "directives"; configuration options that take an argument. Directives' syntax look like so: + + Directive Argument + +Modify the `Homeserver` directive to match your homeserver's Matrix URL. If you're using matrix.org you can leave it as default. + +If you're not using matrix.org, one way you can find your homeserver's Matrix URL is by typing your homeserver's address into Element. Click Continue, and hover over your homeserver's address that popped up. The Matrix URL should be showing. + +Set the `Username` directive to your username, and the `Password` directive to your password. + +You might not want to put your password in plain text, so you could do something like this instead: + + Password $(gpg -d ~/.matrix_pass.gpg) + +This will open `gpg` to decrypt a file with your password inside. You will need to set this up first. + +After you've finished changing these, your configuration should look like this (without the comments): + + Homeserver matrix-client.matrix.org # or your homeserver + Username jeremy # or your name + Password mysupersecurepassword # or your password + +After you have these three directives set, you're ready to start. + +--- + +To install, run `sudo make install` in the cloned repository's directory. + + sudo make install + +Now, using your Matrix client, make a room, and find the Room ID. On Element, right click your room, and click Advanced. Your Room ID is under "Internal Room ID". + +Your Room ID will start with a '!'. Remove this symbol from the start and copy the new ID. + +To send a message to your chosen room, type `matrix-send` followed by your message (in speech marks) and then your Room ID. For example: + + matrix-send "Hi\!" asdfasdfasdfasdf:matrix.org + +And that will send the message "Hi!" to the Matrix room asdfasdfasdfasdf:matrix.org. + +Also, if you type exclamation marks '!' in a message, some shells misinterpret that as an event. To fix this, I put a backslash `\` before the exclamation mark. From f62bd475540a1562785795319c832ffde7c6e4c2 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 19 Apr 2022 02:44:16 +0000 Subject: [PATCH 006/133] Create README.md --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b3a31e8 --- /dev/null +++ b/README.md @@ -0,0 +1,66 @@ +# matrix-send +A script to send a message to a Matrix room. + +--- + +**Syntax:** `matrix-send ` + +**For example:** `matrix-send "Hello world\!" aBcDeFgHiJkLmNoP:matrix.org` + +--- + +`matrix-send` is a simple script to interact with a Matrix homeserver in order to send a message to a room hosted by it. + +If you don't understand, `matrix-send` is an oversimplified Matrix client. + +It is designed for automation, for example you could set a cron job for `matrix-send "$(curl ifconfig.co)" yourmatrixroom:matrix.org` and that would automatically send your device's public IP address to a Matrix room. It seems like doxxing yourself, but I use it for ssh'ing into my home server when I'm somewhere else. + +## Get started + +In order to start using `matrix-send` you need a config file. To copy the configuration to .config, clone this repository and type: + + make config + +The configuration has now been copied to ~/.config, so open the file ~/.config/matrix-send.conf with your favourite text editor. + +You will see three "directives"; configuration options that take an argument. Directives' syntax look like so: + + Directive Argument + +Modify the `Homeserver` directive to match your homeserver's Matrix URL. If you're using matrix.org you can leave it as default. + +If you're not using matrix.org, one way you can find your homeserver's Matrix URL is by typing your homeserver's address into Element. Click Continue, and hover over your homeserver's address that popped up. The Matrix URL should be showing. + +Set the `Username` directive to your username, and the `Password` directive to your password. + +You might not want to put your password in plain text, so you could do something like this instead: + + Password $(gpg -d ~/.matrix_pass.gpg) + +This will open `gpg` to decrypt a file with your password inside. You will need to set this up first. + +After you've finished changing these, your configuration should look like this (without the comments): + + Homeserver matrix-client.matrix.org # or your homeserver + Username jeremy # or your name + Password mysupersecurepassword # or your password + +After you have these three directives set, you're ready to start. + +--- + +To install, run `sudo make install` in the cloned repository's directory. + + sudo make install + +Now, using your Matrix client, make a room, and find the Room ID. On Element, right click your room, and click Advanced. Your Room ID is under "Internal Room ID". + +Your Room ID will start with a '!'. Remove this symbol from the start and copy the new ID. + +To send a message to your chosen room, type `matrix-send` followed by your message (in speech marks) and then your Room ID. For example: + + matrix-send "Hi\!" asdfasdfasdfasdf:matrix.org + +And that will send the message "Hi!" to the Matrix room asdfasdfasdfasdf:matrix.org. + +Also, if you type exclamation marks '!' in a message, some shells misinterpret that as an event. To fix this, I put a backslash `\` before the exclamation mark. From b380959b8a55de3d9a3877f76d79b5fba9222f6e Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 19 Apr 2022 02:52:42 +0000 Subject: [PATCH 007/133] Create config.md --- config.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 config.md diff --git a/config.md b/config.md new file mode 100644 index 0000000..1411f4a --- /dev/null +++ b/config.md @@ -0,0 +1,23 @@ +# Configuration + +This file will list all the possible configuration directives and statements. +Comments can be made in the file with a hashtag (`#`). + +--- + +## Directives + +Options you can modify with an argument. + +* `Homeserver`: The homeserver to log into +* `Username`: The user's name used to log in +* `Password`: The user's password used to log in +* `AccessToken`: A custom access token to use for logging in, instead of generating a new one from login credentials +* `CacheLocation`: A custom location to cache access tokens in. Defaults to $HOME/.cache + +## Statements + +Options that say one thing and nothing else. You can't change these. + +* `Colour`/`Color`: Use colour +* `NoCache`: Don't cache access tokens From 21cfb78614323dbf13632cbe5b66e46bc6e88ecb Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 19 Apr 2022 02:52:42 +0000 Subject: [PATCH 008/133] Create config.md --- config.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 config.md diff --git a/config.md b/config.md new file mode 100644 index 0000000..1411f4a --- /dev/null +++ b/config.md @@ -0,0 +1,23 @@ +# Configuration + +This file will list all the possible configuration directives and statements. +Comments can be made in the file with a hashtag (`#`). + +--- + +## Directives + +Options you can modify with an argument. + +* `Homeserver`: The homeserver to log into +* `Username`: The user's name used to log in +* `Password`: The user's password used to log in +* `AccessToken`: A custom access token to use for logging in, instead of generating a new one from login credentials +* `CacheLocation`: A custom location to cache access tokens in. Defaults to $HOME/.cache + +## Statements + +Options that say one thing and nothing else. You can't change these. + +* `Colour`/`Color`: Use colour +* `NoCache`: Don't cache access tokens From 39f9ebf676f7853cdf504bacbf2faa34ec4b9a4e Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 19 Apr 2022 02:54:37 +0000 Subject: [PATCH 009/133] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b3a31e8..c63cce3 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ After you've finished changing these, your configuration should look like this ( After you have these three directives set, you're ready to start. +Additional directives can be found in [config.md](https://github.com/jtbx/matrix-send/blob/main/config.md). + --- To install, run `sudo make install` in the cloned repository's directory. From 434ceaed1b8f5b5c3e32ea8be8e32b871d260566 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 19 Apr 2022 02:54:37 +0000 Subject: [PATCH 010/133] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b3a31e8..c63cce3 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ After you've finished changing these, your configuration should look like this ( After you have these three directives set, you're ready to start. +Additional directives can be found in [config.md](https://github.com/jtbx/matrix-send/blob/main/config.md). + --- To install, run `sudo make install` in the cloned repository's directory. From 5128553ce94a58dcba975a3c44f38982ab71230d Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 19 Apr 2022 03:03:00 +0000 Subject: [PATCH 011/133] Added `Colour` configuration option --- matrix-send | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/matrix-send b/matrix-send index 96e3392..1edf513 100644 --- a/matrix-send +++ b/matrix-send @@ -58,9 +58,10 @@ CacheLocation () { #### Configuration Statements #### ################################## -Color () { - color="true" +Colour () { + colour="true" } +alias Color="Colour" NoCache () { nocache="true" From 94027d3e7da4457f8be48b13dc7643225b36314e Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 19 Apr 2022 03:03:00 +0000 Subject: [PATCH 012/133] Added `Colour` configuration option --- matrix-send | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/matrix-send b/matrix-send index 96e3392..1edf513 100644 --- a/matrix-send +++ b/matrix-send @@ -58,9 +58,10 @@ CacheLocation () { #### Configuration Statements #### ################################## -Color () { - color="true" +Colour () { + colour="true" } +alias Color="Colour" NoCache () { nocache="true" From 10f83b63df98e03b5ca6441823eb026386407fa9 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 19 Apr 2022 15:37:01 +1200 Subject: [PATCH 013/133] Removed Colour and Color options --- config.md | 1 - matrix-send | 5 ----- 2 files changed, 6 deletions(-) mode change 100644 => 100755 matrix-send diff --git a/config.md b/config.md index 1411f4a..b848b35 100644 --- a/config.md +++ b/config.md @@ -19,5 +19,4 @@ Options you can modify with an argument. Options that say one thing and nothing else. You can't change these. -* `Colour`/`Color`: Use colour * `NoCache`: Don't cache access tokens diff --git a/matrix-send b/matrix-send old mode 100644 new mode 100755 index 1edf513..0ac9158 --- a/matrix-send +++ b/matrix-send @@ -58,11 +58,6 @@ CacheLocation () { #### Configuration Statements #### ################################## -Colour () { - colour="true" -} -alias Color="Colour" - NoCache () { nocache="true" } From 4815d417915ffdde244b6eccf088aa31c51f81ac Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 19 Apr 2022 15:37:01 +1200 Subject: [PATCH 014/133] Removed Colour and Color options --- config.md | 1 - matrix-send | 5 ----- 2 files changed, 6 deletions(-) mode change 100644 => 100755 matrix-send diff --git a/config.md b/config.md index 1411f4a..b848b35 100644 --- a/config.md +++ b/config.md @@ -19,5 +19,4 @@ Options you can modify with an argument. Options that say one thing and nothing else. You can't change these. -* `Colour`/`Color`: Use colour * `NoCache`: Don't cache access tokens diff --git a/matrix-send b/matrix-send old mode 100644 new mode 100755 index 1edf513..0ac9158 --- a/matrix-send +++ b/matrix-send @@ -58,11 +58,6 @@ CacheLocation () { #### Configuration Statements #### ################################## -Colour () { - colour="true" -} -alias Color="Colour" - NoCache () { nocache="true" } From a4f09d5dea67d3a75630a352724288a3e4365dd8 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 19 Apr 2022 05:10:05 +0000 Subject: [PATCH 015/133] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c63cce3..b7bf23b 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A script to send a message to a Matrix room. --- -`matrix-send` is a simple script to interact with a Matrix homeserver in order to send a message to a room hosted by it. +`matrix-send` is a simple script to interact with a Matrix homeserver in order to send a message to a room. If you don't understand, `matrix-send` is an oversimplified Matrix client. From 14fc4de9c67572da28595cdb1d24d2c750fe533c Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 19 Apr 2022 05:10:05 +0000 Subject: [PATCH 016/133] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c63cce3..b7bf23b 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A script to send a message to a Matrix room. --- -`matrix-send` is a simple script to interact with a Matrix homeserver in order to send a message to a room hosted by it. +`matrix-send` is a simple script to interact with a Matrix homeserver in order to send a message to a room. If you don't understand, `matrix-send` is an oversimplified Matrix client. From 1f72a2361e294cef3622cdde2bce9e5da37b586c Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 19 Apr 2022 05:12:28 +0000 Subject: [PATCH 017/133] Create versiondata --- versiondata | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 versiondata diff --git a/versiondata b/versiondata new file mode 100644 index 0000000..acef7f7 --- /dev/null +++ b/versiondata @@ -0,0 +1,3 @@ +# This is used by matrix-send when given the -u option, to upgrade. + +LatestVersion="dev_rolling" From 0a3ef6ee292c23b43b97b311fec7562584115fa5 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 19 Apr 2022 05:12:28 +0000 Subject: [PATCH 018/133] Create versiondata --- versiondata | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 versiondata diff --git a/versiondata b/versiondata new file mode 100644 index 0000000..acef7f7 --- /dev/null +++ b/versiondata @@ -0,0 +1,3 @@ +# This is used by matrix-send when given the -u option, to upgrade. + +LatestVersion="dev_rolling" From 1827573d77b748b3023f17f97a023ab54e0442ef Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 19 Apr 2022 05:34:34 +0000 Subject: [PATCH 019/133] Modified versiondata because dash didn't like comments --- versiondata | 2 -- 1 file changed, 2 deletions(-) diff --git a/versiondata b/versiondata index acef7f7..6bad906 100644 --- a/versiondata +++ b/versiondata @@ -1,3 +1 @@ -# This is used by matrix-send when given the -u option, to upgrade. - LatestVersion="dev_rolling" From e85304ff8787a27bf79cb85fe1aca5922feb8cb4 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 19 Apr 2022 05:34:34 +0000 Subject: [PATCH 020/133] Modified versiondata because dash didn't like comments --- versiondata | 2 -- 1 file changed, 2 deletions(-) diff --git a/versiondata b/versiondata index acef7f7..6bad906 100644 --- a/versiondata +++ b/versiondata @@ -1,3 +1 @@ -# This is used by matrix-send when given the -u option, to upgrade. - LatestVersion="dev_rolling" From 1451bf6941f83de155e28d4d3954767d651cfde3 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 19 Apr 2022 17:40:20 +1200 Subject: [PATCH 021/133] Removed the WIP update mechanism, it never worked out --- matrix-send | 14 +++++++------- versiondata | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 versiondata diff --git a/matrix-send b/matrix-send index 0ac9158..803e92f 100755 --- a/matrix-send +++ b/matrix-send @@ -1,6 +1,8 @@ #!/bin/sh # matrix-send: a super-simple command-line matrix client +Version="dev_rolling" + [ -e /usr/bin/curl ] || printf "\033[31;1merror:\033[0m curl not found\n" ########################### @@ -12,9 +14,7 @@ error () { exit 1 } -conf_error () { - printf "\033[31;1mconfiguration error:\033[0m $1\n" - exit 2 +conf_error () { printf "\033[31;1mconfiguration error:\033[0m $1\n" exit 2 } vargrep () { @@ -62,9 +62,9 @@ NoCache () { nocache="true" } -################################### -#### Matrix-specific Functions #### -################################### +############################ +#### Specific Functions #### +############################ GetAccessToken () { [ -z "$manualAuth" ] && printf "Getting access token...\n" @@ -118,9 +118,9 @@ fi ############## [ -z "$1" ] && error "Message not specified" +[ "$1" = "-c" ] && ClearCache # Get token and cache it (unless NoCache is set) -[ "$1" = "-c" ] && ClearCache [ -e "$cacheloc/matrix-send/access-token" ] && token=$(cat $cacheloc/matrix-send/access-token) [ -e "$cacheloc/matrix-send/access-token" ] || GetAccessToken CacheAccessToken diff --git a/versiondata b/versiondata deleted file mode 100644 index 6bad906..0000000 --- a/versiondata +++ /dev/null @@ -1 +0,0 @@ -LatestVersion="dev_rolling" From e27afb048264b6d0d863662e1ab735822bcc9c31 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 19 Apr 2022 17:40:20 +1200 Subject: [PATCH 022/133] Removed the WIP update mechanism, it never worked out --- matrix-send | 14 +++++++------- versiondata | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 versiondata diff --git a/matrix-send b/matrix-send index 0ac9158..803e92f 100755 --- a/matrix-send +++ b/matrix-send @@ -1,6 +1,8 @@ #!/bin/sh # matrix-send: a super-simple command-line matrix client +Version="dev_rolling" + [ -e /usr/bin/curl ] || printf "\033[31;1merror:\033[0m curl not found\n" ########################### @@ -12,9 +14,7 @@ error () { exit 1 } -conf_error () { - printf "\033[31;1mconfiguration error:\033[0m $1\n" - exit 2 +conf_error () { printf "\033[31;1mconfiguration error:\033[0m $1\n" exit 2 } vargrep () { @@ -62,9 +62,9 @@ NoCache () { nocache="true" } -################################### -#### Matrix-specific Functions #### -################################### +############################ +#### Specific Functions #### +############################ GetAccessToken () { [ -z "$manualAuth" ] && printf "Getting access token...\n" @@ -118,9 +118,9 @@ fi ############## [ -z "$1" ] && error "Message not specified" +[ "$1" = "-c" ] && ClearCache # Get token and cache it (unless NoCache is set) -[ "$1" = "-c" ] && ClearCache [ -e "$cacheloc/matrix-send/access-token" ] && token=$(cat $cacheloc/matrix-send/access-token) [ -e "$cacheloc/matrix-send/access-token" ] || GetAccessToken CacheAccessToken diff --git a/versiondata b/versiondata deleted file mode 100644 index 6bad906..0000000 --- a/versiondata +++ /dev/null @@ -1 +0,0 @@ -LatestVersion="dev_rolling" From e9f626c36eeec12a448cbb49f22e2dbd8e2fcb1c Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 20 Apr 2022 10:11:38 +1200 Subject: [PATCH 023/133] Allowed for spaces in passwords more permissively + fixed space bug --- matrix-send | 6 +++--- matrix-send.conf | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/matrix-send b/matrix-send index 803e92f..7917dc9 100755 --- a/matrix-send +++ b/matrix-send @@ -36,8 +36,8 @@ Username () { } Password () { - [ -z $1 ] && conf_error "Password not specified in directive Password" - password="$1" + [ -z "$1" ] && conf_error "Password not specified in directive Password" + password="$*" } AccessToken () { @@ -111,7 +111,7 @@ fi # Run checks for essential directives [ -z $homeserver ] && conf_error "Homeserver directive is not present" [ -z $username ] && conf_error "Username directive is not present" -[ -z $password ] && conf_error "Password directive is not present" +[ -z "$password" ] && conf_error "Password directive is not present" ############## #### Main #### diff --git a/matrix-send.conf b/matrix-send.conf index 89cd43b..fce7e7e 100644 --- a/matrix-send.conf +++ b/matrix-send.conf @@ -13,5 +13,5 @@ Homeserver matrix-client.matrix.org Username john_doe # The Password directive is your password for your account. -# If your password has spaces, put speech marks ("") around it. +# Example with spaces: Password This is my super duper secure password. Password supersecretpassword From 6274ab4282bfdf235a3319e224964de106e5c278 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 20 Apr 2022 10:11:38 +1200 Subject: [PATCH 024/133] Allowed for spaces in passwords more permissively + fixed space bug --- matrix-send | 6 +++--- matrix-send.conf | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/matrix-send b/matrix-send index 803e92f..7917dc9 100755 --- a/matrix-send +++ b/matrix-send @@ -36,8 +36,8 @@ Username () { } Password () { - [ -z $1 ] && conf_error "Password not specified in directive Password" - password="$1" + [ -z "$1" ] && conf_error "Password not specified in directive Password" + password="$*" } AccessToken () { @@ -111,7 +111,7 @@ fi # Run checks for essential directives [ -z $homeserver ] && conf_error "Homeserver directive is not present" [ -z $username ] && conf_error "Username directive is not present" -[ -z $password ] && conf_error "Password directive is not present" +[ -z "$password" ] && conf_error "Password directive is not present" ############## #### Main #### diff --git a/matrix-send.conf b/matrix-send.conf index 89cd43b..fce7e7e 100644 --- a/matrix-send.conf +++ b/matrix-send.conf @@ -13,5 +13,5 @@ Homeserver matrix-client.matrix.org Username john_doe # The Password directive is your password for your account. -# If your password has spaces, put speech marks ("") around it. +# Example with spaces: Password This is my super duper secure password. Password supersecretpassword From 067259de15084ba5df6f1b5268f05f285e53dd22 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 20 Apr 2022 11:55:39 +1200 Subject: [PATCH 025/133] Added E2EE statement + shortened a line --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b7bf23b..fcec648 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,9 @@ A script to send a message to a Matrix room. If you don't understand, `matrix-send` is an oversimplified Matrix client. -It is designed for automation, for example you could set a cron job for `matrix-send "$(curl ifconfig.co)" yourmatrixroom:matrix.org` and that would automatically send your device's public IP address to a Matrix room. It seems like doxxing yourself, but I use it for ssh'ing into my home server when I'm somewhere else. +It is mainly designed for automation. I use it on my Matrix room. + +`matrix-send` doesn't have support for end-to-end encryption, and never will. ## Get started From 5291f78479bc6ff933e83a60e0d7062742b09c27 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 20 Apr 2022 11:55:39 +1200 Subject: [PATCH 026/133] Added E2EE statement + shortened a line --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b7bf23b..fcec648 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,9 @@ A script to send a message to a Matrix room. If you don't understand, `matrix-send` is an oversimplified Matrix client. -It is designed for automation, for example you could set a cron job for `matrix-send "$(curl ifconfig.co)" yourmatrixroom:matrix.org` and that would automatically send your device's public IP address to a Matrix room. It seems like doxxing yourself, but I use it for ssh'ing into my home server when I'm somewhere else. +It is mainly designed for automation. I use it on my Matrix room. + +`matrix-send` doesn't have support for end-to-end encryption, and never will. ## Get started From bf0aa3601dbec8db7fadbb7cdfad3454088da202 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 28 Jul 2022 18:27:45 +1200 Subject: [PATCH 027/133] Added matrix-send(1) manpage --- matrix-send.1 | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 matrix-send.1 diff --git a/matrix-send.1 b/matrix-send.1 new file mode 100644 index 0000000..d82deb3 --- /dev/null +++ b/matrix-send.1 @@ -0,0 +1,99 @@ +.Dd $Mdocdate: July 28 2022 $ +.Dt MATRIX-SEND 1 +.Os +.Sh NAME +.Nm matrix-send +.Nd send a message to a Matrix room +.Sh SYNOPSIS +.Nm matrix-send +.Bk -words +.Op Fl c +.Op Fl h +.Op Fl v +.Ar message room +.Ek +.Sh DESCRIPTION +.Nm +is a script to send a message to a Matrix room. +It works by sending a JSON request to your Matrix server. The message +type will always be m.text, but other options may be considered in the +future. +.Pp +To begin, start by making a configuration file. This always has the location of +.Em ~/.config/matrix-send.conf . + +At the very least, your configuration file has to contain 3 directives: +.Em Server , +.Em Username , +and +.Em Password . +Let's say your Matrix server is envs.net. Your username is john, and your password is supersecretpassword. Your configuration could look like this: +.Bd -literal -offset indent +Server matrix.envs.net +Username john +Password supersecretpassword +.Ed +.Pp +In that example, we used matrix.envs.net instead of envs.net. This is because +matrix.envs.net is the address in which the Client-Server API is listening on. +You can find your server's Client-Server API URL in Element by entering in +your server into the Homeserver dialogue in the sign-in screen, then hovering +over it once entered. Your server's Client-Server API URL should appear once +you hover over it. If it doesn't appear, you've already got it. +.Pp +You may have noticed that with this configuration, your password +is visible in plain sight. + +At its most basic, matrix-send.conf is a shell script. This means you could +replace the +.Em Password +line with something similar to this +.Bd -literal -offset indent +Password $(gpg -d /path/to/passwd.gpg) +.Ed +.Pp +where +.Em /path/to/passwd.gpg +is a GPG-encrypted plain text file containing only your password. +This line would mean that you would be asked for the passphrase required to +decrypt your password file before authenticating. This way, your password +is not in plain text. + +More information on configuration options can be found in +.Xr matrix-send.conf 5 . +.Pp +To use +.Nm , +you will need to get the Room ID of the room you'd like to send to. +This will be something like +.Em !zyxwvutsrq:example.org . + +Type the Room ID as the argument after the message you wish to send. +You may have to escape the exclamation mark with a backslash. For example: +.Bd -literal -offset indent +matrix-send "Hello world!" \!zyxwvutsrq:example.org +.Ed +.Pp +That should send a message saying +.Em Hello world! +to the room with the Room ID !zyxwvutsrq:example.org. + +By default, +.Nm +caches access tokens in +.Em $HOME/.cache/matrix-send/access-token . +If you would like to disable caching of access tokens, add NoCache to your +.Em matrix-send.conf . +.El + +.Sh FILES +.Bl -tag -width ~/.config/matrix-send.conf +.It Pa ~/.config/matrix-send.conf +configuration file for +.Nm +.It Pa ~/.cache/matrix-send/access-token +access token cache file +.El + +.Sh SEE ALSO +.Xr matrix-send.conf 5 From 717645a42152c8be876b3b56367e0e63ab6c3ea5 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 28 Jul 2022 18:27:45 +1200 Subject: [PATCH 028/133] Added matrix-send(1) manpage --- matrix-send.1 | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 matrix-send.1 diff --git a/matrix-send.1 b/matrix-send.1 new file mode 100644 index 0000000..d82deb3 --- /dev/null +++ b/matrix-send.1 @@ -0,0 +1,99 @@ +.Dd $Mdocdate: July 28 2022 $ +.Dt MATRIX-SEND 1 +.Os +.Sh NAME +.Nm matrix-send +.Nd send a message to a Matrix room +.Sh SYNOPSIS +.Nm matrix-send +.Bk -words +.Op Fl c +.Op Fl h +.Op Fl v +.Ar message room +.Ek +.Sh DESCRIPTION +.Nm +is a script to send a message to a Matrix room. +It works by sending a JSON request to your Matrix server. The message +type will always be m.text, but other options may be considered in the +future. +.Pp +To begin, start by making a configuration file. This always has the location of +.Em ~/.config/matrix-send.conf . + +At the very least, your configuration file has to contain 3 directives: +.Em Server , +.Em Username , +and +.Em Password . +Let's say your Matrix server is envs.net. Your username is john, and your password is supersecretpassword. Your configuration could look like this: +.Bd -literal -offset indent +Server matrix.envs.net +Username john +Password supersecretpassword +.Ed +.Pp +In that example, we used matrix.envs.net instead of envs.net. This is because +matrix.envs.net is the address in which the Client-Server API is listening on. +You can find your server's Client-Server API URL in Element by entering in +your server into the Homeserver dialogue in the sign-in screen, then hovering +over it once entered. Your server's Client-Server API URL should appear once +you hover over it. If it doesn't appear, you've already got it. +.Pp +You may have noticed that with this configuration, your password +is visible in plain sight. + +At its most basic, matrix-send.conf is a shell script. This means you could +replace the +.Em Password +line with something similar to this +.Bd -literal -offset indent +Password $(gpg -d /path/to/passwd.gpg) +.Ed +.Pp +where +.Em /path/to/passwd.gpg +is a GPG-encrypted plain text file containing only your password. +This line would mean that you would be asked for the passphrase required to +decrypt your password file before authenticating. This way, your password +is not in plain text. + +More information on configuration options can be found in +.Xr matrix-send.conf 5 . +.Pp +To use +.Nm , +you will need to get the Room ID of the room you'd like to send to. +This will be something like +.Em !zyxwvutsrq:example.org . + +Type the Room ID as the argument after the message you wish to send. +You may have to escape the exclamation mark with a backslash. For example: +.Bd -literal -offset indent +matrix-send "Hello world!" \!zyxwvutsrq:example.org +.Ed +.Pp +That should send a message saying +.Em Hello world! +to the room with the Room ID !zyxwvutsrq:example.org. + +By default, +.Nm +caches access tokens in +.Em $HOME/.cache/matrix-send/access-token . +If you would like to disable caching of access tokens, add NoCache to your +.Em matrix-send.conf . +.El + +.Sh FILES +.Bl -tag -width ~/.config/matrix-send.conf +.It Pa ~/.config/matrix-send.conf +configuration file for +.Nm +.It Pa ~/.cache/matrix-send/access-token +access token cache file +.El + +.Sh SEE ALSO +.Xr matrix-send.conf 5 From 867531d31b848478d6b87b576a3d7f285f30d57b Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 28 Jul 2022 18:28:52 +1200 Subject: [PATCH 029/133] Added matrix-send.conf(5) manpage --- matrix-send.conf.5 | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 matrix-send.conf.5 diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 new file mode 100644 index 0000000..6ab963d --- /dev/null +++ b/matrix-send.conf.5 @@ -0,0 +1,59 @@ +.Dd $Mdocdate: July 28 2022 $ +.Dt MATRIX-SEND.CONF 5 +.Os +.Sh NAME +.Nm matrix-send.conf +.Nd configuration file for +.Xr matrix-send 1 +.Sh DESCRIPTION +.Pp +.Xr matrix-send 1 +sends messages to Matrix rooms. In order to send a message however, it needs +credentials for the account sending the message. These credentials are provided +in the +.Nm +configuration file, as well as other options if you need them. +.Pp +The following directives are available: +.Bl -bullet +.It +Server +.Ar server + The Client-Server API URL for your Matrix server. +.It +Username +.Ar username + Your Matrix username. +.It +Password +.Ar password + The password to your Matrix account. +.It +AccessToken +.Ar token + Instead of using a username and password to obtain an access token, just use +.Ar token . +.It +CacheLocation +.Ar location + Instead of caching access tokens to ~/.cache, cache them to +.Ar location . +.El +.Pp +The following statements are available: +.Bl -bullet +.It +NoCache + Don't cache access tokens. +.El +.Sh FILES +.Bl -tag -width ~/.config/matrix-send.conf +.It Pa ~/.config/matrix-send.conf +configuration file for +.Nm +.It Pa ~/.cache/matrix-send/access-token +default access token cache file +.El + +.Sh SEE ALSO +.Xr matrix-send 1 From e59bb405d6d90eeacb321b66fd038ffaff087baf Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 28 Jul 2022 18:28:52 +1200 Subject: [PATCH 030/133] Added matrix-send.conf(5) manpage --- matrix-send.conf.5 | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 matrix-send.conf.5 diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 new file mode 100644 index 0000000..6ab963d --- /dev/null +++ b/matrix-send.conf.5 @@ -0,0 +1,59 @@ +.Dd $Mdocdate: July 28 2022 $ +.Dt MATRIX-SEND.CONF 5 +.Os +.Sh NAME +.Nm matrix-send.conf +.Nd configuration file for +.Xr matrix-send 1 +.Sh DESCRIPTION +.Pp +.Xr matrix-send 1 +sends messages to Matrix rooms. In order to send a message however, it needs +credentials for the account sending the message. These credentials are provided +in the +.Nm +configuration file, as well as other options if you need them. +.Pp +The following directives are available: +.Bl -bullet +.It +Server +.Ar server + The Client-Server API URL for your Matrix server. +.It +Username +.Ar username + Your Matrix username. +.It +Password +.Ar password + The password to your Matrix account. +.It +AccessToken +.Ar token + Instead of using a username and password to obtain an access token, just use +.Ar token . +.It +CacheLocation +.Ar location + Instead of caching access tokens to ~/.cache, cache them to +.Ar location . +.El +.Pp +The following statements are available: +.Bl -bullet +.It +NoCache + Don't cache access tokens. +.El +.Sh FILES +.Bl -tag -width ~/.config/matrix-send.conf +.It Pa ~/.config/matrix-send.conf +configuration file for +.Nm +.It Pa ~/.cache/matrix-send/access-token +default access token cache file +.El + +.Sh SEE ALSO +.Xr matrix-send 1 From 299ddafdb9c6dedd78faad0b0a1ff040112a3db5 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 28 Jul 2022 18:31:13 +1200 Subject: [PATCH 031/133] Fixed a few issues --- matrix-send | 89 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 23 deletions(-) mode change 100755 => 100644 matrix-send diff --git a/matrix-send b/matrix-send old mode 100755 new mode 100644 index 7917dc9..2b3452e --- a/matrix-send +++ b/matrix-send @@ -1,9 +1,7 @@ -#!/bin/sh -# matrix-send: a super-simple command-line matrix client +#!/usr/bin/env sh +# matrix-send: send a message to a Matrix room -Version="dev_rolling" - -[ -e /usr/bin/curl ] || printf "\033[31;1merror:\033[0m curl not found\n" +version="1.0" ########################### #### Generic Functions #### @@ -14,44 +12,77 @@ error () { exit 1 } -conf_error () { printf "\033[31;1mconfiguration error:\033[0m $1\n" exit 2 +conf_error () { + printf "\033[31;1mconfiguration error:\033[0m $1\n" + exit 2 } vargrep () { printf "$2\n" | grep "$1" $3 } +usage () { + printf "usage: $0 [-c] [-h] [-V] message room\n" + exit 1 +} + +help () { + cat < Date: Thu, 28 Jul 2022 18:31:13 +1200 Subject: [PATCH 032/133] Fixed a few issues --- matrix-send | 89 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 23 deletions(-) mode change 100755 => 100644 matrix-send diff --git a/matrix-send b/matrix-send old mode 100755 new mode 100644 index 7917dc9..2b3452e --- a/matrix-send +++ b/matrix-send @@ -1,9 +1,7 @@ -#!/bin/sh -# matrix-send: a super-simple command-line matrix client +#!/usr/bin/env sh +# matrix-send: send a message to a Matrix room -Version="dev_rolling" - -[ -e /usr/bin/curl ] || printf "\033[31;1merror:\033[0m curl not found\n" +version="1.0" ########################### #### Generic Functions #### @@ -14,44 +12,77 @@ error () { exit 1 } -conf_error () { printf "\033[31;1mconfiguration error:\033[0m $1\n" exit 2 +conf_error () { + printf "\033[31;1mconfiguration error:\033[0m $1\n" + exit 2 } vargrep () { printf "$2\n" | grep "$1" $3 } +usage () { + printf "usage: $0 [-c] [-h] [-V] message room\n" + exit 1 +} + +help () { + cat < Date: Thu, 28 Jul 2022 20:34:01 +1200 Subject: [PATCH 033/133] Made the Makefile proper --- Makefile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7d39ff7..91ab75d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,14 @@ -install: - cp matrix-send /bin +VERSION = 1.0 +PREFIX = /usr/local +MANPREFIX = ${PREFIX}/man + config: - cp matrix-send.conf ~/.config/ + cp matrix-send.conf ~/.config/matrix-send.conf + +install: + cp -f matrix-send ${DESTDIR}${PREFIX}/bin + mkdir -p ${DESTDIR}${MANPREFIX}/man1 + cp -f matrix-send.1 ${DESTDIR}${MANPREFIX}/man1 + mkdir -p ${DESTDIR}${MANPREFIX}/man5 + cp -f matrix-send.conf.5 ${DESTDIR}${MANPREFIX}/man5 + makewhatis ${DESTDIR}${MANPREFIX} From a62caaeb133eb07cc5517ee53b779a9082129bf2 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 28 Jul 2022 20:34:01 +1200 Subject: [PATCH 034/133] Made the Makefile proper --- Makefile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7d39ff7..91ab75d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,14 @@ -install: - cp matrix-send /bin +VERSION = 1.0 +PREFIX = /usr/local +MANPREFIX = ${PREFIX}/man + config: - cp matrix-send.conf ~/.config/ + cp matrix-send.conf ~/.config/matrix-send.conf + +install: + cp -f matrix-send ${DESTDIR}${PREFIX}/bin + mkdir -p ${DESTDIR}${MANPREFIX}/man1 + cp -f matrix-send.1 ${DESTDIR}${MANPREFIX}/man1 + mkdir -p ${DESTDIR}${MANPREFIX}/man5 + cp -f matrix-send.conf.5 ${DESTDIR}${MANPREFIX}/man5 + makewhatis ${DESTDIR}${MANPREFIX} From 05e4569820c9fd0ba899c6b77e76af48d78d381b Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 28 Jul 2022 20:34:30 +1200 Subject: [PATCH 035/133] Updated matrix-send.conf --- matrix-send.conf | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/matrix-send.conf b/matrix-send.conf index fce7e7e..a7582ab 100644 --- a/matrix-send.conf +++ b/matrix-send.conf @@ -1,17 +1,17 @@ ## Example basic configuration for matrix-send # A line with an option (e.g. 'Username jeremy') is a "directive". -# A line with only one word (e.g. 'Color') is a "statement". +# A line with only one word (e.g. 'NoCache') is a "statement". # Comments start with a pound (#) -# Additional options can be found in config.md in the Git repository +# Additional options can be found in matrix-send.conf(5) -# The Homeserver directive is for your homeserver's Matrix URL. matrix-send assumes that this is valid. -# matrix.org's would be matrix-client.matrix.org. +# The Server directive is for your server's Matrix Client-Server API URL. +# matrix-send assumes that this is valid. +# matrix.org's CS API URL is matrix-client.matrix.org. # You can find it by typing it into Element's sign in page and hovering your mouse over it. -Homeserver matrix-client.matrix.org +Server matrix.envs.net -# The Username directive is for your username for that homeserver. -Username john_doe +# The Username directive is your username for that server. +Username john # The Password directive is your password for your account. -# Example with spaces: Password This is my super duper secure password. Password supersecretpassword From ac8c2c42ead0f51808142f1cc0db8deaf4486ff4 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 28 Jul 2022 20:34:30 +1200 Subject: [PATCH 036/133] Updated matrix-send.conf --- matrix-send.conf | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/matrix-send.conf b/matrix-send.conf index fce7e7e..a7582ab 100644 --- a/matrix-send.conf +++ b/matrix-send.conf @@ -1,17 +1,17 @@ ## Example basic configuration for matrix-send # A line with an option (e.g. 'Username jeremy') is a "directive". -# A line with only one word (e.g. 'Color') is a "statement". +# A line with only one word (e.g. 'NoCache') is a "statement". # Comments start with a pound (#) -# Additional options can be found in config.md in the Git repository +# Additional options can be found in matrix-send.conf(5) -# The Homeserver directive is for your homeserver's Matrix URL. matrix-send assumes that this is valid. -# matrix.org's would be matrix-client.matrix.org. +# The Server directive is for your server's Matrix Client-Server API URL. +# matrix-send assumes that this is valid. +# matrix.org's CS API URL is matrix-client.matrix.org. # You can find it by typing it into Element's sign in page and hovering your mouse over it. -Homeserver matrix-client.matrix.org +Server matrix.envs.net -# The Username directive is for your username for that homeserver. -Username john_doe +# The Username directive is your username for that server. +Username john # The Password directive is your password for your account. -# Example with spaces: Password This is my super duper secure password. Password supersecretpassword From 98396c27cb7e6198f0bf4eb82364592c4b49894b Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 28 Jul 2022 20:34:50 +1200 Subject: [PATCH 037/133] Fixed mistakes in matrix-send.conf(5) --- matrix-send.conf.5 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index 6ab963d..23e4ba1 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -3,8 +3,7 @@ .Os .Sh NAME .Nm matrix-send.conf -.Nd configuration file for -.Xr matrix-send 1 +.Nd configuration file for matrix-send(1) .Sh DESCRIPTION .Pp .Xr matrix-send 1 From a3e94791b972765c30afb3fb2b577a2e09af83a0 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 28 Jul 2022 20:34:50 +1200 Subject: [PATCH 038/133] Fixed mistakes in matrix-send.conf(5) --- matrix-send.conf.5 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index 6ab963d..23e4ba1 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -3,8 +3,7 @@ .Os .Sh NAME .Nm matrix-send.conf -.Nd configuration file for -.Xr matrix-send 1 +.Nd configuration file for matrix-send(1) .Sh DESCRIPTION .Pp .Xr matrix-send 1 From 81a02d9cfe4fef8438fcce5ac0aa66dc6e5bb62d Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 28 Jul 2022 20:41:32 +1200 Subject: [PATCH 039/133] Updated documentation --- README.md | 24 +++++++++++------------- config.md | 18 ++++++++++-------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index fcec648..89716b7 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,9 @@ You will see three "directives"; configuration options that take an argument. Di Directive Argument -Modify the `Homeserver` directive to match your homeserver's Matrix URL. If you're using matrix.org you can leave it as default. +Modify the `Server` directive to match your server's Matrix URL. If you're using matrix.org you can leave it as default. -If you're not using matrix.org, one way you can find your homeserver's Matrix URL is by typing your homeserver's address into Element. Click Continue, and hover over your homeserver's address that popped up. The Matrix URL should be showing. +If you're not using matrix.org, one way you can find your server's Matrix URL is by typing your server's address into Element. Click Continue, and hover over your server's address that popped up. The Matrix URL should be showing. Set the `Username` directive to your username, and the `Password` directive to your password. @@ -43,9 +43,9 @@ This will open `gpg` to decrypt a file with your password inside. You will need After you've finished changing these, your configuration should look like this (without the comments): - Homeserver matrix-client.matrix.org # or your homeserver - Username jeremy # or your name - Password mysupersecurepassword # or your password + Server matrix-client.matrix.org # or your server + Username jeremy # your name + Password mysupersecurepassword # your password After you have these three directives set, you're ready to start. @@ -53,18 +53,16 @@ Additional directives can be found in [config.md](https://github.com/jtbx/matrix --- -To install, run `sudo make install` in the cloned repository's directory. +To install, run `make install` as root, in the cloned repository's directory. - sudo make install + make install Now, using your Matrix client, make a room, and find the Room ID. On Element, right click your room, and click Advanced. Your Room ID is under "Internal Room ID". -Your Room ID will start with a '!'. Remove this symbol from the start and copy the new ID. +To send a message to your chosen room, type `matrix-send` followed by your message (in speech marks) and then your Room ID. You may need to escape the exclamation mark(s). For example: -To send a message to your chosen room, type `matrix-send` followed by your message (in speech marks) and then your Room ID. For example: + matrix-send "Hi\!" \!asdfasdfasdfasdf:matrix.org - matrix-send "Hi\!" asdfasdfasdfasdf:matrix.org +That will send the message "Hi!" to the Matrix room !asdfasdfasdfasdf:matrix.org. -And that will send the message "Hi!" to the Matrix room asdfasdfasdfasdf:matrix.org. - -Also, if you type exclamation marks '!' in a message, some shells misinterpret that as an event. To fix this, I put a backslash `\` before the exclamation mark. +For a more detailed guide, see the manual page `man matrix-send`. diff --git a/config.md b/config.md index b848b35..5134237 100644 --- a/config.md +++ b/config.md @@ -7,16 +7,18 @@ Comments can be made in the file with a hashtag (`#`). ## Directives -Options you can modify with an argument. +Options that take an argument. -* `Homeserver`: The homeserver to log into -* `Username`: The user's name used to log in -* `Password`: The user's password used to log in -* `AccessToken`: A custom access token to use for logging in, instead of generating a new one from login credentials -* `CacheLocation`: A custom location to cache access tokens in. Defaults to $HOME/.cache + * `Server`: The server to log into + * `Username`: The user's name used to log in + * `Password`: The user's password used to log in + * `AccessToken`: A custom access token to use for logging in (overrides username+password) + * `CacheLocation`: A custom location to cache access tokens in. Defaults to $HOME/.cache ## Statements -Options that say one thing and nothing else. You can't change these. +Options that do not take an argument. -* `NoCache`: Don't cache access tokens + * `NoCache`: Don't cache access tokens + +For more information, take a look at the manual page (`man matrix-send.conf`). From 9a190042c51e1e29f4d1fea3a805f3ab9f32fdfb Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 28 Jul 2022 20:41:32 +1200 Subject: [PATCH 040/133] Updated documentation --- README.md | 24 +++++++++++------------- config.md | 18 ++++++++++-------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index fcec648..89716b7 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,9 @@ You will see three "directives"; configuration options that take an argument. Di Directive Argument -Modify the `Homeserver` directive to match your homeserver's Matrix URL. If you're using matrix.org you can leave it as default. +Modify the `Server` directive to match your server's Matrix URL. If you're using matrix.org you can leave it as default. -If you're not using matrix.org, one way you can find your homeserver's Matrix URL is by typing your homeserver's address into Element. Click Continue, and hover over your homeserver's address that popped up. The Matrix URL should be showing. +If you're not using matrix.org, one way you can find your server's Matrix URL is by typing your server's address into Element. Click Continue, and hover over your server's address that popped up. The Matrix URL should be showing. Set the `Username` directive to your username, and the `Password` directive to your password. @@ -43,9 +43,9 @@ This will open `gpg` to decrypt a file with your password inside. You will need After you've finished changing these, your configuration should look like this (without the comments): - Homeserver matrix-client.matrix.org # or your homeserver - Username jeremy # or your name - Password mysupersecurepassword # or your password + Server matrix-client.matrix.org # or your server + Username jeremy # your name + Password mysupersecurepassword # your password After you have these three directives set, you're ready to start. @@ -53,18 +53,16 @@ Additional directives can be found in [config.md](https://github.com/jtbx/matrix --- -To install, run `sudo make install` in the cloned repository's directory. +To install, run `make install` as root, in the cloned repository's directory. - sudo make install + make install Now, using your Matrix client, make a room, and find the Room ID. On Element, right click your room, and click Advanced. Your Room ID is under "Internal Room ID". -Your Room ID will start with a '!'. Remove this symbol from the start and copy the new ID. +To send a message to your chosen room, type `matrix-send` followed by your message (in speech marks) and then your Room ID. You may need to escape the exclamation mark(s). For example: -To send a message to your chosen room, type `matrix-send` followed by your message (in speech marks) and then your Room ID. For example: + matrix-send "Hi\!" \!asdfasdfasdfasdf:matrix.org - matrix-send "Hi\!" asdfasdfasdfasdf:matrix.org +That will send the message "Hi!" to the Matrix room !asdfasdfasdfasdf:matrix.org. -And that will send the message "Hi!" to the Matrix room asdfasdfasdfasdf:matrix.org. - -Also, if you type exclamation marks '!' in a message, some shells misinterpret that as an event. To fix this, I put a backslash `\` before the exclamation mark. +For a more detailed guide, see the manual page `man matrix-send`. diff --git a/config.md b/config.md index b848b35..5134237 100644 --- a/config.md +++ b/config.md @@ -7,16 +7,18 @@ Comments can be made in the file with a hashtag (`#`). ## Directives -Options you can modify with an argument. +Options that take an argument. -* `Homeserver`: The homeserver to log into -* `Username`: The user's name used to log in -* `Password`: The user's password used to log in -* `AccessToken`: A custom access token to use for logging in, instead of generating a new one from login credentials -* `CacheLocation`: A custom location to cache access tokens in. Defaults to $HOME/.cache + * `Server`: The server to log into + * `Username`: The user's name used to log in + * `Password`: The user's password used to log in + * `AccessToken`: A custom access token to use for logging in (overrides username+password) + * `CacheLocation`: A custom location to cache access tokens in. Defaults to $HOME/.cache ## Statements -Options that say one thing and nothing else. You can't change these. +Options that do not take an argument. -* `NoCache`: Don't cache access tokens + * `NoCache`: Don't cache access tokens + +For more information, take a look at the manual page (`man matrix-send.conf`). From 87490ca7f4db58732610e2d0a55c66e8c29b309d Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Fri, 29 Jul 2022 06:20:04 +1200 Subject: [PATCH 041/133] Removed Linux incompatibility --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 91ab75d..31e76e8 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,3 @@ install: cp -f matrix-send.1 ${DESTDIR}${MANPREFIX}/man1 mkdir -p ${DESTDIR}${MANPREFIX}/man5 cp -f matrix-send.conf.5 ${DESTDIR}${MANPREFIX}/man5 - makewhatis ${DESTDIR}${MANPREFIX} From c6fd42e18f641932ee00af86b8235207e8153a0c Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 29 Jul 2022 06:20:04 +1200 Subject: [PATCH 042/133] Removed Linux incompatibility --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 91ab75d..31e76e8 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,3 @@ install: cp -f matrix-send.1 ${DESTDIR}${MANPREFIX}/man1 mkdir -p ${DESTDIR}${MANPREFIX}/man5 cp -f matrix-send.conf.5 ${DESTDIR}${MANPREFIX}/man5 - makewhatis ${DESTDIR}${MANPREFIX} From bbd8866e43a34896e4c714b68d8a6b4049c52c23 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Fri, 29 Jul 2022 06:20:19 +1200 Subject: [PATCH 043/133] Fix formatting of manpage --- matrix-send.1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/matrix-send.1 b/matrix-send.1 index d82deb3..6476812 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -27,7 +27,8 @@ At the very least, your configuration file has to contain 3 directives: .Em Username , and .Em Password . -Let's say your Matrix server is envs.net. Your username is john, and your password is supersecretpassword. Your configuration could look like this: +Let's say your Matrix server is envs.net. Your username is john, and your password +is supersecretpassword. Your configuration could look like this: .Bd -literal -offset indent Server matrix.envs.net Username john From 90b8004da6e005089cc174a5d56f1479b34623b9 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 29 Jul 2022 06:20:19 +1200 Subject: [PATCH 044/133] Fix formatting of manpage --- matrix-send.1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/matrix-send.1 b/matrix-send.1 index d82deb3..6476812 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -27,7 +27,8 @@ At the very least, your configuration file has to contain 3 directives: .Em Username , and .Em Password . -Let's say your Matrix server is envs.net. Your username is john, and your password is supersecretpassword. Your configuration could look like this: +Let's say your Matrix server is envs.net. Your username is john, and your password +is supersecretpassword. Your configuration could look like this: .Bd -literal -offset indent Server matrix.envs.net Username john From 0e7b46743934ae9412ad9cf5877229591aee3822 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Fri, 29 Jul 2022 06:20:51 +1200 Subject: [PATCH 045/133] Added Markdown manpages --- doc/Makefile | 3 ++ doc/README.md | 7 +++ doc/matrix-send.1.md | 102 ++++++++++++++++++++++++++++++++++++++ doc/matrix-send.conf.5.md | 60 ++++++++++++++++++++++ 4 files changed, 172 insertions(+) create mode 100644 doc/Makefile create mode 100644 doc/README.md create mode 100644 doc/matrix-send.1.md create mode 100644 doc/matrix-send.conf.5.md diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..4537bb3 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,3 @@ +generate: + man -cT markdown ../matrix-send.1 > matrix-send.1.md + man -cT markdown ../matrix-send.conf.5 > matrix-send.conf.5.md diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 0000000..fc0bd8a --- /dev/null +++ b/doc/README.md @@ -0,0 +1,7 @@ +# Manual pages + +This directory contains the manual pages for matrix-send. + +They are automatically generated from the man page, so if you already have matrix-send installed you can view these documents offline by typing `man matrix-send`. + +To generate these Markdown documents, enter this directory and type `make generate`. diff --git a/doc/matrix-send.1.md b/doc/matrix-send.1.md new file mode 100644 index 0000000..962814a --- /dev/null +++ b/doc/matrix-send.1.md @@ -0,0 +1,102 @@ +MATRIX-SEND(1) - General Commands Manual + +# NAME + +**matrix-send** - send a message to a Matrix room + +# SYNOPSIS + +**matrix-send** +\[**-c**] +\[**-h**] +\[**-v**] +*message room* + +# DESCRIPTION + +**matrix-send** +is a script to send a message to a Matrix room. +It works by sending a JSON request to your Matrix server. The message +type will always be m.text, but other options may be considered in the +future. + +To begin, start by making a configuration file. This always has the location of +*~/.config/matrix-send.conf*. + +At the very least, your configuration file has to contain 3 directives: +*Server*, +*Username*, +and +*Password*. +Let's say your Matrix server is envs.net. Your username is john, and your password +is supersecretpassword. Your configuration could look like this: + + Server matrix.envs.net + Username john + Password supersecretpassword + +In that example, we used matrix.envs.net instead of envs.net. This is because +matrix.envs.net is the address in which the Client-Server API is listening on. +You can find your server's Client-Server API URL in Element by entering in +your server into the Homeserver dialogue in the sign-in screen, then hovering +over it once entered. Your server's Client-Server API URL should appear once +you hover over it. If it doesn't appear, you've already got it. + +You may have noticed that with this configuration, your password +is visible in plain sight. + +At its most basic, matrix-send.conf is a shell script. This means you could +replace the +*Password* +line with something similar to this + + Password $(gpg -d /path/to/passwd.gpg) + +where +*/path/to/passwd.gpg* +is a GPG-encrypted plain text file containing only your password. +This line would mean that you would be asked for the passphrase required to +decrypt your password file before authenticating. This way, your password +is not in plain text. + +More information on configuration options can be found in +matrix-send.conf(5). + +To use +**matrix-send**, +you will need to get the Room ID of the room you'd like to send to. +This will be something like +*!zyxwvutsrq:example.org*. + +Type the Room ID as the argument after the message you wish to send. +You may have to escape the exclamation mark with a backslash. For example: + + matrix-send "Hello world!" zyxwvutsrq:example.org + +That should send a message saying +*Hello world!* +to the room with the Room ID !zyxwvutsrq:example.org. + +By default, +**matrix-send** +caches access tokens in +*$HOME/.cache/matrix-send/access-token*. +If you would like to disable caching of access tokens, add NoCache to your +*matrix-send.conf*. + +# FILES + +*~/.config/matrix-send.conf* + +> configuration file for +> **matrix-send** + +*~/.cache/matrix-send/access-token* + +> access token cache file + +# SEE ALSO + +matrix-send.conf(5) + +OpenBSD 7.1 - July 28, 2022 diff --git a/doc/matrix-send.conf.5.md b/doc/matrix-send.conf.5.md new file mode 100644 index 0000000..ba3f333 --- /dev/null +++ b/doc/matrix-send.conf.5.md @@ -0,0 +1,60 @@ +MATRIX-SEND.CONF(5) - File Formats Manual + +# NAME + +**matrix-send.conf** - configuration file for matrix-send(1) + +# DESCRIPTION + +matrix-send(1) +sends messages to Matrix rooms. In order to send a message however, it needs +credentials for the account sending the message. These credentials are provided +in the +**matrix-send.conf** +configuration file, as well as other options if you need them. + +The following directives are available: + +* Server + *server* + The Client-Server API URL for your Matrix server. + +* Username + *username* + Your Matrix username. + +* Password + *password* + The password to your Matrix account. + +* AccessToken + *token* + Instead of using a username and password to obtain an access token, just use + *token*. + +* CacheLocation + *location* + Instead of caching access tokens to ~/.cache, cache them to + *location*. + +The following statements are available: + +* NoCache + Don't cache access tokens. + +# FILES + +*~/.config/matrix-send.conf* + +> configuration file for +> **matrix-send.conf** + +*~/.cache/matrix-send/access-token* + +> default access token cache file + +# SEE ALSO + +matrix-send(1) + +OpenBSD 7.1 - July 28, 2022 From e74a9186e5002dcfbfbbe43af690d73ff07e19af Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 29 Jul 2022 06:20:51 +1200 Subject: [PATCH 046/133] Added Markdown manpages --- doc/Makefile | 3 ++ doc/README.md | 7 +++ doc/matrix-send.1.md | 102 ++++++++++++++++++++++++++++++++++++++ doc/matrix-send.conf.5.md | 60 ++++++++++++++++++++++ 4 files changed, 172 insertions(+) create mode 100644 doc/Makefile create mode 100644 doc/README.md create mode 100644 doc/matrix-send.1.md create mode 100644 doc/matrix-send.conf.5.md diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..4537bb3 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,3 @@ +generate: + man -cT markdown ../matrix-send.1 > matrix-send.1.md + man -cT markdown ../matrix-send.conf.5 > matrix-send.conf.5.md diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 0000000..fc0bd8a --- /dev/null +++ b/doc/README.md @@ -0,0 +1,7 @@ +# Manual pages + +This directory contains the manual pages for matrix-send. + +They are automatically generated from the man page, so if you already have matrix-send installed you can view these documents offline by typing `man matrix-send`. + +To generate these Markdown documents, enter this directory and type `make generate`. diff --git a/doc/matrix-send.1.md b/doc/matrix-send.1.md new file mode 100644 index 0000000..962814a --- /dev/null +++ b/doc/matrix-send.1.md @@ -0,0 +1,102 @@ +MATRIX-SEND(1) - General Commands Manual + +# NAME + +**matrix-send** - send a message to a Matrix room + +# SYNOPSIS + +**matrix-send** +\[**-c**] +\[**-h**] +\[**-v**] +*message room* + +# DESCRIPTION + +**matrix-send** +is a script to send a message to a Matrix room. +It works by sending a JSON request to your Matrix server. The message +type will always be m.text, but other options may be considered in the +future. + +To begin, start by making a configuration file. This always has the location of +*~/.config/matrix-send.conf*. + +At the very least, your configuration file has to contain 3 directives: +*Server*, +*Username*, +and +*Password*. +Let's say your Matrix server is envs.net. Your username is john, and your password +is supersecretpassword. Your configuration could look like this: + + Server matrix.envs.net + Username john + Password supersecretpassword + +In that example, we used matrix.envs.net instead of envs.net. This is because +matrix.envs.net is the address in which the Client-Server API is listening on. +You can find your server's Client-Server API URL in Element by entering in +your server into the Homeserver dialogue in the sign-in screen, then hovering +over it once entered. Your server's Client-Server API URL should appear once +you hover over it. If it doesn't appear, you've already got it. + +You may have noticed that with this configuration, your password +is visible in plain sight. + +At its most basic, matrix-send.conf is a shell script. This means you could +replace the +*Password* +line with something similar to this + + Password $(gpg -d /path/to/passwd.gpg) + +where +*/path/to/passwd.gpg* +is a GPG-encrypted plain text file containing only your password. +This line would mean that you would be asked for the passphrase required to +decrypt your password file before authenticating. This way, your password +is not in plain text. + +More information on configuration options can be found in +matrix-send.conf(5). + +To use +**matrix-send**, +you will need to get the Room ID of the room you'd like to send to. +This will be something like +*!zyxwvutsrq:example.org*. + +Type the Room ID as the argument after the message you wish to send. +You may have to escape the exclamation mark with a backslash. For example: + + matrix-send "Hello world!" zyxwvutsrq:example.org + +That should send a message saying +*Hello world!* +to the room with the Room ID !zyxwvutsrq:example.org. + +By default, +**matrix-send** +caches access tokens in +*$HOME/.cache/matrix-send/access-token*. +If you would like to disable caching of access tokens, add NoCache to your +*matrix-send.conf*. + +# FILES + +*~/.config/matrix-send.conf* + +> configuration file for +> **matrix-send** + +*~/.cache/matrix-send/access-token* + +> access token cache file + +# SEE ALSO + +matrix-send.conf(5) + +OpenBSD 7.1 - July 28, 2022 diff --git a/doc/matrix-send.conf.5.md b/doc/matrix-send.conf.5.md new file mode 100644 index 0000000..ba3f333 --- /dev/null +++ b/doc/matrix-send.conf.5.md @@ -0,0 +1,60 @@ +MATRIX-SEND.CONF(5) - File Formats Manual + +# NAME + +**matrix-send.conf** - configuration file for matrix-send(1) + +# DESCRIPTION + +matrix-send(1) +sends messages to Matrix rooms. In order to send a message however, it needs +credentials for the account sending the message. These credentials are provided +in the +**matrix-send.conf** +configuration file, as well as other options if you need them. + +The following directives are available: + +* Server + *server* + The Client-Server API URL for your Matrix server. + +* Username + *username* + Your Matrix username. + +* Password + *password* + The password to your Matrix account. + +* AccessToken + *token* + Instead of using a username and password to obtain an access token, just use + *token*. + +* CacheLocation + *location* + Instead of caching access tokens to ~/.cache, cache them to + *location*. + +The following statements are available: + +* NoCache + Don't cache access tokens. + +# FILES + +*~/.config/matrix-send.conf* + +> configuration file for +> **matrix-send.conf** + +*~/.cache/matrix-send/access-token* + +> default access token cache file + +# SEE ALSO + +matrix-send(1) + +OpenBSD 7.1 - July 28, 2022 From cdfbffc9320bb3f8bc8e9dae9d1a12726481b0f1 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Fri, 29 Jul 2022 06:39:05 +1200 Subject: [PATCH 047/133] Update README.md --- README.md | 63 +++++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 89716b7..efb71a9 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,17 @@ A script to send a message to a Matrix room. --- -**Syntax:** `matrix-send ` +**Syntax:** `matrix-send message room` -**For example:** `matrix-send "Hello world\!" aBcDeFgHiJkLmNoP:matrix.org` +**For example:** `matrix-send "Hello world\!" \!aBcDeFgHiJkLmNoP:example.org` --- -`matrix-send` is a simple script to interact with a Matrix homeserver in order to send a message to a room. +`matrix-send` is a simple script to send a message to a Matrix room. -If you don't understand, `matrix-send` is an oversimplified Matrix client. +It does this by sending a JSON message to your Matrix server. The message type supported is currently only m.text, but other types will be supported. -It is mainly designed for automation. I use it on my Matrix room. +It is mainly designed for automation. I use it on a private Matrix room of mine. `matrix-send` doesn't have support for end-to-end encryption, and never will. @@ -21,48 +21,41 @@ It is mainly designed for automation. I use it on my Matrix room. In order to start using `matrix-send` you need a config file. To copy the configuration to .config, clone this repository and type: - make config +```shell +$ make config +``` -The configuration has now been copied to ~/.config, so open the file ~/.config/matrix-send.conf with your favourite text editor. +Now edit the file ~/.config/matrix-send.conf. You will see three (uncommented) lines. -You will see three "directives"; configuration options that take an argument. Directives' syntax look like so: +```shell +Server ... +Username ... +Password ... +``` - Directive Argument +Delete the example values and enter in your credentials. -Modify the `Server` directive to match your server's Matrix URL. If you're using matrix.org you can leave it as default. +If you don't want to put your password in plain text, since matrix-send.conf is a shell script, you could do something like this: -If you're not using matrix.org, one way you can find your server's Matrix URL is by typing your server's address into Element. Click Continue, and hover over your server's address that popped up. The Matrix URL should be showing. +```shell +Password $(gpg -d /path/to/passwd.gpg) +``` -Set the `Username` directive to your username, and the `Password` directive to your password. - -You might not want to put your password in plain text, so you could do something like this instead: - - Password $(gpg -d ~/.matrix_pass.gpg) - -This will open `gpg` to decrypt a file with your password inside. You will need to set this up first. - -After you've finished changing these, your configuration should look like this (without the comments): - - Server matrix-client.matrix.org # or your server - Username jeremy # your name - Password mysupersecurepassword # your password - -After you have these three directives set, you're ready to start. - -Additional directives can be found in [config.md](https://github.com/jtbx/matrix-send/blob/main/config.md). +/path/to/passwd.gpg is a GPG-encrypted file containing only your password, once decrypted. --- -To install, run `make install` as root, in the cloned repository's directory. +To install matrix-send, run `make install` as root, in the cloned repository's directory. +```shell +# make install +``` - make install +In order to send messages, you need your Room ID. Find the room you want to send to, and find its Room ID in the settings or somewhere else. It will likely be under Advanced or something similar. -Now, using your Matrix client, make a room, and find the Room ID. On Element, right click your room, and click Advanced. Your Room ID is under "Internal Room ID". +To send a message, type `matrix-send` followed by your message and then your Room ID. You may need to escape the exclamation mark(s). For example: -To send a message to your chosen room, type `matrix-send` followed by your message (in speech marks) and then your Room ID. You may need to escape the exclamation mark(s). For example: - - matrix-send "Hi\!" \!asdfasdfasdfasdf:matrix.org + matrix-send 'Hi!' \!asdfasdfasdfasdf:matrix.org That will send the message "Hi!" to the Matrix room !asdfasdfasdfasdf:matrix.org. -For a more detailed guide, see the manual page `man matrix-send`. +For more information, see [matrix-send(1)](https://codeberg.org/jtbx/matrix-send/src/branch/master/doc/matrix-send.1.md). From 08720943926997d0986d5d27eb9b1a8d44aa29b6 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 29 Jul 2022 06:39:05 +1200 Subject: [PATCH 048/133] Update README.md --- README.md | 63 +++++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 89716b7..efb71a9 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,17 @@ A script to send a message to a Matrix room. --- -**Syntax:** `matrix-send ` +**Syntax:** `matrix-send message room` -**For example:** `matrix-send "Hello world\!" aBcDeFgHiJkLmNoP:matrix.org` +**For example:** `matrix-send "Hello world\!" \!aBcDeFgHiJkLmNoP:example.org` --- -`matrix-send` is a simple script to interact with a Matrix homeserver in order to send a message to a room. +`matrix-send` is a simple script to send a message to a Matrix room. -If you don't understand, `matrix-send` is an oversimplified Matrix client. +It does this by sending a JSON message to your Matrix server. The message type supported is currently only m.text, but other types will be supported. -It is mainly designed for automation. I use it on my Matrix room. +It is mainly designed for automation. I use it on a private Matrix room of mine. `matrix-send` doesn't have support for end-to-end encryption, and never will. @@ -21,48 +21,41 @@ It is mainly designed for automation. I use it on my Matrix room. In order to start using `matrix-send` you need a config file. To copy the configuration to .config, clone this repository and type: - make config +```shell +$ make config +``` -The configuration has now been copied to ~/.config, so open the file ~/.config/matrix-send.conf with your favourite text editor. +Now edit the file ~/.config/matrix-send.conf. You will see three (uncommented) lines. -You will see three "directives"; configuration options that take an argument. Directives' syntax look like so: +```shell +Server ... +Username ... +Password ... +``` - Directive Argument +Delete the example values and enter in your credentials. -Modify the `Server` directive to match your server's Matrix URL. If you're using matrix.org you can leave it as default. +If you don't want to put your password in plain text, since matrix-send.conf is a shell script, you could do something like this: -If you're not using matrix.org, one way you can find your server's Matrix URL is by typing your server's address into Element. Click Continue, and hover over your server's address that popped up. The Matrix URL should be showing. +```shell +Password $(gpg -d /path/to/passwd.gpg) +``` -Set the `Username` directive to your username, and the `Password` directive to your password. - -You might not want to put your password in plain text, so you could do something like this instead: - - Password $(gpg -d ~/.matrix_pass.gpg) - -This will open `gpg` to decrypt a file with your password inside. You will need to set this up first. - -After you've finished changing these, your configuration should look like this (without the comments): - - Server matrix-client.matrix.org # or your server - Username jeremy # your name - Password mysupersecurepassword # your password - -After you have these three directives set, you're ready to start. - -Additional directives can be found in [config.md](https://github.com/jtbx/matrix-send/blob/main/config.md). +/path/to/passwd.gpg is a GPG-encrypted file containing only your password, once decrypted. --- -To install, run `make install` as root, in the cloned repository's directory. +To install matrix-send, run `make install` as root, in the cloned repository's directory. +```shell +# make install +``` - make install +In order to send messages, you need your Room ID. Find the room you want to send to, and find its Room ID in the settings or somewhere else. It will likely be under Advanced or something similar. -Now, using your Matrix client, make a room, and find the Room ID. On Element, right click your room, and click Advanced. Your Room ID is under "Internal Room ID". +To send a message, type `matrix-send` followed by your message and then your Room ID. You may need to escape the exclamation mark(s). For example: -To send a message to your chosen room, type `matrix-send` followed by your message (in speech marks) and then your Room ID. You may need to escape the exclamation mark(s). For example: - - matrix-send "Hi\!" \!asdfasdfasdfasdf:matrix.org + matrix-send 'Hi!' \!asdfasdfasdfasdf:matrix.org That will send the message "Hi!" to the Matrix room !asdfasdfasdfasdf:matrix.org. -For a more detailed guide, see the manual page `man matrix-send`. +For more information, see [matrix-send(1)](https://codeberg.org/jtbx/matrix-send/src/branch/master/doc/matrix-send.1.md). From 11c736ae9992a955431b01512571d1c66741ace2 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Fri, 29 Jul 2022 06:49:52 +1200 Subject: [PATCH 049/133] Fix Makefile --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 31e76e8..db545b9 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ config: install: cp -f matrix-send ${DESTDIR}${PREFIX}/bin + chmod +x ${DESTDIR}${PREFIX}/bin/matrix-send mkdir -p ${DESTDIR}${MANPREFIX}/man1 cp -f matrix-send.1 ${DESTDIR}${MANPREFIX}/man1 mkdir -p ${DESTDIR}${MANPREFIX}/man5 From f1d96524e92ad121d3c05e0507ea68c7e2fa2554 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 29 Jul 2022 06:49:52 +1200 Subject: [PATCH 050/133] Fix Makefile --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 31e76e8..db545b9 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ config: install: cp -f matrix-send ${DESTDIR}${PREFIX}/bin + chmod +x ${DESTDIR}${PREFIX}/bin/matrix-send mkdir -p ${DESTDIR}${MANPREFIX}/man1 cp -f matrix-send.1 ${DESTDIR}${MANPREFIX}/man1 mkdir -p ${DESTDIR}${MANPREFIX}/man5 From a4f1622aa04599e80e8666713ef64ed41c83abb5 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Fri, 29 Jul 2022 06:50:07 +1200 Subject: [PATCH 051/133] Added options to matrix-send(1) --- matrix-send.1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/matrix-send.1 b/matrix-send.1 index 6476812..2840e84 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -19,6 +19,16 @@ It works by sending a JSON request to your Matrix server. The message type will always be m.text, but other options may be considered in the future. .Pp +The options are as follows: +.Bl -tag -width keyword +.It Fl c +Clear cached access tokens. +.It Fl h +Show a help menu, then exit. +.It Fl V +Print version and program information, then exit +.El +.Pp To begin, start by making a configuration file. This always has the location of .Em ~/.config/matrix-send.conf . @@ -78,13 +88,17 @@ matrix-send "Hello world!" \!zyxwvutsrq:example.org That should send a message saying .Em Hello world! to the room with the Room ID !zyxwvutsrq:example.org. - +.Pp By default, .Nm caches access tokens in .Em $HOME/.cache/matrix-send/access-token . If you would like to disable caching of access tokens, add NoCache to your .Em matrix-send.conf . +.Pp +Encryption is not supported. All messages will be sent unencrypted. +There are currently no plans to add encryption to +.Nm . .El .Sh FILES From bb2c2c9695ba753b7b162c1a89d35b2debd1adcf Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 29 Jul 2022 06:50:07 +1200 Subject: [PATCH 052/133] Added options to matrix-send(1) --- matrix-send.1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/matrix-send.1 b/matrix-send.1 index 6476812..2840e84 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -19,6 +19,16 @@ It works by sending a JSON request to your Matrix server. The message type will always be m.text, but other options may be considered in the future. .Pp +The options are as follows: +.Bl -tag -width keyword +.It Fl c +Clear cached access tokens. +.It Fl h +Show a help menu, then exit. +.It Fl V +Print version and program information, then exit +.El +.Pp To begin, start by making a configuration file. This always has the location of .Em ~/.config/matrix-send.conf . @@ -78,13 +88,17 @@ matrix-send "Hello world!" \!zyxwvutsrq:example.org That should send a message saying .Em Hello world! to the room with the Room ID !zyxwvutsrq:example.org. - +.Pp By default, .Nm caches access tokens in .Em $HOME/.cache/matrix-send/access-token . If you would like to disable caching of access tokens, add NoCache to your .Em matrix-send.conf . +.Pp +Encryption is not supported. All messages will be sent unencrypted. +There are currently no plans to add encryption to +.Nm . .El .Sh FILES From c74497105b754af44080a0243e92e13924869731 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Fri, 29 Jul 2022 06:50:48 +1200 Subject: [PATCH 053/133] Update markdown manpages --- doc/matrix-send.1.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/matrix-send.1.md b/doc/matrix-send.1.md index 962814a..090f25a 100644 --- a/doc/matrix-send.1.md +++ b/doc/matrix-send.1.md @@ -20,6 +20,20 @@ It works by sending a JSON request to your Matrix server. The message type will always be m.text, but other options may be considered in the future. +The options are as follows: + +**-c** + +> Clear cached access tokens. + +**-h** + +> Show a help menu, then exit. + +**-V** + +> Print version and program information, then exit + To begin, start by making a configuration file. This always has the location of *~/.config/matrix-send.conf*. @@ -84,6 +98,10 @@ caches access tokens in If you would like to disable caching of access tokens, add NoCache to your *matrix-send.conf*. +Encryption is not supported. All messages will be sent unencrypted. +There are currently no plans to add encryption to +**matrix-send**. + # FILES *~/.config/matrix-send.conf* From 90fb1586181606e7e9fdc1c7ba320eddc8e44553 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 29 Jul 2022 06:50:48 +1200 Subject: [PATCH 054/133] Update markdown manpages --- doc/matrix-send.1.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/matrix-send.1.md b/doc/matrix-send.1.md index 962814a..090f25a 100644 --- a/doc/matrix-send.1.md +++ b/doc/matrix-send.1.md @@ -20,6 +20,20 @@ It works by sending a JSON request to your Matrix server. The message type will always be m.text, but other options may be considered in the future. +The options are as follows: + +**-c** + +> Clear cached access tokens. + +**-h** + +> Show a help menu, then exit. + +**-V** + +> Print version and program information, then exit + To begin, start by making a configuration file. This always has the location of *~/.config/matrix-send.conf*. @@ -84,6 +98,10 @@ caches access tokens in If you would like to disable caching of access tokens, add NoCache to your *matrix-send.conf*. +Encryption is not supported. All messages will be sent unencrypted. +There are currently no plans to add encryption to +**matrix-send**. + # FILES *~/.config/matrix-send.conf* From b98624bc7897c8eeabfa56d628b10a1fa7389318 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Fri, 29 Jul 2022 06:54:54 +1200 Subject: [PATCH 055/133] Added getopts and -s option to curl --- matrix-send | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) mode change 100644 => 100755 matrix-send diff --git a/matrix-send b/matrix-send old mode 100644 new mode 100755 index 2b3452e..d758ce2 --- a/matrix-send +++ b/matrix-send @@ -101,7 +101,7 @@ GetAccessToken () { [ -z "$manualAuth" ] && printf "Getting access token...\n" if [ "$manualAuth" = "true" ]; then printf ""; # printf "" basically means do nothing - else token=$(curl -XPOST -d "{"'"'"type"'"'":"'"'"m.login.password"'"'", "'"'"user"'"'":"'"'"$username"'"'", "'"'"password"'"'":"'"'"$password"'"'"}" "https://$server/_matrix/client/r0/login" | grep -oE 'syt_.+_...................._......'); + else token=$(curl -s -XPOST -d "{"'"'"type"'"'":"'"'"m.login.password"'"'", "'"'"user"'"'":"'"'"$username"'"'", "'"'"password"'"'":"'"'"$password"'"'"}" "https://$server/_matrix/client/r0/login" | grep -oE 'syt_.+_...................._......'); fi } @@ -121,7 +121,7 @@ ClearCache () { } Send () { - curl -XPOST -d "{"'"'"msgtype"'"'":"'"'"m.text"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" + curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"m.text"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" } ######################## @@ -131,9 +131,18 @@ Send () { [ -e /usr/local/bin/curl ] || [ -e /usr/bin/curl ] || error "curl not found" [ -z "$1" ] && usage -[ "$1" = "-c" ] && ClearCache -[ "$1" = "-h" ] && help -[ "$1" = "-V" ] && version +#[ "$1" = "-c" ] && ClearCache +#[ "$1" = "-h" ] && help +#[ "$1" = "-V" ] && version + +while getopts :chV opt +do + case $opt in + c) ClearCache ;; + h) help ;; + V) version ;; + esac +done ############################### #### Configuration loading #### From 14a7466c1cb2eb84a4ba1827f84d4909558d3f40 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 29 Jul 2022 06:54:54 +1200 Subject: [PATCH 056/133] Added getopts and -s option to curl --- matrix-send | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) mode change 100644 => 100755 matrix-send diff --git a/matrix-send b/matrix-send old mode 100644 new mode 100755 index 2b3452e..d758ce2 --- a/matrix-send +++ b/matrix-send @@ -101,7 +101,7 @@ GetAccessToken () { [ -z "$manualAuth" ] && printf "Getting access token...\n" if [ "$manualAuth" = "true" ]; then printf ""; # printf "" basically means do nothing - else token=$(curl -XPOST -d "{"'"'"type"'"'":"'"'"m.login.password"'"'", "'"'"user"'"'":"'"'"$username"'"'", "'"'"password"'"'":"'"'"$password"'"'"}" "https://$server/_matrix/client/r0/login" | grep -oE 'syt_.+_...................._......'); + else token=$(curl -s -XPOST -d "{"'"'"type"'"'":"'"'"m.login.password"'"'", "'"'"user"'"'":"'"'"$username"'"'", "'"'"password"'"'":"'"'"$password"'"'"}" "https://$server/_matrix/client/r0/login" | grep -oE 'syt_.+_...................._......'); fi } @@ -121,7 +121,7 @@ ClearCache () { } Send () { - curl -XPOST -d "{"'"'"msgtype"'"'":"'"'"m.text"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" + curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"m.text"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" } ######################## @@ -131,9 +131,18 @@ Send () { [ -e /usr/local/bin/curl ] || [ -e /usr/bin/curl ] || error "curl not found" [ -z "$1" ] && usage -[ "$1" = "-c" ] && ClearCache -[ "$1" = "-h" ] && help -[ "$1" = "-V" ] && version +#[ "$1" = "-c" ] && ClearCache +#[ "$1" = "-h" ] && help +#[ "$1" = "-V" ] && version + +while getopts :chV opt +do + case $opt in + c) ClearCache ;; + h) help ;; + V) version ;; + esac +done ############################### #### Configuration loading #### From 9591bcdaa6600adf1ec54f251ec92c975d54efe8 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Fri, 29 Jul 2022 08:12:43 +1200 Subject: [PATCH 057/133] Added -t option --- doc/matrix-send.1.md | 26 ++++++++++++++++------- doc/matrix-send.conf.5.md | 12 ++++++++--- matrix-send | 44 +++++++++++++++++++++++++-------------- matrix-send.1 | 24 ++++++++++++++------- matrix-send.conf.5 | 12 ++++++++--- 5 files changed, 82 insertions(+), 36 deletions(-) diff --git a/doc/matrix-send.1.md b/doc/matrix-send.1.md index 090f25a..e91dc7a 100644 --- a/doc/matrix-send.1.md +++ b/doc/matrix-send.1.md @@ -7,6 +7,7 @@ MATRIX-SEND(1) - General Commands Manual # SYNOPSIS **matrix-send** +\[**-t** *type*] \[**-c**] \[**-h**] \[**-v**] @@ -16,23 +17,34 @@ MATRIX-SEND(1) - General Commands Manual **matrix-send** is a script to send a message to a Matrix room. -It works by sending a JSON request to your Matrix server. The message -type will always be m.text, but other options may be considered in the -future. +It works by sending a JSON message to your Matrix server. The default message +type is m.text, but you can specify a custom type with +*-t*. The options are as follows: +**-t** *type* + +> Change the event type to +> *type*. +> Currently supported types are +> *m.text* +> and +> *m.notice*. +> Default is +> *m.text*. + **-c** > Clear cached access tokens. **-h** -> Show a help menu, then exit. +> Show the help menu, then exit. **-V** -> Print version and program information, then exit +> Print version and program information, then exit. To begin, start by making a configuration file. This always has the location of *~/.config/matrix-send.conf*. @@ -85,7 +97,7 @@ This will be something like Type the Room ID as the argument after the message you wish to send. You may have to escape the exclamation mark with a backslash. For example: - matrix-send "Hello world!" zyxwvutsrq:example.org + matrix-send "Hello world!" \!zyxwvutsrq:example.org That should send a message saying *Hello world!* @@ -117,4 +129,4 @@ There are currently no plans to add encryption to matrix-send.conf(5) -OpenBSD 7.1 - July 28, 2022 +OpenBSD 7.1 - July 29, 2022 diff --git a/doc/matrix-send.conf.5.md b/doc/matrix-send.conf.5.md index ba3f333..8762563 100644 --- a/doc/matrix-send.conf.5.md +++ b/doc/matrix-send.conf.5.md @@ -21,7 +21,7 @@ The following directives are available: * Username *username* - Your Matrix username. + The username of your Matrix account. * Password *password* @@ -29,7 +29,7 @@ The following directives are available: * AccessToken *token* - Instead of using a username and password to obtain an access token, just use + Instead of using a username and password to obtain an access token, use *token*. * CacheLocation @@ -37,6 +37,12 @@ The following directives are available: Instead of caching access tokens to ~/.cache, cache them to *location*. +* DefaultEvent + *type* + Use + *type* + as the default event type instead of m.text. + The following statements are available: * NoCache @@ -57,4 +63,4 @@ The following statements are available: matrix-send(1) -OpenBSD 7.1 - July 28, 2022 +OpenBSD 7.1 - July 29, 2022 diff --git a/matrix-send b/matrix-send index d758ce2..57b79d5 100755 --- a/matrix-send +++ b/matrix-send @@ -22,14 +22,15 @@ vargrep () { } usage () { - printf "usage: $0 [-c] [-h] [-V] message room\n" + printf "usage: matrix-send [-t type] [-c] [-h] [-V] message room\n" exit 1 } help () { cat < Date: Fri, 29 Jul 2022 08:12:43 +1200 Subject: [PATCH 058/133] Added -t option --- doc/matrix-send.1.md | 26 ++++++++++++++++------- doc/matrix-send.conf.5.md | 12 ++++++++--- matrix-send | 44 +++++++++++++++++++++++++-------------- matrix-send.1 | 24 ++++++++++++++------- matrix-send.conf.5 | 12 ++++++++--- 5 files changed, 82 insertions(+), 36 deletions(-) diff --git a/doc/matrix-send.1.md b/doc/matrix-send.1.md index 090f25a..e91dc7a 100644 --- a/doc/matrix-send.1.md +++ b/doc/matrix-send.1.md @@ -7,6 +7,7 @@ MATRIX-SEND(1) - General Commands Manual # SYNOPSIS **matrix-send** +\[**-t** *type*] \[**-c**] \[**-h**] \[**-v**] @@ -16,23 +17,34 @@ MATRIX-SEND(1) - General Commands Manual **matrix-send** is a script to send a message to a Matrix room. -It works by sending a JSON request to your Matrix server. The message -type will always be m.text, but other options may be considered in the -future. +It works by sending a JSON message to your Matrix server. The default message +type is m.text, but you can specify a custom type with +*-t*. The options are as follows: +**-t** *type* + +> Change the event type to +> *type*. +> Currently supported types are +> *m.text* +> and +> *m.notice*. +> Default is +> *m.text*. + **-c** > Clear cached access tokens. **-h** -> Show a help menu, then exit. +> Show the help menu, then exit. **-V** -> Print version and program information, then exit +> Print version and program information, then exit. To begin, start by making a configuration file. This always has the location of *~/.config/matrix-send.conf*. @@ -85,7 +97,7 @@ This will be something like Type the Room ID as the argument after the message you wish to send. You may have to escape the exclamation mark with a backslash. For example: - matrix-send "Hello world!" zyxwvutsrq:example.org + matrix-send "Hello world!" \!zyxwvutsrq:example.org That should send a message saying *Hello world!* @@ -117,4 +129,4 @@ There are currently no plans to add encryption to matrix-send.conf(5) -OpenBSD 7.1 - July 28, 2022 +OpenBSD 7.1 - July 29, 2022 diff --git a/doc/matrix-send.conf.5.md b/doc/matrix-send.conf.5.md index ba3f333..8762563 100644 --- a/doc/matrix-send.conf.5.md +++ b/doc/matrix-send.conf.5.md @@ -21,7 +21,7 @@ The following directives are available: * Username *username* - Your Matrix username. + The username of your Matrix account. * Password *password* @@ -29,7 +29,7 @@ The following directives are available: * AccessToken *token* - Instead of using a username and password to obtain an access token, just use + Instead of using a username and password to obtain an access token, use *token*. * CacheLocation @@ -37,6 +37,12 @@ The following directives are available: Instead of caching access tokens to ~/.cache, cache them to *location*. +* DefaultEvent + *type* + Use + *type* + as the default event type instead of m.text. + The following statements are available: * NoCache @@ -57,4 +63,4 @@ The following statements are available: matrix-send(1) -OpenBSD 7.1 - July 28, 2022 +OpenBSD 7.1 - July 29, 2022 diff --git a/matrix-send b/matrix-send index d758ce2..57b79d5 100755 --- a/matrix-send +++ b/matrix-send @@ -22,14 +22,15 @@ vargrep () { } usage () { - printf "usage: $0 [-c] [-h] [-V] message room\n" + printf "usage: matrix-send [-t type] [-c] [-h] [-V] message room\n" exit 1 } help () { cat < Date: Thu, 28 Jul 2022 22:17:09 +0200 Subject: [PATCH 059/133] Update 'README.md' --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index efb71a9..1671f84 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # matrix-send + A script to send a message to a Matrix room. +[Read the manual page](https://codeberg.org/jtbx/matrix-send/src/branch/master/doc/matrix-send.1.md) + --- **Syntax:** `matrix-send message room` @@ -11,11 +14,11 @@ A script to send a message to a Matrix room. `matrix-send` is a simple script to send a message to a Matrix room. -It does this by sending a JSON message to your Matrix server. The message type supported is currently only m.text, but other types will be supported. +It does this by sending a JSON message to your Matrix server. The message types that are supported are *m.text*, and *m.notice*. It is mainly designed for automation. I use it on a private Matrix room of mine. -`matrix-send` doesn't have support for end-to-end encryption, and never will. +There aren't any plans for `matrix-send` to support encryption. ## Get started @@ -43,14 +46,16 @@ Password $(gpg -d /path/to/passwd.gpg) /path/to/passwd.gpg is a GPG-encrypted file containing only your password, once decrypted. +For more configuration options, see [matrix-send.conf(5)](https://codeberg.org/jtbx/matrix-send/src/branch/master/doc/matrix-send.conf.5.md). + --- To install matrix-send, run `make install` as root, in the cloned repository's directory. -```shell +``` # make install ``` -In order to send messages, you need your Room ID. Find the room you want to send to, and find its Room ID in the settings or somewhere else. It will likely be under Advanced or something similar. +In order to send messages, you will need your Room ID. Find the room you want to send to, and find its Room ID in the settings or somewhere else. It will likely be under Advanced or something similar. To send a message, type `matrix-send` followed by your message and then your Room ID. You may need to escape the exclamation mark(s). For example: From 2eb5ac04fe75ce043aad15498024ef1f10efb0ee Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 28 Jul 2022 22:17:09 +0200 Subject: [PATCH 060/133] Update 'README.md' --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index efb71a9..1671f84 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # matrix-send + A script to send a message to a Matrix room. +[Read the manual page](https://codeberg.org/jtbx/matrix-send/src/branch/master/doc/matrix-send.1.md) + --- **Syntax:** `matrix-send message room` @@ -11,11 +14,11 @@ A script to send a message to a Matrix room. `matrix-send` is a simple script to send a message to a Matrix room. -It does this by sending a JSON message to your Matrix server. The message type supported is currently only m.text, but other types will be supported. +It does this by sending a JSON message to your Matrix server. The message types that are supported are *m.text*, and *m.notice*. It is mainly designed for automation. I use it on a private Matrix room of mine. -`matrix-send` doesn't have support for end-to-end encryption, and never will. +There aren't any plans for `matrix-send` to support encryption. ## Get started @@ -43,14 +46,16 @@ Password $(gpg -d /path/to/passwd.gpg) /path/to/passwd.gpg is a GPG-encrypted file containing only your password, once decrypted. +For more configuration options, see [matrix-send.conf(5)](https://codeberg.org/jtbx/matrix-send/src/branch/master/doc/matrix-send.conf.5.md). + --- To install matrix-send, run `make install` as root, in the cloned repository's directory. -```shell +``` # make install ``` -In order to send messages, you need your Room ID. Find the room you want to send to, and find its Room ID in the settings or somewhere else. It will likely be under Advanced or something similar. +In order to send messages, you will need your Room ID. Find the room you want to send to, and find its Room ID in the settings or somewhere else. It will likely be under Advanced or something similar. To send a message, type `matrix-send` followed by your message and then your Room ID. You may need to escape the exclamation mark(s). For example: From 0daa8367ecc5994838d6af21c118d9d3fdbd47cc Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 2 Aug 2022 16:26:20 +1200 Subject: [PATCH 061/133] Added EXAMPLES section --- matrix-send.1 | 20 ++++++++++++-------- matrix-send.conf.5 | 11 +++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/matrix-send.1 b/matrix-send.1 index 13eccd0..d1b11d6 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -10,7 +10,7 @@ .Op Fl t Ar type .Op Fl c .Op Fl h -.Op Fl v +.Op Fl V .Ar message room .Ek .Sh DESCRIPTION @@ -69,9 +69,8 @@ At its most basic, matrix-send.conf is a shell script. This means you could replace the .Em Password line with something similar to this -.Bd -literal -offset indent -Password $(gpg -d /path/to/passwd.gpg) -.Ed +.Pp +.Dl Password $(gpg -d /path/to/passwd.gpg) .Pp where .Em /path/to/passwd.gpg @@ -91,11 +90,10 @@ This will be something like Type the Room ID as the argument after the message you wish to send. You may have to escape the exclamation mark with a backslash. For example: -.Bd -literal -offset indent -matrix-send "Hello world!" \\!zyxwvutsrq:example.org -.Ed .Pp -That should send a message saying +.Dl matrix-send "Hello world!" \\!zyxwvutsrq:example.org +.Pp +That would send a message saying .Em Hello world! to the room with the Room ID !zyxwvutsrq:example.org. .Pp @@ -120,5 +118,11 @@ configuration file for access token cache file .El +.Sh EXAMPLES +Send a message saying "How are you?" to the Matrix room !TfbDbeqp:example.org: +.Pp +.Dl matrix-send "How are you?" !TfbDbeqp:example.org +.Pp + .Sh SEE ALSO .Xr matrix-send.conf 5 diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index 1d88483..2a49980 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -60,5 +60,16 @@ configuration file for default access token cache file .El +.Sh EXAMPLES +This configuration would sign into matrix.org under the user +.Em johndoe +using the password +.Em supersecretpassword : +.Bd -literal -offset indent +Server matrix-client.matrix.org +Username johndoe +Password supersecretpassword +.Ed + .Sh SEE ALSO .Xr matrix-send 1 From b486569a72f91bdff351a22b58382576eccab1b0 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 2 Aug 2022 16:26:20 +1200 Subject: [PATCH 062/133] Added EXAMPLES section --- matrix-send.1 | 20 ++++++++++++-------- matrix-send.conf.5 | 11 +++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/matrix-send.1 b/matrix-send.1 index 13eccd0..d1b11d6 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -10,7 +10,7 @@ .Op Fl t Ar type .Op Fl c .Op Fl h -.Op Fl v +.Op Fl V .Ar message room .Ek .Sh DESCRIPTION @@ -69,9 +69,8 @@ At its most basic, matrix-send.conf is a shell script. This means you could replace the .Em Password line with something similar to this -.Bd -literal -offset indent -Password $(gpg -d /path/to/passwd.gpg) -.Ed +.Pp +.Dl Password $(gpg -d /path/to/passwd.gpg) .Pp where .Em /path/to/passwd.gpg @@ -91,11 +90,10 @@ This will be something like Type the Room ID as the argument after the message you wish to send. You may have to escape the exclamation mark with a backslash. For example: -.Bd -literal -offset indent -matrix-send "Hello world!" \\!zyxwvutsrq:example.org -.Ed .Pp -That should send a message saying +.Dl matrix-send "Hello world!" \\!zyxwvutsrq:example.org +.Pp +That would send a message saying .Em Hello world! to the room with the Room ID !zyxwvutsrq:example.org. .Pp @@ -120,5 +118,11 @@ configuration file for access token cache file .El +.Sh EXAMPLES +Send a message saying "How are you?" to the Matrix room !TfbDbeqp:example.org: +.Pp +.Dl matrix-send "How are you?" !TfbDbeqp:example.org +.Pp + .Sh SEE ALSO .Xr matrix-send.conf 5 diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index 1d88483..2a49980 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -60,5 +60,16 @@ configuration file for default access token cache file .El +.Sh EXAMPLES +This configuration would sign into matrix.org under the user +.Em johndoe +using the password +.Em supersecretpassword : +.Bd -literal -offset indent +Server matrix-client.matrix.org +Username johndoe +Password supersecretpassword +.Ed + .Sh SEE ALSO .Xr matrix-send 1 From f7fb6021b701061453aa6e348ff1e45234b33b7d Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 2 Aug 2022 18:23:01 +1200 Subject: [PATCH 063/133] Update manual dates --- matrix-send.1 | 2 +- matrix-send.conf.5 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/matrix-send.1 b/matrix-send.1 index d1b11d6..ae07aff 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: July 29 2022 $ +.Dd $Mdocdate: August 2 2022 $ .Dt MATRIX-SEND 1 .Os .Sh NAME diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index 2a49980..3158da1 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: July 29 2022 $ +.Dd $Mdocdate: August 2 2022 $ .Dt MATRIX-SEND.CONF 5 .Os .Sh NAME From 068626c0e08ef023ebd20c14986b773cc904e262 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 2 Aug 2022 18:23:01 +1200 Subject: [PATCH 064/133] Update manual dates --- matrix-send.1 | 2 +- matrix-send.conf.5 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/matrix-send.1 b/matrix-send.1 index d1b11d6..ae07aff 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: July 29 2022 $ +.Dd $Mdocdate: August 2 2022 $ .Dt MATRIX-SEND 1 .Os .Sh NAME diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index 2a49980..3158da1 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: July 29 2022 $ +.Dd $Mdocdate: August 2 2022 $ .Dt MATRIX-SEND.CONF 5 .Os .Sh NAME From ac0912c53c2743b4716aab8871069b57c14f99d6 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 2 Aug 2022 08:59:21 +0200 Subject: [PATCH 065/133] Change man links --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1671f84..a74178d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A script to send a message to a Matrix room. -[Read the manual page](https://codeberg.org/jtbx/matrix-send/src/branch/master/doc/matrix-send.1.md) +[Read the manual page](https://jtbx.codeberg.page/man/matrix-send.1) --- @@ -46,7 +46,7 @@ Password $(gpg -d /path/to/passwd.gpg) /path/to/passwd.gpg is a GPG-encrypted file containing only your password, once decrypted. -For more configuration options, see [matrix-send.conf(5)](https://codeberg.org/jtbx/matrix-send/src/branch/master/doc/matrix-send.conf.5.md). +For more configuration options, see [matrix-send.conf(5)](https://jtbx.codeberg.page/man/matrix-send.conf.5). --- @@ -63,4 +63,4 @@ To send a message, type `matrix-send` followed by your message and then your Roo That will send the message "Hi!" to the Matrix room !asdfasdfasdfasdf:matrix.org. -For more information, see [matrix-send(1)](https://codeberg.org/jtbx/matrix-send/src/branch/master/doc/matrix-send.1.md). +For more information, see [matrix-send(1)](https://jtbx.codeberg.page/man/matrix-send.1). From a5cc6d776b0851f68df4b6b1873b51fa7d16e06b Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 2 Aug 2022 08:59:21 +0200 Subject: [PATCH 066/133] Change man links --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1671f84..a74178d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A script to send a message to a Matrix room. -[Read the manual page](https://codeberg.org/jtbx/matrix-send/src/branch/master/doc/matrix-send.1.md) +[Read the manual page](https://jtbx.codeberg.page/man/matrix-send.1) --- @@ -46,7 +46,7 @@ Password $(gpg -d /path/to/passwd.gpg) /path/to/passwd.gpg is a GPG-encrypted file containing only your password, once decrypted. -For more configuration options, see [matrix-send.conf(5)](https://codeberg.org/jtbx/matrix-send/src/branch/master/doc/matrix-send.conf.5.md). +For more configuration options, see [matrix-send.conf(5)](https://jtbx.codeberg.page/man/matrix-send.conf.5). --- @@ -63,4 +63,4 @@ To send a message, type `matrix-send` followed by your message and then your Roo That will send the message "Hi!" to the Matrix room !asdfasdfasdfasdf:matrix.org. -For more information, see [matrix-send(1)](https://codeberg.org/jtbx/matrix-send/src/branch/master/doc/matrix-send.1.md). +For more information, see [matrix-send(1)](https://jtbx.codeberg.page/man/matrix-send.1). From 275f2c899bf6962fa164f6ce99c4d0d5cf32bfaa Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 2 Aug 2022 09:03:41 +0200 Subject: [PATCH 067/133] Update 'README.md' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a74178d..ea32f5e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # matrix-send -A script to send a message to a Matrix room. +A script that sends a message to a Matrix room. [Read the manual page](https://jtbx.codeberg.page/man/matrix-send.1) From 63948a443d4ea4a1a6eaa894024872025a6ab775 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 2 Aug 2022 09:03:58 +0200 Subject: [PATCH 068/133] Update 'README.md' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ea32f5e..c0c3a6f 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ A script that sends a message to a Matrix room. --- -`matrix-send` is a simple script to send a message to a Matrix room. +`matrix-send` is a simple script that sends a message to a Matrix room. It does this by sending a JSON message to your Matrix server. The message types that are supported are *m.text*, and *m.notice*. From 7c107a9a93ca36e5c1f5c9ad4f874ce5fcc5031a Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 2 Aug 2022 09:12:10 +0200 Subject: [PATCH 069/133] Fix README.md --- README.md | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index c0c3a6f..3b5d4ec 100644 --- a/README.md +++ b/README.md @@ -8,29 +8,25 @@ A script that sends a message to a Matrix room. **Syntax:** `matrix-send message room` -**For example:** `matrix-send "Hello world\!" \!aBcDeFgHiJkLmNoP:example.org` +**Example:** `matrix-send "Hello world\!" \!aBcDeFgHiJkLmNoP:example.org` --- -`matrix-send` is a simple script that sends a message to a Matrix room. +matrix-send is a simple script that sends a message to a Matrix room. It does this by sending a JSON message to your Matrix server. The message types that are supported are *m.text*, and *m.notice*. It is mainly designed for automation. I use it on a private Matrix room of mine. -There aren't any plans for `matrix-send` to support encryption. +There aren't any plans for matrix-send to support encryption. ## Get started -In order to start using `matrix-send` you need a config file. To copy the configuration to .config, clone this repository and type: - -```shell -$ make config -``` +In order to start using matrix-send, you need a config file. To copy the default configuration to .config, clone this repository and type `make config` as the desired user (not root). Now edit the file ~/.config/matrix-send.conf. You will see three (uncommented) lines. -```shell +``` Server ... Username ... Password ... @@ -38,7 +34,7 @@ Password ... Delete the example values and enter in your credentials. -If you don't want to put your password in plain text, since matrix-send.conf is a shell script, you could do something like this: +If you don't want to put your password in plain text, as matrix-send.conf is a shell script, you could do something like this: ```shell Password $(gpg -d /path/to/passwd.gpg) @@ -51,15 +47,14 @@ For more configuration options, see [matrix-send.conf(5)](https://jtbx.codeberg. --- To install matrix-send, run `make install` as root, in the cloned repository's directory. -``` -# make install -``` -In order to send messages, you will need your Room ID. Find the room you want to send to, and find its Room ID in the settings or somewhere else. It will likely be under Advanced or something similar. +In order to send messages, you will need the Room ID of your choice. Find the room you want to send to, and find its Room ID in the settings or somewhere else. It will likely be under Advanced or something similar. To send a message, type `matrix-send` followed by your message and then your Room ID. You may need to escape the exclamation mark(s). For example: - matrix-send 'Hi!' \!asdfasdfasdfasdf:matrix.org +```shell +matrix-send 'Hi!' \!asdfasdfasdfasdf:matrix.org +``` That will send the message "Hi!" to the Matrix room !asdfasdfasdfasdf:matrix.org. From b156cb024732a71280c28d40e74699b0a2416bee Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 2 Aug 2022 19:01:32 +1200 Subject: [PATCH 070/133] Fix manpages not rendering w/ HTML --- matrix-send.1 | 2 +- matrix-send.conf.5 | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/matrix-send.1 b/matrix-send.1 index ae07aff..b20100e 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -15,7 +15,7 @@ .Ek .Sh DESCRIPTION .Nm -is a script to send a message to a Matrix room. +is a script that sends a message to a Matrix room. It works by sending a JSON message to your Matrix server. The default message type is m.text, but you can specify a custom type with .Em -t . diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index 3158da1..35d12d0 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -19,24 +19,30 @@ The following directives are available: Server .Ar server The Client-Server API URL for your Matrix server. +.Pp .It Username .Ar username The username of your Matrix account. +.Pp .It Password .Ar password The password to your Matrix account. +.Pp .It AccessToken .Ar token Instead of using a username and password to obtain an access token, use +.Pp .Ar token . .It CacheLocation .Ar location Instead of caching access tokens to ~/.cache, cache them to +.Pp .Ar location . +.Pp .It DefaultEvent .Ar type From 9c636a88e354e2a3406d56775aa6d386e88a5a3f Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 2 Aug 2022 19:02:55 +1200 Subject: [PATCH 071/133] Remove doc/ and config.md --- config.md | 24 ------- doc/Makefile | 3 - doc/README.md | 7 -- doc/matrix-send.1.md | 132 -------------------------------------- doc/matrix-send.conf.5.md | 66 ------------------- 5 files changed, 232 deletions(-) delete mode 100644 config.md delete mode 100644 doc/Makefile delete mode 100644 doc/README.md delete mode 100644 doc/matrix-send.1.md delete mode 100644 doc/matrix-send.conf.5.md diff --git a/config.md b/config.md deleted file mode 100644 index 5134237..0000000 --- a/config.md +++ /dev/null @@ -1,24 +0,0 @@ -# Configuration - -This file will list all the possible configuration directives and statements. -Comments can be made in the file with a hashtag (`#`). - ---- - -## Directives - -Options that take an argument. - - * `Server`: The server to log into - * `Username`: The user's name used to log in - * `Password`: The user's password used to log in - * `AccessToken`: A custom access token to use for logging in (overrides username+password) - * `CacheLocation`: A custom location to cache access tokens in. Defaults to $HOME/.cache - -## Statements - -Options that do not take an argument. - - * `NoCache`: Don't cache access tokens - -For more information, take a look at the manual page (`man matrix-send.conf`). diff --git a/doc/Makefile b/doc/Makefile deleted file mode 100644 index 4537bb3..0000000 --- a/doc/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -generate: - man -cT markdown ../matrix-send.1 > matrix-send.1.md - man -cT markdown ../matrix-send.conf.5 > matrix-send.conf.5.md diff --git a/doc/README.md b/doc/README.md deleted file mode 100644 index fc0bd8a..0000000 --- a/doc/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Manual pages - -This directory contains the manual pages for matrix-send. - -They are automatically generated from the man page, so if you already have matrix-send installed you can view these documents offline by typing `man matrix-send`. - -To generate these Markdown documents, enter this directory and type `make generate`. diff --git a/doc/matrix-send.1.md b/doc/matrix-send.1.md deleted file mode 100644 index e91dc7a..0000000 --- a/doc/matrix-send.1.md +++ /dev/null @@ -1,132 +0,0 @@ -MATRIX-SEND(1) - General Commands Manual - -# NAME - -**matrix-send** - send a message to a Matrix room - -# SYNOPSIS - -**matrix-send** -\[**-t** *type*] -\[**-c**] -\[**-h**] -\[**-v**] -*message room* - -# DESCRIPTION - -**matrix-send** -is a script to send a message to a Matrix room. -It works by sending a JSON message to your Matrix server. The default message -type is m.text, but you can specify a custom type with -*-t*. - -The options are as follows: - -**-t** *type* - -> Change the event type to -> *type*. -> Currently supported types are -> *m.text* -> and -> *m.notice*. -> Default is -> *m.text*. - -**-c** - -> Clear cached access tokens. - -**-h** - -> Show the help menu, then exit. - -**-V** - -> Print version and program information, then exit. - -To begin, start by making a configuration file. This always has the location of -*~/.config/matrix-send.conf*. - -At the very least, your configuration file has to contain 3 directives: -*Server*, -*Username*, -and -*Password*. -Let's say your Matrix server is envs.net. Your username is john, and your password -is supersecretpassword. Your configuration could look like this: - - Server matrix.envs.net - Username john - Password supersecretpassword - -In that example, we used matrix.envs.net instead of envs.net. This is because -matrix.envs.net is the address in which the Client-Server API is listening on. -You can find your server's Client-Server API URL in Element by entering in -your server into the Homeserver dialogue in the sign-in screen, then hovering -over it once entered. Your server's Client-Server API URL should appear once -you hover over it. If it doesn't appear, you've already got it. - -You may have noticed that with this configuration, your password -is visible in plain sight. - -At its most basic, matrix-send.conf is a shell script. This means you could -replace the -*Password* -line with something similar to this - - Password $(gpg -d /path/to/passwd.gpg) - -where -*/path/to/passwd.gpg* -is a GPG-encrypted plain text file containing only your password. -This line would mean that you would be asked for the passphrase required to -decrypt your password file before authenticating. This way, your password -is not in plain text. - -More information on configuration options can be found in -matrix-send.conf(5). - -To use -**matrix-send**, -you will need to get the Room ID of the room you'd like to send to. -This will be something like -*!zyxwvutsrq:example.org*. - -Type the Room ID as the argument after the message you wish to send. -You may have to escape the exclamation mark with a backslash. For example: - - matrix-send "Hello world!" \!zyxwvutsrq:example.org - -That should send a message saying -*Hello world!* -to the room with the Room ID !zyxwvutsrq:example.org. - -By default, -**matrix-send** -caches access tokens in -*$HOME/.cache/matrix-send/access-token*. -If you would like to disable caching of access tokens, add NoCache to your -*matrix-send.conf*. - -Encryption is not supported. All messages will be sent unencrypted. -There are currently no plans to add encryption to -**matrix-send**. - -# FILES - -*~/.config/matrix-send.conf* - -> configuration file for -> **matrix-send** - -*~/.cache/matrix-send/access-token* - -> access token cache file - -# SEE ALSO - -matrix-send.conf(5) - -OpenBSD 7.1 - July 29, 2022 diff --git a/doc/matrix-send.conf.5.md b/doc/matrix-send.conf.5.md deleted file mode 100644 index 8762563..0000000 --- a/doc/matrix-send.conf.5.md +++ /dev/null @@ -1,66 +0,0 @@ -MATRIX-SEND.CONF(5) - File Formats Manual - -# NAME - -**matrix-send.conf** - configuration file for matrix-send(1) - -# DESCRIPTION - -matrix-send(1) -sends messages to Matrix rooms. In order to send a message however, it needs -credentials for the account sending the message. These credentials are provided -in the -**matrix-send.conf** -configuration file, as well as other options if you need them. - -The following directives are available: - -* Server - *server* - The Client-Server API URL for your Matrix server. - -* Username - *username* - The username of your Matrix account. - -* Password - *password* - The password to your Matrix account. - -* AccessToken - *token* - Instead of using a username and password to obtain an access token, use - *token*. - -* CacheLocation - *location* - Instead of caching access tokens to ~/.cache, cache them to - *location*. - -* DefaultEvent - *type* - Use - *type* - as the default event type instead of m.text. - -The following statements are available: - -* NoCache - Don't cache access tokens. - -# FILES - -*~/.config/matrix-send.conf* - -> configuration file for -> **matrix-send.conf** - -*~/.cache/matrix-send/access-token* - -> default access token cache file - -# SEE ALSO - -matrix-send(1) - -OpenBSD 7.1 - July 29, 2022 From e0fb4ce7260190324b9db1887440927a6ec984ad Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 2 Aug 2022 09:03:41 +0200 Subject: [PATCH 072/133] Update 'README.md' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a74178d..ea32f5e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # matrix-send -A script to send a message to a Matrix room. +A script that sends a message to a Matrix room. [Read the manual page](https://jtbx.codeberg.page/man/matrix-send.1) From 32d03d211e5e39607917e4a61dada8ddf0725aa3 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 2 Aug 2022 09:03:58 +0200 Subject: [PATCH 073/133] Update 'README.md' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ea32f5e..c0c3a6f 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ A script that sends a message to a Matrix room. --- -`matrix-send` is a simple script to send a message to a Matrix room. +`matrix-send` is a simple script that sends a message to a Matrix room. It does this by sending a JSON message to your Matrix server. The message types that are supported are *m.text*, and *m.notice*. From 18894e767c68d0e2fcf511484125b5d576dc92d0 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 2 Aug 2022 09:12:10 +0200 Subject: [PATCH 074/133] Fix README.md --- README.md | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index c0c3a6f..3b5d4ec 100644 --- a/README.md +++ b/README.md @@ -8,29 +8,25 @@ A script that sends a message to a Matrix room. **Syntax:** `matrix-send message room` -**For example:** `matrix-send "Hello world\!" \!aBcDeFgHiJkLmNoP:example.org` +**Example:** `matrix-send "Hello world\!" \!aBcDeFgHiJkLmNoP:example.org` --- -`matrix-send` is a simple script that sends a message to a Matrix room. +matrix-send is a simple script that sends a message to a Matrix room. It does this by sending a JSON message to your Matrix server. The message types that are supported are *m.text*, and *m.notice*. It is mainly designed for automation. I use it on a private Matrix room of mine. -There aren't any plans for `matrix-send` to support encryption. +There aren't any plans for matrix-send to support encryption. ## Get started -In order to start using `matrix-send` you need a config file. To copy the configuration to .config, clone this repository and type: - -```shell -$ make config -``` +In order to start using matrix-send, you need a config file. To copy the default configuration to .config, clone this repository and type `make config` as the desired user (not root). Now edit the file ~/.config/matrix-send.conf. You will see three (uncommented) lines. -```shell +``` Server ... Username ... Password ... @@ -38,7 +34,7 @@ Password ... Delete the example values and enter in your credentials. -If you don't want to put your password in plain text, since matrix-send.conf is a shell script, you could do something like this: +If you don't want to put your password in plain text, as matrix-send.conf is a shell script, you could do something like this: ```shell Password $(gpg -d /path/to/passwd.gpg) @@ -51,15 +47,14 @@ For more configuration options, see [matrix-send.conf(5)](https://jtbx.codeberg. --- To install matrix-send, run `make install` as root, in the cloned repository's directory. -``` -# make install -``` -In order to send messages, you will need your Room ID. Find the room you want to send to, and find its Room ID in the settings or somewhere else. It will likely be under Advanced or something similar. +In order to send messages, you will need the Room ID of your choice. Find the room you want to send to, and find its Room ID in the settings or somewhere else. It will likely be under Advanced or something similar. To send a message, type `matrix-send` followed by your message and then your Room ID. You may need to escape the exclamation mark(s). For example: - matrix-send 'Hi!' \!asdfasdfasdfasdf:matrix.org +```shell +matrix-send 'Hi!' \!asdfasdfasdfasdf:matrix.org +``` That will send the message "Hi!" to the Matrix room !asdfasdfasdfasdf:matrix.org. From 5d72d40f9a43e5e70494c87efac4d4860a92a4ee Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 2 Aug 2022 19:01:32 +1200 Subject: [PATCH 075/133] Fix manpages not rendering w/ HTML --- matrix-send.1 | 2 +- matrix-send.conf.5 | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/matrix-send.1 b/matrix-send.1 index ae07aff..b20100e 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -15,7 +15,7 @@ .Ek .Sh DESCRIPTION .Nm -is a script to send a message to a Matrix room. +is a script that sends a message to a Matrix room. It works by sending a JSON message to your Matrix server. The default message type is m.text, but you can specify a custom type with .Em -t . diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index 3158da1..35d12d0 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -19,24 +19,30 @@ The following directives are available: Server .Ar server The Client-Server API URL for your Matrix server. +.Pp .It Username .Ar username The username of your Matrix account. +.Pp .It Password .Ar password The password to your Matrix account. +.Pp .It AccessToken .Ar token Instead of using a username and password to obtain an access token, use +.Pp .Ar token . .It CacheLocation .Ar location Instead of caching access tokens to ~/.cache, cache them to +.Pp .Ar location . +.Pp .It DefaultEvent .Ar type From c4e397f77ae2681d225ed4bcb0236f544185a2b6 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 2 Aug 2022 19:02:55 +1200 Subject: [PATCH 076/133] Remove doc/ and config.md --- config.md | 24 ------- doc/Makefile | 3 - doc/README.md | 7 -- doc/matrix-send.1.md | 132 -------------------------------------- doc/matrix-send.conf.5.md | 66 ------------------- 5 files changed, 232 deletions(-) delete mode 100644 config.md delete mode 100644 doc/Makefile delete mode 100644 doc/README.md delete mode 100644 doc/matrix-send.1.md delete mode 100644 doc/matrix-send.conf.5.md diff --git a/config.md b/config.md deleted file mode 100644 index 5134237..0000000 --- a/config.md +++ /dev/null @@ -1,24 +0,0 @@ -# Configuration - -This file will list all the possible configuration directives and statements. -Comments can be made in the file with a hashtag (`#`). - ---- - -## Directives - -Options that take an argument. - - * `Server`: The server to log into - * `Username`: The user's name used to log in - * `Password`: The user's password used to log in - * `AccessToken`: A custom access token to use for logging in (overrides username+password) - * `CacheLocation`: A custom location to cache access tokens in. Defaults to $HOME/.cache - -## Statements - -Options that do not take an argument. - - * `NoCache`: Don't cache access tokens - -For more information, take a look at the manual page (`man matrix-send.conf`). diff --git a/doc/Makefile b/doc/Makefile deleted file mode 100644 index 4537bb3..0000000 --- a/doc/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -generate: - man -cT markdown ../matrix-send.1 > matrix-send.1.md - man -cT markdown ../matrix-send.conf.5 > matrix-send.conf.5.md diff --git a/doc/README.md b/doc/README.md deleted file mode 100644 index fc0bd8a..0000000 --- a/doc/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Manual pages - -This directory contains the manual pages for matrix-send. - -They are automatically generated from the man page, so if you already have matrix-send installed you can view these documents offline by typing `man matrix-send`. - -To generate these Markdown documents, enter this directory and type `make generate`. diff --git a/doc/matrix-send.1.md b/doc/matrix-send.1.md deleted file mode 100644 index e91dc7a..0000000 --- a/doc/matrix-send.1.md +++ /dev/null @@ -1,132 +0,0 @@ -MATRIX-SEND(1) - General Commands Manual - -# NAME - -**matrix-send** - send a message to a Matrix room - -# SYNOPSIS - -**matrix-send** -\[**-t** *type*] -\[**-c**] -\[**-h**] -\[**-v**] -*message room* - -# DESCRIPTION - -**matrix-send** -is a script to send a message to a Matrix room. -It works by sending a JSON message to your Matrix server. The default message -type is m.text, but you can specify a custom type with -*-t*. - -The options are as follows: - -**-t** *type* - -> Change the event type to -> *type*. -> Currently supported types are -> *m.text* -> and -> *m.notice*. -> Default is -> *m.text*. - -**-c** - -> Clear cached access tokens. - -**-h** - -> Show the help menu, then exit. - -**-V** - -> Print version and program information, then exit. - -To begin, start by making a configuration file. This always has the location of -*~/.config/matrix-send.conf*. - -At the very least, your configuration file has to contain 3 directives: -*Server*, -*Username*, -and -*Password*. -Let's say your Matrix server is envs.net. Your username is john, and your password -is supersecretpassword. Your configuration could look like this: - - Server matrix.envs.net - Username john - Password supersecretpassword - -In that example, we used matrix.envs.net instead of envs.net. This is because -matrix.envs.net is the address in which the Client-Server API is listening on. -You can find your server's Client-Server API URL in Element by entering in -your server into the Homeserver dialogue in the sign-in screen, then hovering -over it once entered. Your server's Client-Server API URL should appear once -you hover over it. If it doesn't appear, you've already got it. - -You may have noticed that with this configuration, your password -is visible in plain sight. - -At its most basic, matrix-send.conf is a shell script. This means you could -replace the -*Password* -line with something similar to this - - Password $(gpg -d /path/to/passwd.gpg) - -where -*/path/to/passwd.gpg* -is a GPG-encrypted plain text file containing only your password. -This line would mean that you would be asked for the passphrase required to -decrypt your password file before authenticating. This way, your password -is not in plain text. - -More information on configuration options can be found in -matrix-send.conf(5). - -To use -**matrix-send**, -you will need to get the Room ID of the room you'd like to send to. -This will be something like -*!zyxwvutsrq:example.org*. - -Type the Room ID as the argument after the message you wish to send. -You may have to escape the exclamation mark with a backslash. For example: - - matrix-send "Hello world!" \!zyxwvutsrq:example.org - -That should send a message saying -*Hello world!* -to the room with the Room ID !zyxwvutsrq:example.org. - -By default, -**matrix-send** -caches access tokens in -*$HOME/.cache/matrix-send/access-token*. -If you would like to disable caching of access tokens, add NoCache to your -*matrix-send.conf*. - -Encryption is not supported. All messages will be sent unencrypted. -There are currently no plans to add encryption to -**matrix-send**. - -# FILES - -*~/.config/matrix-send.conf* - -> configuration file for -> **matrix-send** - -*~/.cache/matrix-send/access-token* - -> access token cache file - -# SEE ALSO - -matrix-send.conf(5) - -OpenBSD 7.1 - July 29, 2022 diff --git a/doc/matrix-send.conf.5.md b/doc/matrix-send.conf.5.md deleted file mode 100644 index 8762563..0000000 --- a/doc/matrix-send.conf.5.md +++ /dev/null @@ -1,66 +0,0 @@ -MATRIX-SEND.CONF(5) - File Formats Manual - -# NAME - -**matrix-send.conf** - configuration file for matrix-send(1) - -# DESCRIPTION - -matrix-send(1) -sends messages to Matrix rooms. In order to send a message however, it needs -credentials for the account sending the message. These credentials are provided -in the -**matrix-send.conf** -configuration file, as well as other options if you need them. - -The following directives are available: - -* Server - *server* - The Client-Server API URL for your Matrix server. - -* Username - *username* - The username of your Matrix account. - -* Password - *password* - The password to your Matrix account. - -* AccessToken - *token* - Instead of using a username and password to obtain an access token, use - *token*. - -* CacheLocation - *location* - Instead of caching access tokens to ~/.cache, cache them to - *location*. - -* DefaultEvent - *type* - Use - *type* - as the default event type instead of m.text. - -The following statements are available: - -* NoCache - Don't cache access tokens. - -# FILES - -*~/.config/matrix-send.conf* - -> configuration file for -> **matrix-send.conf** - -*~/.cache/matrix-send/access-token* - -> default access token cache file - -# SEE ALSO - -matrix-send(1) - -OpenBSD 7.1 - July 29, 2022 From e4d1d2cb20bad427c586a8c2df4bf702ca9d775b Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 3 Aug 2022 11:19:55 +1200 Subject: [PATCH 077/133] Re-design matrix-send.conf man page --- matrix-send.conf.5 | 83 +++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 56 deletions(-) diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index 35d12d0..9424c3c 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -1,11 +1,11 @@ -.Dd $Mdocdate: August 2 2022 $ +.Dd $Mdocdate: August 3 2022 $ .Dt MATRIX-SEND.CONF 5 .Os .Sh NAME .Nm matrix-send.conf -.Nd configuration file for matrix-send(1) +.Nd configuration file for +.Xr matrix-send 1 .Sh DESCRIPTION -.Pp .Xr matrix-send 1 sends messages to Matrix rooms. In order to send a message however, it needs credentials for the account sending the message. These credentials are provided @@ -13,69 +13,40 @@ in the .Nm configuration file, as well as other options if you need them. .Pp -The following directives are available: -.Bl -bullet -.It -Server -.Ar server - The Client-Server API URL for your Matrix server. -.Pp -.It -Username -.Ar username - The username of your Matrix account. -.Pp -.It -Password -.Ar password - The password to your Matrix account. -.Pp -.It -AccessToken -.Ar token - Instead of using a username and password to obtain an access token, use -.Pp -.Ar token . -.It -CacheLocation -.Ar location - Instead of caching access tokens to ~/.cache, cache them to -.Pp +The following configuration options are available: +.Bl -tag -width 11n +.Bl -tag -width keepenv +.It Ic Server Ar server +The Client-Server API address of the Matrix server being used. +.It Ic Username Ar username +The username of the account being used. +.It Ic Password Ar password +The password for the account being used. +.It Ic CacheLocation Ar location +Modify the cache location from the default (~/.cache) to .Ar location . -.Pp -.It -DefaultEvent -.Ar type -Use -.Ar type -as the default event type instead of m.text. -.El -.Pp -The following statements are available: -.Bl -bullet -.It -NoCache - Don't cache access tokens. +.It Ic DefaultEvent Ar type +Modify the default event type from the default (m.text) to +.Ar type . +Supported types are m.text, and m.notice. .El .Sh FILES -.Bl -tag -width ~/.config/matrix-send.conf +.Bl -tag -width ~/.config/matrix-send.conf -compact .It Pa ~/.config/matrix-send.conf -configuration file for -.Nm -.It Pa ~/.cache/matrix-send/access-token -default access token cache file +.Xr matrix-send 1 +configuration file. +.It Pa ~/.cache +Default cache location. .El - .Sh EXAMPLES -This configuration would sign into matrix.org under the user -.Em johndoe -using the password -.Em supersecretpassword : +The following example logs into the user johndoe of the server with the +Client-Server API address of matrix-client.matrix.org with the password +supersecretpassword, and sets the default event type to m.notice. .Bd -literal -offset indent Server matrix-client.matrix.org Username johndoe Password supersecretpassword +DefaultEvent m.notice .Ed - .Sh SEE ALSO .Xr matrix-send 1 From 4b1ab4b3746bb666cf3b46d014b8bf0bab043492 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 3 Aug 2022 11:19:55 +1200 Subject: [PATCH 078/133] Re-design matrix-send.conf man page --- matrix-send.conf.5 | 83 +++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 56 deletions(-) diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index 35d12d0..9424c3c 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -1,11 +1,11 @@ -.Dd $Mdocdate: August 2 2022 $ +.Dd $Mdocdate: August 3 2022 $ .Dt MATRIX-SEND.CONF 5 .Os .Sh NAME .Nm matrix-send.conf -.Nd configuration file for matrix-send(1) +.Nd configuration file for +.Xr matrix-send 1 .Sh DESCRIPTION -.Pp .Xr matrix-send 1 sends messages to Matrix rooms. In order to send a message however, it needs credentials for the account sending the message. These credentials are provided @@ -13,69 +13,40 @@ in the .Nm configuration file, as well as other options if you need them. .Pp -The following directives are available: -.Bl -bullet -.It -Server -.Ar server - The Client-Server API URL for your Matrix server. -.Pp -.It -Username -.Ar username - The username of your Matrix account. -.Pp -.It -Password -.Ar password - The password to your Matrix account. -.Pp -.It -AccessToken -.Ar token - Instead of using a username and password to obtain an access token, use -.Pp -.Ar token . -.It -CacheLocation -.Ar location - Instead of caching access tokens to ~/.cache, cache them to -.Pp +The following configuration options are available: +.Bl -tag -width 11n +.Bl -tag -width keepenv +.It Ic Server Ar server +The Client-Server API address of the Matrix server being used. +.It Ic Username Ar username +The username of the account being used. +.It Ic Password Ar password +The password for the account being used. +.It Ic CacheLocation Ar location +Modify the cache location from the default (~/.cache) to .Ar location . -.Pp -.It -DefaultEvent -.Ar type -Use -.Ar type -as the default event type instead of m.text. -.El -.Pp -The following statements are available: -.Bl -bullet -.It -NoCache - Don't cache access tokens. +.It Ic DefaultEvent Ar type +Modify the default event type from the default (m.text) to +.Ar type . +Supported types are m.text, and m.notice. .El .Sh FILES -.Bl -tag -width ~/.config/matrix-send.conf +.Bl -tag -width ~/.config/matrix-send.conf -compact .It Pa ~/.config/matrix-send.conf -configuration file for -.Nm -.It Pa ~/.cache/matrix-send/access-token -default access token cache file +.Xr matrix-send 1 +configuration file. +.It Pa ~/.cache +Default cache location. .El - .Sh EXAMPLES -This configuration would sign into matrix.org under the user -.Em johndoe -using the password -.Em supersecretpassword : +The following example logs into the user johndoe of the server with the +Client-Server API address of matrix-client.matrix.org with the password +supersecretpassword, and sets the default event type to m.notice. .Bd -literal -offset indent Server matrix-client.matrix.org Username johndoe Password supersecretpassword +DefaultEvent m.notice .Ed - .Sh SEE ALSO .Xr matrix-send 1 From 78169ce8882bc4ed1ec642f681e152be74a12a83 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 3 Aug 2022 01:22:06 +0200 Subject: [PATCH 079/133] Add NoCache to config manpage --- matrix-send.conf.5 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index 9424c3c..b99523c 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -25,6 +25,8 @@ The password for the account being used. .It Ic CacheLocation Ar location Modify the cache location from the default (~/.cache) to .Ar location . +.It Ic NoCache +Don't cache access tokens. .It Ic DefaultEvent Ar type Modify the default event type from the default (m.text) to .Ar type . From cd686dd4e3fe61be8334728bb2f7afab00b883b1 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 3 Aug 2022 01:22:06 +0200 Subject: [PATCH 080/133] Add NoCache to config manpage --- matrix-send.conf.5 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index 9424c3c..b99523c 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -25,6 +25,8 @@ The password for the account being used. .It Ic CacheLocation Ar location Modify the cache location from the default (~/.cache) to .Ar location . +.It Ic NoCache +Don't cache access tokens. .It Ic DefaultEvent Ar type Modify the default event type from the default (m.text) to .Ar type . From a16db17ddf8b8a400a9251dd1aea8168a4985ebe Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 3 Aug 2022 11:24:54 +1200 Subject: [PATCH 081/133] Fixed manpage rendering issue --- matrix-send.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix-send.1 b/matrix-send.1 index b20100e..2bf0b80 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -121,7 +121,7 @@ access token cache file .Sh EXAMPLES Send a message saying "How are you?" to the Matrix room !TfbDbeqp:example.org: .Pp -.Dl matrix-send "How are you?" !TfbDbeqp:example.org +.Dl matrix-send 'How are you?' !TfbDbeqp:example.org .Pp .Sh SEE ALSO From 8e9d67c9143d9a2d700cfa1b15eee7a420e3235b Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 3 Aug 2022 11:24:54 +1200 Subject: [PATCH 082/133] Fixed manpage rendering issue --- matrix-send.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix-send.1 b/matrix-send.1 index b20100e..2bf0b80 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -121,7 +121,7 @@ access token cache file .Sh EXAMPLES Send a message saying "How are you?" to the Matrix room !TfbDbeqp:example.org: .Pp -.Dl matrix-send "How are you?" !TfbDbeqp:example.org +.Dl matrix-send 'How are you?' !TfbDbeqp:example.org .Pp .Sh SEE ALSO From 302bb7f631e267759ada014d647177e3d92eab49 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 3 Aug 2022 11:33:42 +1200 Subject: [PATCH 083/133] Update manpage mdocdate --- matrix-send.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix-send.1 b/matrix-send.1 index 2bf0b80..7067659 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: August 2 2022 $ +.Dd $Mdocdate: August 3 2022 $ .Dt MATRIX-SEND 1 .Os .Sh NAME From f61b8ce0b50df9877531c59da4087cedff10ccef Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 3 Aug 2022 11:33:42 +1200 Subject: [PATCH 084/133] Update manpage mdocdate --- matrix-send.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix-send.1 b/matrix-send.1 index 2bf0b80..7067659 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: August 2 2022 $ +.Dd $Mdocdate: August 3 2022 $ .Dt MATRIX-SEND 1 .Os .Sh NAME From 4be51f12e22357ae16121c62798fb3979d81dfe7 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 3 Aug 2022 16:25:38 +1200 Subject: [PATCH 085/133] Fix breaking login issue --- matrix-send | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/matrix-send b/matrix-send index 57b79d5..0c15e98 100755 --- a/matrix-send +++ b/matrix-send @@ -68,7 +68,7 @@ Username () { } Password () { - [ -z $1 ] && conf_error "No argument for directive Password" + [ -z $1 ] && conf_error "No argument(s) for directive Password" password="$@" } @@ -88,7 +88,7 @@ CacheLocation () { DefaultEvent () { [ -z $1 ] && conf_error "No argument for directive DefaultEvent" - if vargrep "m\.(text|notice)" "$1" -Eo + if vargrep "m\.(text|notice)" "$1" -Eq then defaultevent="$1" else conf_error "Invalid default event type"; fi } @@ -130,6 +130,9 @@ ClearCache () { Send () { curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" + #cat < Date: Wed, 3 Aug 2022 16:25:38 +1200 Subject: [PATCH 086/133] Fix breaking login issue --- matrix-send | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/matrix-send b/matrix-send index 57b79d5..0c15e98 100755 --- a/matrix-send +++ b/matrix-send @@ -68,7 +68,7 @@ Username () { } Password () { - [ -z $1 ] && conf_error "No argument for directive Password" + [ -z $1 ] && conf_error "No argument(s) for directive Password" password="$@" } @@ -88,7 +88,7 @@ CacheLocation () { DefaultEvent () { [ -z $1 ] && conf_error "No argument for directive DefaultEvent" - if vargrep "m\.(text|notice)" "$1" -Eo + if vargrep "m\.(text|notice)" "$1" -Eq then defaultevent="$1" else conf_error "Invalid default event type"; fi } @@ -130,6 +130,9 @@ ClearCache () { Send () { curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" + #cat < Date: Thu, 4 Aug 2022 16:39:27 +1200 Subject: [PATCH 087/133] Shorten synopsis in manpage --- matrix-send.1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/matrix-send.1 b/matrix-send.1 index 7067659..1417214 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -8,9 +8,7 @@ .Nm matrix-send .Bk -words .Op Fl t Ar type -.Op Fl c -.Op Fl h -.Op Fl V +.Op Fl chV .Ar message room .Ek .Sh DESCRIPTION From 1d32782593e835188037503aa88536f8013c2c87 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 4 Aug 2022 16:39:27 +1200 Subject: [PATCH 088/133] Shorten synopsis in manpage --- matrix-send.1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/matrix-send.1 b/matrix-send.1 index 7067659..1417214 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -8,9 +8,7 @@ .Nm matrix-send .Bk -words .Op Fl t Ar type -.Op Fl c -.Op Fl h -.Op Fl V +.Op Fl chV .Ar message room .Ek .Sh DESCRIPTION From 6f021541d2f6b8edf982116fcc48828ba1006808 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 4 Aug 2022 17:16:24 +1200 Subject: [PATCH 089/133] Added -C option + added warning function and more --- matrix-send | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/matrix-send b/matrix-send index 0c15e98..de36628 100755 --- a/matrix-send +++ b/matrix-send @@ -17,12 +17,16 @@ conf_error () { exit 2 } +warning () { + printf "\033[93;1mwarning:\033[0m $1\n" +} + vargrep () { printf "$2\n" | grep "$1" $3 } usage () { - printf "usage: matrix-send [-t type] [-c] [-h] [-V] message room\n" + printf "usage: matrix-send [-t type] [-C config] [-chV] message room\n" exit 1 } @@ -31,6 +35,7 @@ help () { matrix-send: send a message to a Matrix room Options: -t type: change default event type + -C config: use a custom configuration file -c: clear cached access tokens -h: show this help menu -V: show version and program information @@ -130,9 +135,6 @@ ClearCache () { Send () { curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" - #cat < Date: Thu, 4 Aug 2022 17:16:24 +1200 Subject: [PATCH 090/133] Added -C option + added warning function and more --- matrix-send | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/matrix-send b/matrix-send index 0c15e98..de36628 100755 --- a/matrix-send +++ b/matrix-send @@ -17,12 +17,16 @@ conf_error () { exit 2 } +warning () { + printf "\033[93;1mwarning:\033[0m $1\n" +} + vargrep () { printf "$2\n" | grep "$1" $3 } usage () { - printf "usage: matrix-send [-t type] [-c] [-h] [-V] message room\n" + printf "usage: matrix-send [-t type] [-C config] [-chV] message room\n" exit 1 } @@ -31,6 +35,7 @@ help () { matrix-send: send a message to a Matrix room Options: -t type: change default event type + -C config: use a custom configuration file -c: clear cached access tokens -h: show this help menu -V: show version and program information @@ -130,9 +135,6 @@ ClearCache () { Send () { curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" - #cat < Date: Thu, 4 Aug 2022 17:19:12 +1200 Subject: [PATCH 091/133] Added PrettyPrint config option --- matrix-send | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/matrix-send b/matrix-send index de36628..23a0ed2 100755 --- a/matrix-send +++ b/matrix-send @@ -1,7 +1,7 @@ #!/usr/bin/env sh # matrix-send: send a message to a Matrix room -version="1.0" +version="1.0.1" ########################### #### Generic Functions #### @@ -106,6 +106,10 @@ NoCache () { nocache="true" } +PrettyPrint () { + prettyprint="true" +} + ############################ #### Specific Functions #### ############################ @@ -134,7 +138,10 @@ ClearCache () { } Send () { - curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" + if [ -z "$prettyprint" ] + then curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" + else curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" | jq + fi } ######################## From 1fb436c53b811d07a0b50c1a7dcc8f5c17cd0c85 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 4 Aug 2022 17:19:12 +1200 Subject: [PATCH 092/133] Added PrettyPrint config option --- matrix-send | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/matrix-send b/matrix-send index de36628..23a0ed2 100755 --- a/matrix-send +++ b/matrix-send @@ -1,7 +1,7 @@ #!/usr/bin/env sh # matrix-send: send a message to a Matrix room -version="1.0" +version="1.0.1" ########################### #### Generic Functions #### @@ -106,6 +106,10 @@ NoCache () { nocache="true" } +PrettyPrint () { + prettyprint="true" +} + ############################ #### Specific Functions #### ############################ @@ -134,7 +138,10 @@ ClearCache () { } Send () { - curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" + if [ -z "$prettyprint" ] + then curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" + else curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" | jq + fi } ######################## From fe4c1dad5581feaf44b38c65ead9a4711c17f622 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 4 Aug 2022 17:24:45 +1200 Subject: [PATCH 093/133] Added -C option to manpage --- matrix-send.1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/matrix-send.1 b/matrix-send.1 index 1417214..bd4bc75 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: August 3 2022 $ +.Dd $Mdocdate: August 4 2022 $ .Dt MATRIX-SEND 1 .Os .Sh NAME @@ -8,6 +8,7 @@ .Nm matrix-send .Bk -words .Op Fl t Ar type +.Op Fl C Ar config .Op Fl chV .Ar message room .Ek @@ -29,6 +30,9 @@ and .Em m.notice . Default is .Em m.text . +.It Fl C Ar config +Instead of reading the default configuration file (~/.config/matrix-send.conf), read +.Ar config . .It Fl c Clear cached access tokens. .It Fl h From 017cea52f43c6de45d906da71a39b0653e74c38e Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 4 Aug 2022 17:24:45 +1200 Subject: [PATCH 094/133] Added -C option to manpage --- matrix-send.1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/matrix-send.1 b/matrix-send.1 index 1417214..bd4bc75 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: August 3 2022 $ +.Dd $Mdocdate: August 4 2022 $ .Dt MATRIX-SEND 1 .Os .Sh NAME @@ -8,6 +8,7 @@ .Nm matrix-send .Bk -words .Op Fl t Ar type +.Op Fl C Ar config .Op Fl chV .Ar message room .Ek @@ -29,6 +30,9 @@ and .Em m.notice . Default is .Em m.text . +.It Fl C Ar config +Instead of reading the default configuration file (~/.config/matrix-send.conf), read +.Ar config . .It Fl c Clear cached access tokens. .It Fl h From 407f3cdf9a4a07c7c7a0ddc0cf93062504c13dc7 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 4 Aug 2022 17:25:00 +1200 Subject: [PATCH 095/133] Added AccessToken config option to manpage --- matrix-send.conf.5 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index b99523c..9c3a025 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: August 3 2022 $ +.Dd $Mdocdate: August 4 2022 $ .Dt MATRIX-SEND.CONF 5 .Os .Sh NAME @@ -22,6 +22,9 @@ The Client-Server API address of the Matrix server being used. The username of the account being used. .It Ic Password Ar password The password for the account being used. +.It Ic AccessToken Ar token +Instead of authenticating via username and password to obtain an access token, use +.Ar token . .It Ic CacheLocation Ar location Modify the cache location from the default (~/.cache) to .Ar location . From fcf5e4b51026c59568acf6cc3d38e638be402688 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 4 Aug 2022 17:25:00 +1200 Subject: [PATCH 096/133] Added AccessToken config option to manpage --- matrix-send.conf.5 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index b99523c..9c3a025 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: August 3 2022 $ +.Dd $Mdocdate: August 4 2022 $ .Dt MATRIX-SEND.CONF 5 .Os .Sh NAME @@ -22,6 +22,9 @@ The Client-Server API address of the Matrix server being used. The username of the account being used. .It Ic Password Ar password The password for the account being used. +.It Ic AccessToken Ar token +Instead of authenticating via username and password to obtain an access token, use +.Ar token . .It Ic CacheLocation Ar location Modify the cache location from the default (~/.cache) to .Ar location . From e4fe071f6a79ca878f3b2fb60e53a7df5125235c Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 4 Aug 2022 17:38:30 +1200 Subject: [PATCH 097/133] Improve config manpage wording --- LICENCE | 339 +++++++++++++++++++++++++++++++++++++++++++++ matrix-send.conf.5 | 5 +- 2 files changed, 343 insertions(+), 1 deletion(-) create mode 100644 LICENCE diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENCE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index 9c3a025..55a1c50 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -24,7 +24,8 @@ The username of the account being used. The password for the account being used. .It Ic AccessToken Ar token Instead of authenticating via username and password to obtain an access token, use -.Ar token . +.Ar token +as the access token. .It Ic CacheLocation Ar location Modify the cache location from the default (~/.cache) to .Ar location . @@ -34,6 +35,8 @@ Don't cache access tokens. Modify the default event type from the default (m.text) to .Ar type . Supported types are m.text, and m.notice. +.It Ic PrettyPrint +Pretty-print the JSON server messages. .El .Sh FILES .Bl -tag -width ~/.config/matrix-send.conf -compact From 6f090d7ac011fdedf6f876899ddf213ea497910e Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 4 Aug 2022 17:38:30 +1200 Subject: [PATCH 098/133] Improve config manpage wording --- LICENCE | 339 +++++++++++++++++++++++++++++++++++++++++++++ matrix-send.conf.5 | 5 +- 2 files changed, 343 insertions(+), 1 deletion(-) create mode 100644 LICENCE diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENCE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 index 9c3a025..55a1c50 100644 --- a/matrix-send.conf.5 +++ b/matrix-send.conf.5 @@ -24,7 +24,8 @@ The username of the account being used. The password for the account being used. .It Ic AccessToken Ar token Instead of authenticating via username and password to obtain an access token, use -.Ar token . +.Ar token +as the access token. .It Ic CacheLocation Ar location Modify the cache location from the default (~/.cache) to .Ar location . @@ -34,6 +35,8 @@ Don't cache access tokens. Modify the default event type from the default (m.text) to .Ar type . Supported types are m.text, and m.notice. +.It Ic PrettyPrint +Pretty-print the JSON server messages. .El .Sh FILES .Bl -tag -width ~/.config/matrix-send.conf -compact From 80a1b7a1f8e1f8fc505358829f596f960e3124bd Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 4 Aug 2022 17:43:57 +1200 Subject: [PATCH 099/133] temporarily remove LICENSE --- LICENSE | 339 -------------------------------------------------------- 1 file changed, 339 deletions(-) delete mode 100644 LICENSE diff --git a/LICENSE b/LICENSE deleted file mode 100644 index d159169..0000000 --- a/LICENSE +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. From 050284e13dbba4e6896f61fc4cd326c7d7ee47b3 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 4 Aug 2022 17:43:57 +1200 Subject: [PATCH 100/133] temporarily remove LICENSE --- LICENSE | 339 -------------------------------------------------------- 1 file changed, 339 deletions(-) delete mode 100644 LICENSE diff --git a/LICENSE b/LICENSE deleted file mode 100644 index d159169..0000000 --- a/LICENSE +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. From d0807670ba787c2be15e2a49af2592a82f4bc2bb Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 4 Aug 2022 17:47:59 +1200 Subject: [PATCH 101/133] Update version numbers --- Makefile | 2 +- README.md | 2 ++ matrix-send | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index db545b9..cf63374 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 1.0 +VERSION = 1.1 PREFIX = /usr/local MANPREFIX = ${PREFIX}/man diff --git a/README.md b/README.md index 3b5d4ec..90710a4 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ A script that sends a message to a Matrix room. +*Version 1.1* + [Read the manual page](https://jtbx.codeberg.page/man/matrix-send.1) --- diff --git a/matrix-send b/matrix-send index 23a0ed2..3d5f606 100755 --- a/matrix-send +++ b/matrix-send @@ -1,7 +1,7 @@ #!/usr/bin/env sh # matrix-send: send a message to a Matrix room -version="1.0.1" +version="1.1" ########################### #### Generic Functions #### From eee2a75739db8a116a3435531a3248a00383de14 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 4 Aug 2022 17:47:59 +1200 Subject: [PATCH 102/133] Update version numbers --- Makefile | 2 +- README.md | 2 ++ matrix-send | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index db545b9..cf63374 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 1.0 +VERSION = 1.1 PREFIX = /usr/local MANPREFIX = ${PREFIX}/man diff --git a/README.md b/README.md index 3b5d4ec..90710a4 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ A script that sends a message to a Matrix room. +*Version 1.1* + [Read the manual page](https://jtbx.codeberg.page/man/matrix-send.1) --- diff --git a/matrix-send b/matrix-send index 23a0ed2..3d5f606 100755 --- a/matrix-send +++ b/matrix-send @@ -1,7 +1,7 @@ #!/usr/bin/env sh # matrix-send: send a message to a Matrix room -version="1.0.1" +version="1.1" ########################### #### Generic Functions #### From 9218843baab94f15a0189db5582caf97ebafa7a8 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 4 Aug 2022 07:49:58 +0200 Subject: [PATCH 103/133] Removed version line in README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 90710a4..3b5d4ec 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ A script that sends a message to a Matrix room. -*Version 1.1* - [Read the manual page](https://jtbx.codeberg.page/man/matrix-send.1) --- From aaf2350de3803c764b5fbd3280f33ee9cd5a6eea Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 4 Aug 2022 07:49:58 +0200 Subject: [PATCH 104/133] Removed version line in README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 90710a4..3b5d4ec 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ A script that sends a message to a Matrix room. -*Version 1.1* - [Read the manual page](https://jtbx.codeberg.page/man/matrix-send.1) --- From 13fcde93399e105608b736a6dbf7c3417e744db5 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sun, 1 Jan 2023 09:53:10 +1300 Subject: [PATCH 105/133] Rewrote the whole entire thing in Lua Shortened list of changes: - Added room aliases - Switched the -C and -c flags - Added the MATRIXSEND_CONFIG environment variable - Changed config format to Lua over custom /bin/sh - Upgraded to Matrix spec 1.5 over whatever version it was previously using - Removed JSON printing (and in turn, pretty printing) - Added actual Matrix error reporting rather than just feeding the JSON to the user - Switched to luaposix getopt() over /bin/sh getopts - Some more changes... --- matrix-send | 551 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 347 insertions(+), 204 deletions(-) diff --git a/matrix-send b/matrix-send index 3d5f606..4d6e5f6 100755 --- a/matrix-send +++ b/matrix-send @@ -1,220 +1,363 @@ -#!/usr/bin/env sh -# matrix-send: send a message to a Matrix room +#!/usr/bin/env lua +--[[ + The GPLv2 License (GPLv2) + Copyright (c) 2022 Jeremy Baxter + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +]]-- -version="1.1" +require "luarocks.loader" +getopt = require "posix.unistd".getopt +mkdir = require "posix.sys.stat".mkdir +bname = require "posix.libgen".basename +http = require "socket.http" +cjson = require "cjson" +ltn12 = require "ltn12" -########################### -#### Generic Functions #### -########################### + version = "2.0" + confdir = string.gsub("~/.config/matrix-send", '~', os.getenv("HOME"), 1) +confpath = confdir .. "/config.lua" +confvarv = os.getenv("MATRIXSEND_CONFIG") +hostname = io.input("/etc/hostname"):read("l") -error () { - printf "\033[31;1merror:\033[0m $1\n" - exit 1 -} +json = {} + uri = {} + sh = os.execute -conf_error () { - printf "\033[31;1mconfiguration error:\033[0m $1\n" - exit 2 -} +----------------- +--- Functions --- +----------------- -warning () { - printf "\033[93;1mwarning:\033[0m $1\n" -} - -vargrep () { - printf "$2\n" | grep "$1" $3 -} - -usage () { - printf "usage: matrix-send [-t type] [-C config] [-chV] message room\n" - exit 1 -} - -help () { - cat < "$cacheloc/matrix-send/access-token"; - fi -} + return false, err + end +end -ClearCache () { - [ -e "$cacheloc/matrix-send/access-token" ] || printf "There is no cache to be cleared.\n" - [ -e "$cacheloc/matrix-send/access-token" ] && rm -rf "$cacheloc/matrix-send/" && printf "Cleared cache\n" - exit 0 -} +-- Makes an HTTP POST request to uri and sends body. Returns the output of the HTTP server. +function post(uri, body) + local respbody = {} -- for the response body + local result, respcode, respheaders, respstatus = http.request { + method = "POST", + url = uri, + source = ltn12.source.string(body), + headers = { + ["content-type"] = "application/json", + ["content-length"] = tostring(#body) + }, + sink = ltn12.sink.table(respbody) + } + return table.concat(respbody) +end -Send () { - if [ -z "$prettyprint" ] - then curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" - else curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" | jq - fi -} +-- Makes an HTTP PUT request to uri and sends body. Returns the output of the HTTP server. +function put(uri, body) + local respbody = {} -- for the response body + local result, respcode, respheaders, respstatus = http.request { + method = "PUT", + url = uri, + source = ltn12.source.string(body), + headers = { + ["content-type"] = "application/json", + ["content-length"] = tostring(#body) + }, + sink = ltn12.sink.table(respbody) + } + return table.concat(respbody) +end -######################## -#### Initial checks #### -######################## +-- Prints a message to stdout in the following format: +-- matrix-send: s +function msg(s) + io.stdout:write(string.format("%s: %s\n", bname(arg[0]), s)) +end -[ -e /usr/local/bin/curl ] || [ -e /usr/bin/curl ] || error "curl not found" +-- Prints an error message to stderr in the following format: +-- matrix-send: s +-- After that, exits and returns 1 to the OS. +function panic(s) + io.stderr:write(string.format("%s: %s\n", bname(arg[0]), s)) + os.exit(1) +end -[ -z "$1" ] && usage -CacheLocation "$HOME/.cache" -while getopts :t:C:chV opt -do - case $opt in - t) - if vargrep "m\.(text|notice)" "$OPTARG" -Eq - then - mtype="$OPTARG" - optind="$OPTIND" - else error "Type not valid (-t)" - fi - ;; - C) - if vargrep "^~" "$OPTARG" -Eq - then config="$OPTARG" - elif vargrep "^/" "$OPTARG" -Eq - then config="$OPTARG" - else error "Configuration file location not valid (-C)" - fi - ;; - c) ClearCache ;; - h) help ;; - V) version ;; - esac -done -unset OPTARG -unset OPTIND +-- Prints an error message to stderr in the following format: +-- matrix-send: confpath: s +-- After that, exits and returns 1 to the OS. +function confpanic(s) + panic(string.format("%s: %s", bname(confpath), s)) + os.exit(1) +end -############################### -#### Configuration loading #### -############################### +--[[ + The configuration file for matrix-send is written in Lua format. + Here is a list of all possible options in the configuration file. + Default values appear after the '=' sign. -# Load configuration -if [ -e "$config" ]; -then . "$config" + login = { + -- The Matrix server to use. + server = nil, + + -- The user to log in to. + username = nil, + + -- The password for the user. + password = nil, + + -- The access token to use (instead of credentials). + -- If token equals nil, credentials are used. + -- If token is not nil, credentials are ignored. + token = nil + + -- The server value needs to be provided. + -- You can choose to login with user credentials or a + -- token. One of them needs to be provided. + } + + cache = { + -- The path to cache access tokens at. + location = "~/.cache/matrix-send", + + -- Disable caching access tokens? + disable = false + } + + rooms = { + -- Room aliases. + -- Here you can add aliases for rooms, + -- instead of having to type the confusing + -- Room ID every single time you send a message. + -- Examples: + --my_alias = "!AbCdEfGhIjKl:burger.land", + --lounge = "!MnOpQrSTuVWxYz:gaming.bruvs" + -- When you want to send to a Matrix room, you + -- can just type the alias instead of the long Room ID. + } + + advanced = { + -- The default event type. + -- Can be either m.text or m.notice. + event = "m.text" + } +--]] + +-- Default configuration file +default_config = [[ +-- Default configuration file for matrix-send +-- In comments, here is a simple example configuration. + +--login = { +-- server = "matrix.envs.net", +-- username = "john", +-- password = "examplepassword +--} + +-- You could also do it this way: + +--login.server = "matrix.envs.net" +--login.username = "john" +--login.password = "examplepassword" + +-- Both configurations do the same thing. + +-- See matrix-send.conf(5) for more information +-- on configuration files. +]] + +------------------------------------ +--- Default configuration values --- +------------------------------------ + +-- Initialise tables +login = {} +cache = {} +rooms = {} +advanced = {} + +-- Cache location +cache.location = "~/.cache/matrix-send" + +-- Disable caching access tokens? +cache.disable = false + +-- Message type +advanced.event = "m.text" + +---------------------- +--- Initial checks --- +---------------------- + +if arg[1] == nil then + io.stderr:write("usage: " .. bname(arg[0]) .. " [-t type] [-c config] [-ChV] message room\n") + os.exit(1) +end + +if confvarv then + if fileexists(confvarv) then + confpath = os.getenv("MATRIXSEND_CONFIG") + else + local _, err = fileexists(os.getenv("MATRIXSEND_CONFIG")) + panic("error opening " .. err) + end +end + +if not fileexists(confpath) then + mkdir(confdir) + f = io.open(confpath, 'w') + f:write(default_config) + f:close() +end +dofile(confpath) + +cache.location = string.gsub(cache.location, '~', os.getenv("HOME"), 1) + +-- Make sure all required values are set +if not login.server then + confpanic("required value 'login.server' left unset") +end + +-- login.token always supersedes login.username and password +if not login.token then + if not login.username then + confpanic("required value 'login.username' left unset") + elseif not login.password then + confpanic("required value 'login.password' left unset") + end +end + +-- Parse options +for opt, optarg, ind in getopt(arg, ':Cc:t:V') do + optind = ind + if opt == 'C' then + msg("clearing cache") + os.execute("rm -rf " .. cache.location) -- TODO: replace this os.execute line + os.exit(0) + elseif opt == 'c' then + confpath = optarg + elseif opt == 't' then + if optarg:match("m%.text") + or optarg:match("m%.notice") then + advanced.event = optarg + else panic("unknown message type '" .. optarg .. "'") + end + elseif opt == 'V' then + io.stdout:write("matrix-send version " .. version .. '\n') + io.stdout:write(_VERSION .. '\n') + os.exit(0) + elseif opt == '?' then + panic("unknown option " .. arg[optind-1]) + os.exit(1) + elseif opt == ':' then + panic("missing argument for option " .. arg[optind-1]) + os.exit(1) + end +end + +if optind == nil then + message = arg[1] + room = arg[2] else - warning "~/.config/matrix-send.conf doesn't exist; creating it" - mkdir -p $HOME/.config - touch $HOME/.config/matrix-send.conf -fi + message = arg[optind+1] + room = arg[optind+2] +end -# Run checks for essential directives -[ -z $server ] && conf_error "Server directive is not present" -[ -z $username ] && conf_error "Username directive is not present" -[ -z "$password" ] && conf_error "Password directive is not present" - -############## -#### Main #### -############## - -# Get token and cache it (unless NoCache is set) -[ -e "$cacheloc/matrix-send/access-token" ] && token=$(cat $cacheloc/matrix-send/access-token) -[ -e "$cacheloc/matrix-send/access-token" ] || GetAccessToken -CacheAccessToken - -if [ -z "$2" ]; -then error "Room ID not specified."; +if room:match("^!") then + room_id = room else - shift $((OPTIND-1)) - message="$1" - roomid_input="$2" - if [ -z "$mtype" ]; then mtype="$defaultevent"; fi; - if vargrep '!' "$roomid_input" -qo - then roomid="$(printf "$roomid_input" | sed 's/!//g')" - else roomid="$roomid_input"; fi - Send -fi + if rooms[room] ~= nil then + room_id = rooms[room] + else + panic("alias '" .. room .. "' invalid") + end +end + +if fileexists(cache.location .. "/txnid") then + txnidf = io.open(cache.location .. "/txnid", 'r') + txnid = txnidf:read('l') + txnidf:close() +else + txnid = 0 +end + +uri.login = string.format("https://%s/_matrix/client/v3/login", login.server) + +-- Assemble various JSON messages +json.message = string.format([[ +{ + "body": "%s", + "msgtype": "%s" +} +]], message, advanced.event) + +-- Get the access token if credentials are used +if not login.token then + if fileexists(cache.location .. "/token") then + cf = io.open(cache.location .. "/token", 'r') + login.token = cf:read('l') + cf:close() + else + -- json.login should only be assigned if it needs to be assigned + json.login = string.format([[ + { + "identifier": { + "type": "m.id.user", + "user": "%s" + }, + "initial_device_display_name": "matrix-send@%s", + "password": "%s", + "type": "m.login.password" + } + + ]], login.username, hostname, login.password) + + -- Send the request! + local body = post(uri.login, json.login) + + -- What else do I call it? + local t = cjson.decode(body) + + -- If there was a server side error, print the error and exit. + if t.error then + panic(login.server .. ": " .. t.error) + end + + -- Log the access token + login.token = t.access_token + + -- Cache the access token + mkdir(cache.location) + cf = io.open(cache.location .. "/token", 'w+') + cf:write(login.token) + cf:close() + end +end + +uri.message = string.format("https://%s/_matrix/client/v3/rooms/%s/send/m.room.message/%d?access_token=%s", + login.server, room_id, txnid, login.token) + +-- Send the message! +body = put(uri.message, json.message) +t = cjson.decode(body) +if t.error then + panic(login.server .. ": " .. t.error) +end + +-- Increment txnid and cache +txnidf = io.open(cache.location .. "/txnid", 'w+') +txnidf:write(txnid + 1) +txnidf:close() From 914e8af956e47159d664c5577a20cb26da9af55f Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 1 Jan 2023 09:53:10 +1300 Subject: [PATCH 106/133] Rewrote the whole entire thing in Lua Shortened list of changes: - Added room aliases - Switched the -C and -c flags - Added the MATRIXSEND_CONFIG environment variable - Changed config format to Lua over custom /bin/sh - Upgraded to Matrix spec 1.5 over whatever version it was previously using - Removed JSON printing (and in turn, pretty printing) - Added actual Matrix error reporting rather than just feeding the JSON to the user - Switched to luaposix getopt() over /bin/sh getopts - Some more changes... --- matrix-send | 551 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 347 insertions(+), 204 deletions(-) diff --git a/matrix-send b/matrix-send index 3d5f606..4d6e5f6 100755 --- a/matrix-send +++ b/matrix-send @@ -1,220 +1,363 @@ -#!/usr/bin/env sh -# matrix-send: send a message to a Matrix room +#!/usr/bin/env lua +--[[ + The GPLv2 License (GPLv2) + Copyright (c) 2022 Jeremy Baxter + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +]]-- -version="1.1" +require "luarocks.loader" +getopt = require "posix.unistd".getopt +mkdir = require "posix.sys.stat".mkdir +bname = require "posix.libgen".basename +http = require "socket.http" +cjson = require "cjson" +ltn12 = require "ltn12" -########################### -#### Generic Functions #### -########################### + version = "2.0" + confdir = string.gsub("~/.config/matrix-send", '~', os.getenv("HOME"), 1) +confpath = confdir .. "/config.lua" +confvarv = os.getenv("MATRIXSEND_CONFIG") +hostname = io.input("/etc/hostname"):read("l") -error () { - printf "\033[31;1merror:\033[0m $1\n" - exit 1 -} +json = {} + uri = {} + sh = os.execute -conf_error () { - printf "\033[31;1mconfiguration error:\033[0m $1\n" - exit 2 -} +----------------- +--- Functions --- +----------------- -warning () { - printf "\033[93;1mwarning:\033[0m $1\n" -} - -vargrep () { - printf "$2\n" | grep "$1" $3 -} - -usage () { - printf "usage: matrix-send [-t type] [-C config] [-chV] message room\n" - exit 1 -} - -help () { - cat < "$cacheloc/matrix-send/access-token"; - fi -} + return false, err + end +end -ClearCache () { - [ -e "$cacheloc/matrix-send/access-token" ] || printf "There is no cache to be cleared.\n" - [ -e "$cacheloc/matrix-send/access-token" ] && rm -rf "$cacheloc/matrix-send/" && printf "Cleared cache\n" - exit 0 -} +-- Makes an HTTP POST request to uri and sends body. Returns the output of the HTTP server. +function post(uri, body) + local respbody = {} -- for the response body + local result, respcode, respheaders, respstatus = http.request { + method = "POST", + url = uri, + source = ltn12.source.string(body), + headers = { + ["content-type"] = "application/json", + ["content-length"] = tostring(#body) + }, + sink = ltn12.sink.table(respbody) + } + return table.concat(respbody) +end -Send () { - if [ -z "$prettyprint" ] - then curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" - else curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" | jq - fi -} +-- Makes an HTTP PUT request to uri and sends body. Returns the output of the HTTP server. +function put(uri, body) + local respbody = {} -- for the response body + local result, respcode, respheaders, respstatus = http.request { + method = "PUT", + url = uri, + source = ltn12.source.string(body), + headers = { + ["content-type"] = "application/json", + ["content-length"] = tostring(#body) + }, + sink = ltn12.sink.table(respbody) + } + return table.concat(respbody) +end -######################## -#### Initial checks #### -######################## +-- Prints a message to stdout in the following format: +-- matrix-send: s +function msg(s) + io.stdout:write(string.format("%s: %s\n", bname(arg[0]), s)) +end -[ -e /usr/local/bin/curl ] || [ -e /usr/bin/curl ] || error "curl not found" +-- Prints an error message to stderr in the following format: +-- matrix-send: s +-- After that, exits and returns 1 to the OS. +function panic(s) + io.stderr:write(string.format("%s: %s\n", bname(arg[0]), s)) + os.exit(1) +end -[ -z "$1" ] && usage -CacheLocation "$HOME/.cache" -while getopts :t:C:chV opt -do - case $opt in - t) - if vargrep "m\.(text|notice)" "$OPTARG" -Eq - then - mtype="$OPTARG" - optind="$OPTIND" - else error "Type not valid (-t)" - fi - ;; - C) - if vargrep "^~" "$OPTARG" -Eq - then config="$OPTARG" - elif vargrep "^/" "$OPTARG" -Eq - then config="$OPTARG" - else error "Configuration file location not valid (-C)" - fi - ;; - c) ClearCache ;; - h) help ;; - V) version ;; - esac -done -unset OPTARG -unset OPTIND +-- Prints an error message to stderr in the following format: +-- matrix-send: confpath: s +-- After that, exits and returns 1 to the OS. +function confpanic(s) + panic(string.format("%s: %s", bname(confpath), s)) + os.exit(1) +end -############################### -#### Configuration loading #### -############################### +--[[ + The configuration file for matrix-send is written in Lua format. + Here is a list of all possible options in the configuration file. + Default values appear after the '=' sign. -# Load configuration -if [ -e "$config" ]; -then . "$config" + login = { + -- The Matrix server to use. + server = nil, + + -- The user to log in to. + username = nil, + + -- The password for the user. + password = nil, + + -- The access token to use (instead of credentials). + -- If token equals nil, credentials are used. + -- If token is not nil, credentials are ignored. + token = nil + + -- The server value needs to be provided. + -- You can choose to login with user credentials or a + -- token. One of them needs to be provided. + } + + cache = { + -- The path to cache access tokens at. + location = "~/.cache/matrix-send", + + -- Disable caching access tokens? + disable = false + } + + rooms = { + -- Room aliases. + -- Here you can add aliases for rooms, + -- instead of having to type the confusing + -- Room ID every single time you send a message. + -- Examples: + --my_alias = "!AbCdEfGhIjKl:burger.land", + --lounge = "!MnOpQrSTuVWxYz:gaming.bruvs" + -- When you want to send to a Matrix room, you + -- can just type the alias instead of the long Room ID. + } + + advanced = { + -- The default event type. + -- Can be either m.text or m.notice. + event = "m.text" + } +--]] + +-- Default configuration file +default_config = [[ +-- Default configuration file for matrix-send +-- In comments, here is a simple example configuration. + +--login = { +-- server = "matrix.envs.net", +-- username = "john", +-- password = "examplepassword +--} + +-- You could also do it this way: + +--login.server = "matrix.envs.net" +--login.username = "john" +--login.password = "examplepassword" + +-- Both configurations do the same thing. + +-- See matrix-send.conf(5) for more information +-- on configuration files. +]] + +------------------------------------ +--- Default configuration values --- +------------------------------------ + +-- Initialise tables +login = {} +cache = {} +rooms = {} +advanced = {} + +-- Cache location +cache.location = "~/.cache/matrix-send" + +-- Disable caching access tokens? +cache.disable = false + +-- Message type +advanced.event = "m.text" + +---------------------- +--- Initial checks --- +---------------------- + +if arg[1] == nil then + io.stderr:write("usage: " .. bname(arg[0]) .. " [-t type] [-c config] [-ChV] message room\n") + os.exit(1) +end + +if confvarv then + if fileexists(confvarv) then + confpath = os.getenv("MATRIXSEND_CONFIG") + else + local _, err = fileexists(os.getenv("MATRIXSEND_CONFIG")) + panic("error opening " .. err) + end +end + +if not fileexists(confpath) then + mkdir(confdir) + f = io.open(confpath, 'w') + f:write(default_config) + f:close() +end +dofile(confpath) + +cache.location = string.gsub(cache.location, '~', os.getenv("HOME"), 1) + +-- Make sure all required values are set +if not login.server then + confpanic("required value 'login.server' left unset") +end + +-- login.token always supersedes login.username and password +if not login.token then + if not login.username then + confpanic("required value 'login.username' left unset") + elseif not login.password then + confpanic("required value 'login.password' left unset") + end +end + +-- Parse options +for opt, optarg, ind in getopt(arg, ':Cc:t:V') do + optind = ind + if opt == 'C' then + msg("clearing cache") + os.execute("rm -rf " .. cache.location) -- TODO: replace this os.execute line + os.exit(0) + elseif opt == 'c' then + confpath = optarg + elseif opt == 't' then + if optarg:match("m%.text") + or optarg:match("m%.notice") then + advanced.event = optarg + else panic("unknown message type '" .. optarg .. "'") + end + elseif opt == 'V' then + io.stdout:write("matrix-send version " .. version .. '\n') + io.stdout:write(_VERSION .. '\n') + os.exit(0) + elseif opt == '?' then + panic("unknown option " .. arg[optind-1]) + os.exit(1) + elseif opt == ':' then + panic("missing argument for option " .. arg[optind-1]) + os.exit(1) + end +end + +if optind == nil then + message = arg[1] + room = arg[2] else - warning "~/.config/matrix-send.conf doesn't exist; creating it" - mkdir -p $HOME/.config - touch $HOME/.config/matrix-send.conf -fi + message = arg[optind+1] + room = arg[optind+2] +end -# Run checks for essential directives -[ -z $server ] && conf_error "Server directive is not present" -[ -z $username ] && conf_error "Username directive is not present" -[ -z "$password" ] && conf_error "Password directive is not present" - -############## -#### Main #### -############## - -# Get token and cache it (unless NoCache is set) -[ -e "$cacheloc/matrix-send/access-token" ] && token=$(cat $cacheloc/matrix-send/access-token) -[ -e "$cacheloc/matrix-send/access-token" ] || GetAccessToken -CacheAccessToken - -if [ -z "$2" ]; -then error "Room ID not specified."; +if room:match("^!") then + room_id = room else - shift $((OPTIND-1)) - message="$1" - roomid_input="$2" - if [ -z "$mtype" ]; then mtype="$defaultevent"; fi; - if vargrep '!' "$roomid_input" -qo - then roomid="$(printf "$roomid_input" | sed 's/!//g')" - else roomid="$roomid_input"; fi - Send -fi + if rooms[room] ~= nil then + room_id = rooms[room] + else + panic("alias '" .. room .. "' invalid") + end +end + +if fileexists(cache.location .. "/txnid") then + txnidf = io.open(cache.location .. "/txnid", 'r') + txnid = txnidf:read('l') + txnidf:close() +else + txnid = 0 +end + +uri.login = string.format("https://%s/_matrix/client/v3/login", login.server) + +-- Assemble various JSON messages +json.message = string.format([[ +{ + "body": "%s", + "msgtype": "%s" +} +]], message, advanced.event) + +-- Get the access token if credentials are used +if not login.token then + if fileexists(cache.location .. "/token") then + cf = io.open(cache.location .. "/token", 'r') + login.token = cf:read('l') + cf:close() + else + -- json.login should only be assigned if it needs to be assigned + json.login = string.format([[ + { + "identifier": { + "type": "m.id.user", + "user": "%s" + }, + "initial_device_display_name": "matrix-send@%s", + "password": "%s", + "type": "m.login.password" + } + + ]], login.username, hostname, login.password) + + -- Send the request! + local body = post(uri.login, json.login) + + -- What else do I call it? + local t = cjson.decode(body) + + -- If there was a server side error, print the error and exit. + if t.error then + panic(login.server .. ": " .. t.error) + end + + -- Log the access token + login.token = t.access_token + + -- Cache the access token + mkdir(cache.location) + cf = io.open(cache.location .. "/token", 'w+') + cf:write(login.token) + cf:close() + end +end + +uri.message = string.format("https://%s/_matrix/client/v3/rooms/%s/send/m.room.message/%d?access_token=%s", + login.server, room_id, txnid, login.token) + +-- Send the message! +body = put(uri.message, json.message) +t = cjson.decode(body) +if t.error then + panic(login.server .. ": " .. t.error) +end + +-- Increment txnid and cache +txnidf = io.open(cache.location .. "/txnid", 'w+') +txnidf:write(txnid + 1) +txnidf:close() From 23da704ccbf83db1e0008aa4e27e181241ebe3b6 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sun, 1 Jan 2023 09:57:12 +1300 Subject: [PATCH 107/133] Added Lua gitignore --- .gitignore | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6fd0a37 --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +# Compiled Lua sources +luac.out + +# luarocks build files +*.src.rock +*.zip +*.tar.gz + +# Object files +*.o +*.os +*.ko +*.obj +*.elf + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo +*.def +*.exp + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + From 40733b4d52abe3b4aba48859de3ba37b8f4c9952 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 1 Jan 2023 09:57:12 +1300 Subject: [PATCH 108/133] Added Lua gitignore --- .gitignore | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6fd0a37 --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +# Compiled Lua sources +luac.out + +# luarocks build files +*.src.rock +*.zip +*.tar.gz + +# Object files +*.o +*.os +*.ko +*.obj +*.elf + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo +*.def +*.exp + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + From 3b1db9ece2fef73b0519e4365705ca3ec7bc4b25 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sun, 1 Jan 2023 09:59:16 +1300 Subject: [PATCH 109/133] Update usage --- matrix-send | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix-send b/matrix-send index 4d6e5f6..6a9b479 100755 --- a/matrix-send +++ b/matrix-send @@ -203,7 +203,7 @@ advanced.event = "m.text" ---------------------- if arg[1] == nil then - io.stderr:write("usage: " .. bname(arg[0]) .. " [-t type] [-c config] [-ChV] message room\n") + io.stderr:write("usage: " .. bname(arg[0]) .. " [-c config] [-t type] [-CV] message room\n") os.exit(1) end From 75de7727d0a85eed6595742b32952fb88765ac9d Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 1 Jan 2023 09:59:16 +1300 Subject: [PATCH 110/133] Update usage --- matrix-send | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix-send b/matrix-send index 4d6e5f6..6a9b479 100755 --- a/matrix-send +++ b/matrix-send @@ -203,7 +203,7 @@ advanced.event = "m.text" ---------------------- if arg[1] == nil then - io.stderr:write("usage: " .. bname(arg[0]) .. " [-t type] [-c config] [-ChV] message room\n") + io.stderr:write("usage: " .. bname(arg[0]) .. " [-c config] [-t type] [-CV] message room\n") os.exit(1) end From 959c3c9c9bc8773c09ffb7606573a11c423ef0ab Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sun, 1 Jan 2023 10:57:22 +1300 Subject: [PATCH 111/133] Add cache.disable logic (oops...) --- matrix-send | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/matrix-send b/matrix-send index 6a9b479..392e393 100755 --- a/matrix-send +++ b/matrix-send @@ -340,10 +340,12 @@ if not login.token then login.token = t.access_token -- Cache the access token - mkdir(cache.location) - cf = io.open(cache.location .. "/token", 'w+') - cf:write(login.token) - cf:close() + if not cache.disable then + mkdir(cache.location) + cf = io.open(cache.location .. "/token", 'w+') + cf:write(login.token) + cf:close() + end end end @@ -358,6 +360,8 @@ if t.error then end -- Increment txnid and cache -txnidf = io.open(cache.location .. "/txnid", 'w+') -txnidf:write(txnid + 1) -txnidf:close() +if not cache.disable then + txnidf = io.open(cache.location .. "/txnid", 'w+') + txnidf:write(txnid + 1) + txnidf:close() +end From 88e373a777fa53980148180788abb98df167f80d Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 1 Jan 2023 10:57:22 +1300 Subject: [PATCH 112/133] Add cache.disable logic (oops...) --- matrix-send | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/matrix-send b/matrix-send index 6a9b479..392e393 100755 --- a/matrix-send +++ b/matrix-send @@ -340,10 +340,12 @@ if not login.token then login.token = t.access_token -- Cache the access token - mkdir(cache.location) - cf = io.open(cache.location .. "/token", 'w+') - cf:write(login.token) - cf:close() + if not cache.disable then + mkdir(cache.location) + cf = io.open(cache.location .. "/token", 'w+') + cf:write(login.token) + cf:close() + end end end @@ -358,6 +360,8 @@ if t.error then end -- Increment txnid and cache -txnidf = io.open(cache.location .. "/txnid", 'w+') -txnidf:write(txnid + 1) -txnidf:close() +if not cache.disable then + txnidf = io.open(cache.location .. "/txnid", 'w+') + txnidf:write(txnid + 1) + txnidf:close() +end From 107ec868ba71ac407d4570999e0ebbaeb139487a Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sun, 1 Jan 2023 12:03:47 +1300 Subject: [PATCH 113/133] Update documentation for version 2.0 --- Makefile | 5 ++- README.md | 12 ++---- config.lua | 31 +++++++++++++++ default_config.lua | 49 +++++++++++++++++++++++ matrix-send | 52 ------------------------ matrix-send-config.5 | 65 ++++++++++++++++++++++++++++++ matrix-send.1 | 94 +++++++++++++++++++++++++------------------- matrix-send.conf | 17 -------- matrix-send.conf.5 | 60 ---------------------------- 9 files changed, 204 insertions(+), 181 deletions(-) create mode 100644 config.lua create mode 100644 default_config.lua create mode 100644 matrix-send-config.5 delete mode 100644 matrix-send.conf delete mode 100644 matrix-send.conf.5 diff --git a/Makefile b/Makefile index cf63374..cd74faf 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ PREFIX = /usr/local MANPREFIX = ${PREFIX}/man config: - cp matrix-send.conf ~/.config/matrix-send.conf + mkdir -p ~/.config/matrix-send + cp config.lua ~/.config/matrix-send/config.lua install: cp -f matrix-send ${DESTDIR}${PREFIX}/bin @@ -11,4 +12,4 @@ install: mkdir -p ${DESTDIR}${MANPREFIX}/man1 cp -f matrix-send.1 ${DESTDIR}${MANPREFIX}/man1 mkdir -p ${DESTDIR}${MANPREFIX}/man5 - cp -f matrix-send.conf.5 ${DESTDIR}${MANPREFIX}/man5 + cp -f matrix-send-config.5 ${DESTDIR}${MANPREFIX}/man5 diff --git a/README.md b/README.md index 3b5d4ec..a71f45c 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,16 @@ # matrix-send -A script that sends a message to a Matrix room. +A script that sends messages to Matrix rooms. [Read the manual page](https://jtbx.codeberg.page/man/matrix-send.1) --- -**Syntax:** `matrix-send message room` - -**Example:** `matrix-send "Hello world\!" \!aBcDeFgHiJkLmNoP:example.org` - ---- - matrix-send is a simple script that sends a message to a Matrix room. -It does this by sending a JSON message to your Matrix server. The message types that are supported are *m.text*, and *m.notice*. +It does this by sending a JSON message to your Matrix server. The message types that are supported are `m.text`, and `m.notice`. -It is mainly designed for automation. I use it on a private Matrix room of mine. +It is mainly designed for automation. There aren't any plans for matrix-send to support encryption. diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..f271a49 --- /dev/null +++ b/config.lua @@ -0,0 +1,31 @@ +login = { + -- The Matrix server to use. + server = "matrix-client.matrix.org", -- matrix.org + + -- The user to log in to. + username = "user", + + -- The password for the user. + password = "password", + + -- The access token to use (instead of credentials). + -- If token equals nil, credentials are used. + -- If token is not nil, credentials are ignored. + token = nil + + -- The server value needs to be provided. + -- You can choose to login with user credentials or a + -- token. One of them needs to be provided. +} + +rooms = { + -- Room aliases. + -- Here you can add aliases for rooms, + -- instead of having to type the confusing + -- Room ID every single time you send a message. + -- Examples: + --my_alias = "!AbCdEfGhIjKl:burger.land", + --lounge = "!MnOpQrSTuVWxYz:gaming.bruvs" + -- When you want to send to a Matrix room, you + -- can just type the alias instead of the long Room ID. +} diff --git a/default_config.lua b/default_config.lua new file mode 100644 index 0000000..76cd492 --- /dev/null +++ b/default_config.lua @@ -0,0 +1,49 @@ +-- The configuration file for matrix-send is written in Lua format. +-- Here is a list of all possible options in the configuration file. +-- Default values appear after the '=' sign. + +login = { + -- The Matrix server to use. + server = nil, + + -- The user to log in to. + username = nil, + + -- The password for the user. + password = nil, + + -- The access token to use (instead of credentials). + -- If token equals nil, credentials are used. + -- If token is not nil, credentials are ignored. + token = nil + + -- The server value needs to be provided. + -- You can choose to login with user credentials or a + -- token. One of them needs to be provided. +} + +cache = { + -- The path to cache access tokens at. + location = "~/.cache/matrix-send", + + -- Disable caching access tokens? + disable = false +} + +rooms = { + -- Room aliases. + -- Here you can add aliases for rooms, + -- instead of having to type the confusing + -- Room ID every single time you send a message. + -- Examples: + --my_alias = "!AbCdEfGhIjKl:burger.land", + --lounge = "!MnOpQrSTuVWxYz:gaming.bruvs" + -- When you want to send to a Matrix room, you + -- can just type the alias instead of the long Room ID. +} + +advanced = { + -- The default event type. + -- Can be either m.text or m.notice. + event = "m.text" +} diff --git a/matrix-send b/matrix-send index 392e393..f042356 100755 --- a/matrix-send +++ b/matrix-send @@ -104,58 +104,6 @@ function confpanic(s) os.exit(1) end ---[[ - The configuration file for matrix-send is written in Lua format. - Here is a list of all possible options in the configuration file. - Default values appear after the '=' sign. - - login = { - -- The Matrix server to use. - server = nil, - - -- The user to log in to. - username = nil, - - -- The password for the user. - password = nil, - - -- The access token to use (instead of credentials). - -- If token equals nil, credentials are used. - -- If token is not nil, credentials are ignored. - token = nil - - -- The server value needs to be provided. - -- You can choose to login with user credentials or a - -- token. One of them needs to be provided. - } - - cache = { - -- The path to cache access tokens at. - location = "~/.cache/matrix-send", - - -- Disable caching access tokens? - disable = false - } - - rooms = { - -- Room aliases. - -- Here you can add aliases for rooms, - -- instead of having to type the confusing - -- Room ID every single time you send a message. - -- Examples: - --my_alias = "!AbCdEfGhIjKl:burger.land", - --lounge = "!MnOpQrSTuVWxYz:gaming.bruvs" - -- When you want to send to a Matrix room, you - -- can just type the alias instead of the long Room ID. - } - - advanced = { - -- The default event type. - -- Can be either m.text or m.notice. - event = "m.text" - } ---]] - -- Default configuration file default_config = [[ -- Default configuration file for matrix-send diff --git a/matrix-send-config.5 b/matrix-send-config.5 new file mode 100644 index 0000000..b2c468c --- /dev/null +++ b/matrix-send-config.5 @@ -0,0 +1,65 @@ +.Dd $Mdocdate: January 1 2023 $ +.Dt MATRIX-SEND-CONFIG 5 +.Os +.Sh NAME +.Nm config.lua +.Nd configuration file for +.Xr matrix-send 1 +.Sh DESCRIPTION +.Xr matrix-send 1 +sends messages to Matrix rooms. In order to send a message however, it needs +credentials for the account sending the message. These credentials are provided +in the +.Nm +configuration file, as well as other options if you need them. +.Pp +The configuration file is in Lua format, meaning +you can write whatever Lua code you wish inside. +.Pp +The following configuration options are available: +.Bl -tag -width 11n +.Bl -tag -width login.server +.It Ic login.server Ar server +The Client-Server API address of the Matrix server being used. +.It Ic login.username Ar username +The username of the account being used. +.It Ic login.password Ar password +The password for the account being used. +.It Ic login.token Ar token +Instead of authenticating via username and password to obtain an access token, use +.Ar token +as the access token. +.It Ic cache.location Ar location +Use +.Ar location +as the cache location. +.It Ic cache.disable +Don't cache anything. +.It Ic advanced.event Ar type +Modify the default event type from the default (m.text) to +.Ar type . +Supported types are m.text, and m.notice. +.El +.Sh FILES +.Bl -tag -width ~/.config/matrix-send/config.lua -compact +.It Pa ~/.config/matrix-send/config.lua +.Xr matrix-send 1 +configuration file +.It Pa ~/.cache/matrix-send +default cache directory +.El +.Sh EXAMPLES +The following example logs into the user 'john' of the server +matrix-client.matrix.org, and the password 'supersecretpassword', +and sets the default event type to m.notice. +.Bd -literal -offset indent +login = { + server = "matrix-client.matrix.org", + username = "john", + password = "supersecretpassword" +} + +advanced.event = "m.notice" +.Ed +.Sh SEE ALSO +.Xr matrix-send 1 diff --git a/matrix-send.1 b/matrix-send.1 index bd4bc75..9b57606 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: August 4 2022 $ +.Dd $Mdocdate: January 1 2023 $ .Dt MATRIX-SEND 1 .Os .Sh NAME @@ -8,19 +8,24 @@ .Nm matrix-send .Bk -words .Op Fl t Ar type -.Op Fl C Ar config -.Op Fl chV +.Op Fl c Ar config +.Op Fl CV .Ar message room .Ek .Sh DESCRIPTION .Nm -is a script that sends a message to a Matrix room. -It works by sending a JSON message to your Matrix server. The default message -type is m.text, but you can specify a custom type with +sends messages to Matrix rooms. +The default event type is m.text (standard text message), +but you can specify a custom type with .Em -t . .Pp The options are as follows: .Bl -tag -width keyword +.It Fl C +Clear cached access tokens and transaction IDs then exit. +.It Fl c Ar config +Instead of reading the default configuration file (~/.config/matrix-send.conf), read +.Ar config . .It Fl t Ar type Change the event type to .Ar type . @@ -30,49 +35,52 @@ and .Em m.notice . Default is .Em m.text . -.It Fl C Ar config -Instead of reading the default configuration file (~/.config/matrix-send.conf), read -.Ar config . -.It Fl c -Clear cached access tokens. -.It Fl h -Show the help menu, then exit. .It Fl V -Print version and program information, then exit. +Print version information and exit. .El .Pp To begin, start by making a configuration file. This always has the location of -.Em ~/.config/matrix-send.conf . +.Em ~/.config/matrix-send/config.lua . -At the very least, your configuration file has to contain 3 directives: -.Em Server , -.Em Username , +At the very least, your configuration file has to contain three values: +.Em login.server , +.Em login.username , and -.Em Password . -Let's say your Matrix server is envs.net. Your username is john, and your password +.Em login.password . +Let's say your Matrix server is envs.net, your username is john, and your password is supersecretpassword. Your configuration could look like this: .Bd -literal -offset indent -Server matrix.envs.net -Username john -Password supersecretpassword +login = { + server = "matrix.envs.net", + username = "john", + password = "supersecretpassword" +} .Ed .Pp -In that example, we used matrix.envs.net instead of envs.net. This is because +It could also look like this: +.Bd -literal -offset indent +login.server = "matrix.envs.net" +login.username = "john" +login.password = "supersecretpassword" +.Ed +.Pp +In those examples, we used matrix.envs.net instead of envs.net. This is because matrix.envs.net is the address in which the Client-Server API is listening on. -You can find your server's Client-Server API URL in Element by entering in -your server into the Homeserver dialogue in the sign-in screen, then hovering +You can find this address in Element by entering in your server into the +Homeserver dialogue in the sign-in screen, then hovering over it once entered. Your server's Client-Server API URL should appear once -you hover over it. If it doesn't appear, you've already got it. +you hover over it. If it doesn't appear, you should already have it. .Pp You may have noticed that with this configuration, your password is visible in plain sight. -At its most basic, matrix-send.conf is a shell script. This means you could +If you would like to have to encrypt your password before use, +you could replace the -.Em Password +.Em login.password line with something similar to this .Pp -.Dl Password $(gpg -d /path/to/passwd.gpg) + login.password = sh "gpg -d /path/to/passwd.gpg" .Pp where .Em /path/to/passwd.gpg @@ -82,7 +90,7 @@ decrypt your password file before authenticating. This way, your password is not in plain text. More information on configuration options can be found in -.Xr matrix-send.conf 5 . +.Xr matrix-send-config 5 . .Pp To use .Nm , @@ -102,9 +110,13 @@ to the room with the Room ID !zyxwvutsrq:example.org. By default, .Nm caches access tokens in -.Em $HOME/.cache/matrix-send/access-token . -If you would like to disable caching of access tokens, add NoCache to your -.Em matrix-send.conf . +.Em $HOME/.cache/matrix-send/token . +If you would like to disable caching of access tokens, add +.Pp +.Dl cache.disable = true +.Pp +to your +.Em config.lua . .Pp Encryption is not supported. All messages will be sent unencrypted. There are currently no plans to add encryption to @@ -112,19 +124,19 @@ There are currently no plans to add encryption to .El .Sh FILES -.Bl -tag -width ~/.config/matrix-send.conf -.It Pa ~/.config/matrix-send.conf +.Bl -tag -width ~/.config/matrix-send/config.lua +.It Pa ~/.config/matrix-send/config.lua configuration file for .Nm -.It Pa ~/.cache/matrix-send/access-token -access token cache file +.It Pa ~/.cache/matrix-send +cache directory .El .Sh EXAMPLES -Send a message saying "How are you?" to the Matrix room !TfbDbeqp:example.org: +Send a message saying "Hello world!" to the Matrix room !TfbDbeqp:example.org: .Pp -.Dl matrix-send 'How are you?' !TfbDbeqp:example.org +.Dl matrix-send 'Hello world!' \\!TfbDbeqp:example.org .Pp .Sh SEE ALSO -.Xr matrix-send.conf 5 +.Xr matrix-send-config 5 diff --git a/matrix-send.conf b/matrix-send.conf deleted file mode 100644 index a7582ab..0000000 --- a/matrix-send.conf +++ /dev/null @@ -1,17 +0,0 @@ -## Example basic configuration for matrix-send -# A line with an option (e.g. 'Username jeremy') is a "directive". -# A line with only one word (e.g. 'NoCache') is a "statement". -# Comments start with a pound (#) -# Additional options can be found in matrix-send.conf(5) - -# The Server directive is for your server's Matrix Client-Server API URL. -# matrix-send assumes that this is valid. -# matrix.org's CS API URL is matrix-client.matrix.org. -# You can find it by typing it into Element's sign in page and hovering your mouse over it. -Server matrix.envs.net - -# The Username directive is your username for that server. -Username john - -# The Password directive is your password for your account. -Password supersecretpassword diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 deleted file mode 100644 index 55a1c50..0000000 --- a/matrix-send.conf.5 +++ /dev/null @@ -1,60 +0,0 @@ -.Dd $Mdocdate: August 4 2022 $ -.Dt MATRIX-SEND.CONF 5 -.Os -.Sh NAME -.Nm matrix-send.conf -.Nd configuration file for -.Xr matrix-send 1 -.Sh DESCRIPTION -.Xr matrix-send 1 -sends messages to Matrix rooms. In order to send a message however, it needs -credentials for the account sending the message. These credentials are provided -in the -.Nm -configuration file, as well as other options if you need them. -.Pp -The following configuration options are available: -.Bl -tag -width 11n -.Bl -tag -width keepenv -.It Ic Server Ar server -The Client-Server API address of the Matrix server being used. -.It Ic Username Ar username -The username of the account being used. -.It Ic Password Ar password -The password for the account being used. -.It Ic AccessToken Ar token -Instead of authenticating via username and password to obtain an access token, use -.Ar token -as the access token. -.It Ic CacheLocation Ar location -Modify the cache location from the default (~/.cache) to -.Ar location . -.It Ic NoCache -Don't cache access tokens. -.It Ic DefaultEvent Ar type -Modify the default event type from the default (m.text) to -.Ar type . -Supported types are m.text, and m.notice. -.It Ic PrettyPrint -Pretty-print the JSON server messages. -.El -.Sh FILES -.Bl -tag -width ~/.config/matrix-send.conf -compact -.It Pa ~/.config/matrix-send.conf -.Xr matrix-send 1 -configuration file. -.It Pa ~/.cache -Default cache location. -.El -.Sh EXAMPLES -The following example logs into the user johndoe of the server with the -Client-Server API address of matrix-client.matrix.org with the password -supersecretpassword, and sets the default event type to m.notice. -.Bd -literal -offset indent -Server matrix-client.matrix.org -Username johndoe -Password supersecretpassword -DefaultEvent m.notice -.Ed -.Sh SEE ALSO -.Xr matrix-send 1 From a112ef195a5bb71f6861b4ba559bc36b8d139ecc Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 1 Jan 2023 12:03:47 +1300 Subject: [PATCH 114/133] Update documentation for version 2.0 --- Makefile | 5 ++- README.md | 12 ++---- config.lua | 31 +++++++++++++++ default_config.lua | 49 +++++++++++++++++++++++ matrix-send | 52 ------------------------ matrix-send-config.5 | 65 ++++++++++++++++++++++++++++++ matrix-send.1 | 94 +++++++++++++++++++++++++------------------- matrix-send.conf | 17 -------- matrix-send.conf.5 | 60 ---------------------------- 9 files changed, 204 insertions(+), 181 deletions(-) create mode 100644 config.lua create mode 100644 default_config.lua create mode 100644 matrix-send-config.5 delete mode 100644 matrix-send.conf delete mode 100644 matrix-send.conf.5 diff --git a/Makefile b/Makefile index cf63374..cd74faf 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ PREFIX = /usr/local MANPREFIX = ${PREFIX}/man config: - cp matrix-send.conf ~/.config/matrix-send.conf + mkdir -p ~/.config/matrix-send + cp config.lua ~/.config/matrix-send/config.lua install: cp -f matrix-send ${DESTDIR}${PREFIX}/bin @@ -11,4 +12,4 @@ install: mkdir -p ${DESTDIR}${MANPREFIX}/man1 cp -f matrix-send.1 ${DESTDIR}${MANPREFIX}/man1 mkdir -p ${DESTDIR}${MANPREFIX}/man5 - cp -f matrix-send.conf.5 ${DESTDIR}${MANPREFIX}/man5 + cp -f matrix-send-config.5 ${DESTDIR}${MANPREFIX}/man5 diff --git a/README.md b/README.md index 3b5d4ec..a71f45c 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,16 @@ # matrix-send -A script that sends a message to a Matrix room. +A script that sends messages to Matrix rooms. [Read the manual page](https://jtbx.codeberg.page/man/matrix-send.1) --- -**Syntax:** `matrix-send message room` - -**Example:** `matrix-send "Hello world\!" \!aBcDeFgHiJkLmNoP:example.org` - ---- - matrix-send is a simple script that sends a message to a Matrix room. -It does this by sending a JSON message to your Matrix server. The message types that are supported are *m.text*, and *m.notice*. +It does this by sending a JSON message to your Matrix server. The message types that are supported are `m.text`, and `m.notice`. -It is mainly designed for automation. I use it on a private Matrix room of mine. +It is mainly designed for automation. There aren't any plans for matrix-send to support encryption. diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..f271a49 --- /dev/null +++ b/config.lua @@ -0,0 +1,31 @@ +login = { + -- The Matrix server to use. + server = "matrix-client.matrix.org", -- matrix.org + + -- The user to log in to. + username = "user", + + -- The password for the user. + password = "password", + + -- The access token to use (instead of credentials). + -- If token equals nil, credentials are used. + -- If token is not nil, credentials are ignored. + token = nil + + -- The server value needs to be provided. + -- You can choose to login with user credentials or a + -- token. One of them needs to be provided. +} + +rooms = { + -- Room aliases. + -- Here you can add aliases for rooms, + -- instead of having to type the confusing + -- Room ID every single time you send a message. + -- Examples: + --my_alias = "!AbCdEfGhIjKl:burger.land", + --lounge = "!MnOpQrSTuVWxYz:gaming.bruvs" + -- When you want to send to a Matrix room, you + -- can just type the alias instead of the long Room ID. +} diff --git a/default_config.lua b/default_config.lua new file mode 100644 index 0000000..76cd492 --- /dev/null +++ b/default_config.lua @@ -0,0 +1,49 @@ +-- The configuration file for matrix-send is written in Lua format. +-- Here is a list of all possible options in the configuration file. +-- Default values appear after the '=' sign. + +login = { + -- The Matrix server to use. + server = nil, + + -- The user to log in to. + username = nil, + + -- The password for the user. + password = nil, + + -- The access token to use (instead of credentials). + -- If token equals nil, credentials are used. + -- If token is not nil, credentials are ignored. + token = nil + + -- The server value needs to be provided. + -- You can choose to login with user credentials or a + -- token. One of them needs to be provided. +} + +cache = { + -- The path to cache access tokens at. + location = "~/.cache/matrix-send", + + -- Disable caching access tokens? + disable = false +} + +rooms = { + -- Room aliases. + -- Here you can add aliases for rooms, + -- instead of having to type the confusing + -- Room ID every single time you send a message. + -- Examples: + --my_alias = "!AbCdEfGhIjKl:burger.land", + --lounge = "!MnOpQrSTuVWxYz:gaming.bruvs" + -- When you want to send to a Matrix room, you + -- can just type the alias instead of the long Room ID. +} + +advanced = { + -- The default event type. + -- Can be either m.text or m.notice. + event = "m.text" +} diff --git a/matrix-send b/matrix-send index 392e393..f042356 100755 --- a/matrix-send +++ b/matrix-send @@ -104,58 +104,6 @@ function confpanic(s) os.exit(1) end ---[[ - The configuration file for matrix-send is written in Lua format. - Here is a list of all possible options in the configuration file. - Default values appear after the '=' sign. - - login = { - -- The Matrix server to use. - server = nil, - - -- The user to log in to. - username = nil, - - -- The password for the user. - password = nil, - - -- The access token to use (instead of credentials). - -- If token equals nil, credentials are used. - -- If token is not nil, credentials are ignored. - token = nil - - -- The server value needs to be provided. - -- You can choose to login with user credentials or a - -- token. One of them needs to be provided. - } - - cache = { - -- The path to cache access tokens at. - location = "~/.cache/matrix-send", - - -- Disable caching access tokens? - disable = false - } - - rooms = { - -- Room aliases. - -- Here you can add aliases for rooms, - -- instead of having to type the confusing - -- Room ID every single time you send a message. - -- Examples: - --my_alias = "!AbCdEfGhIjKl:burger.land", - --lounge = "!MnOpQrSTuVWxYz:gaming.bruvs" - -- When you want to send to a Matrix room, you - -- can just type the alias instead of the long Room ID. - } - - advanced = { - -- The default event type. - -- Can be either m.text or m.notice. - event = "m.text" - } ---]] - -- Default configuration file default_config = [[ -- Default configuration file for matrix-send diff --git a/matrix-send-config.5 b/matrix-send-config.5 new file mode 100644 index 0000000..b2c468c --- /dev/null +++ b/matrix-send-config.5 @@ -0,0 +1,65 @@ +.Dd $Mdocdate: January 1 2023 $ +.Dt MATRIX-SEND-CONFIG 5 +.Os +.Sh NAME +.Nm config.lua +.Nd configuration file for +.Xr matrix-send 1 +.Sh DESCRIPTION +.Xr matrix-send 1 +sends messages to Matrix rooms. In order to send a message however, it needs +credentials for the account sending the message. These credentials are provided +in the +.Nm +configuration file, as well as other options if you need them. +.Pp +The configuration file is in Lua format, meaning +you can write whatever Lua code you wish inside. +.Pp +The following configuration options are available: +.Bl -tag -width 11n +.Bl -tag -width login.server +.It Ic login.server Ar server +The Client-Server API address of the Matrix server being used. +.It Ic login.username Ar username +The username of the account being used. +.It Ic login.password Ar password +The password for the account being used. +.It Ic login.token Ar token +Instead of authenticating via username and password to obtain an access token, use +.Ar token +as the access token. +.It Ic cache.location Ar location +Use +.Ar location +as the cache location. +.It Ic cache.disable +Don't cache anything. +.It Ic advanced.event Ar type +Modify the default event type from the default (m.text) to +.Ar type . +Supported types are m.text, and m.notice. +.El +.Sh FILES +.Bl -tag -width ~/.config/matrix-send/config.lua -compact +.It Pa ~/.config/matrix-send/config.lua +.Xr matrix-send 1 +configuration file +.It Pa ~/.cache/matrix-send +default cache directory +.El +.Sh EXAMPLES +The following example logs into the user 'john' of the server +matrix-client.matrix.org, and the password 'supersecretpassword', +and sets the default event type to m.notice. +.Bd -literal -offset indent +login = { + server = "matrix-client.matrix.org", + username = "john", + password = "supersecretpassword" +} + +advanced.event = "m.notice" +.Ed +.Sh SEE ALSO +.Xr matrix-send 1 diff --git a/matrix-send.1 b/matrix-send.1 index bd4bc75..9b57606 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: August 4 2022 $ +.Dd $Mdocdate: January 1 2023 $ .Dt MATRIX-SEND 1 .Os .Sh NAME @@ -8,19 +8,24 @@ .Nm matrix-send .Bk -words .Op Fl t Ar type -.Op Fl C Ar config -.Op Fl chV +.Op Fl c Ar config +.Op Fl CV .Ar message room .Ek .Sh DESCRIPTION .Nm -is a script that sends a message to a Matrix room. -It works by sending a JSON message to your Matrix server. The default message -type is m.text, but you can specify a custom type with +sends messages to Matrix rooms. +The default event type is m.text (standard text message), +but you can specify a custom type with .Em -t . .Pp The options are as follows: .Bl -tag -width keyword +.It Fl C +Clear cached access tokens and transaction IDs then exit. +.It Fl c Ar config +Instead of reading the default configuration file (~/.config/matrix-send.conf), read +.Ar config . .It Fl t Ar type Change the event type to .Ar type . @@ -30,49 +35,52 @@ and .Em m.notice . Default is .Em m.text . -.It Fl C Ar config -Instead of reading the default configuration file (~/.config/matrix-send.conf), read -.Ar config . -.It Fl c -Clear cached access tokens. -.It Fl h -Show the help menu, then exit. .It Fl V -Print version and program information, then exit. +Print version information and exit. .El .Pp To begin, start by making a configuration file. This always has the location of -.Em ~/.config/matrix-send.conf . +.Em ~/.config/matrix-send/config.lua . -At the very least, your configuration file has to contain 3 directives: -.Em Server , -.Em Username , +At the very least, your configuration file has to contain three values: +.Em login.server , +.Em login.username , and -.Em Password . -Let's say your Matrix server is envs.net. Your username is john, and your password +.Em login.password . +Let's say your Matrix server is envs.net, your username is john, and your password is supersecretpassword. Your configuration could look like this: .Bd -literal -offset indent -Server matrix.envs.net -Username john -Password supersecretpassword +login = { + server = "matrix.envs.net", + username = "john", + password = "supersecretpassword" +} .Ed .Pp -In that example, we used matrix.envs.net instead of envs.net. This is because +It could also look like this: +.Bd -literal -offset indent +login.server = "matrix.envs.net" +login.username = "john" +login.password = "supersecretpassword" +.Ed +.Pp +In those examples, we used matrix.envs.net instead of envs.net. This is because matrix.envs.net is the address in which the Client-Server API is listening on. -You can find your server's Client-Server API URL in Element by entering in -your server into the Homeserver dialogue in the sign-in screen, then hovering +You can find this address in Element by entering in your server into the +Homeserver dialogue in the sign-in screen, then hovering over it once entered. Your server's Client-Server API URL should appear once -you hover over it. If it doesn't appear, you've already got it. +you hover over it. If it doesn't appear, you should already have it. .Pp You may have noticed that with this configuration, your password is visible in plain sight. -At its most basic, matrix-send.conf is a shell script. This means you could +If you would like to have to encrypt your password before use, +you could replace the -.Em Password +.Em login.password line with something similar to this .Pp -.Dl Password $(gpg -d /path/to/passwd.gpg) + login.password = sh "gpg -d /path/to/passwd.gpg" .Pp where .Em /path/to/passwd.gpg @@ -82,7 +90,7 @@ decrypt your password file before authenticating. This way, your password is not in plain text. More information on configuration options can be found in -.Xr matrix-send.conf 5 . +.Xr matrix-send-config 5 . .Pp To use .Nm , @@ -102,9 +110,13 @@ to the room with the Room ID !zyxwvutsrq:example.org. By default, .Nm caches access tokens in -.Em $HOME/.cache/matrix-send/access-token . -If you would like to disable caching of access tokens, add NoCache to your -.Em matrix-send.conf . +.Em $HOME/.cache/matrix-send/token . +If you would like to disable caching of access tokens, add +.Pp +.Dl cache.disable = true +.Pp +to your +.Em config.lua . .Pp Encryption is not supported. All messages will be sent unencrypted. There are currently no plans to add encryption to @@ -112,19 +124,19 @@ There are currently no plans to add encryption to .El .Sh FILES -.Bl -tag -width ~/.config/matrix-send.conf -.It Pa ~/.config/matrix-send.conf +.Bl -tag -width ~/.config/matrix-send/config.lua +.It Pa ~/.config/matrix-send/config.lua configuration file for .Nm -.It Pa ~/.cache/matrix-send/access-token -access token cache file +.It Pa ~/.cache/matrix-send +cache directory .El .Sh EXAMPLES -Send a message saying "How are you?" to the Matrix room !TfbDbeqp:example.org: +Send a message saying "Hello world!" to the Matrix room !TfbDbeqp:example.org: .Pp -.Dl matrix-send 'How are you?' !TfbDbeqp:example.org +.Dl matrix-send 'Hello world!' \\!TfbDbeqp:example.org .Pp .Sh SEE ALSO -.Xr matrix-send.conf 5 +.Xr matrix-send-config 5 diff --git a/matrix-send.conf b/matrix-send.conf deleted file mode 100644 index a7582ab..0000000 --- a/matrix-send.conf +++ /dev/null @@ -1,17 +0,0 @@ -## Example basic configuration for matrix-send -# A line with an option (e.g. 'Username jeremy') is a "directive". -# A line with only one word (e.g. 'NoCache') is a "statement". -# Comments start with a pound (#) -# Additional options can be found in matrix-send.conf(5) - -# The Server directive is for your server's Matrix Client-Server API URL. -# matrix-send assumes that this is valid. -# matrix.org's CS API URL is matrix-client.matrix.org. -# You can find it by typing it into Element's sign in page and hovering your mouse over it. -Server matrix.envs.net - -# The Username directive is your username for that server. -Username john - -# The Password directive is your password for your account. -Password supersecretpassword diff --git a/matrix-send.conf.5 b/matrix-send.conf.5 deleted file mode 100644 index 55a1c50..0000000 --- a/matrix-send.conf.5 +++ /dev/null @@ -1,60 +0,0 @@ -.Dd $Mdocdate: August 4 2022 $ -.Dt MATRIX-SEND.CONF 5 -.Os -.Sh NAME -.Nm matrix-send.conf -.Nd configuration file for -.Xr matrix-send 1 -.Sh DESCRIPTION -.Xr matrix-send 1 -sends messages to Matrix rooms. In order to send a message however, it needs -credentials for the account sending the message. These credentials are provided -in the -.Nm -configuration file, as well as other options if you need them. -.Pp -The following configuration options are available: -.Bl -tag -width 11n -.Bl -tag -width keepenv -.It Ic Server Ar server -The Client-Server API address of the Matrix server being used. -.It Ic Username Ar username -The username of the account being used. -.It Ic Password Ar password -The password for the account being used. -.It Ic AccessToken Ar token -Instead of authenticating via username and password to obtain an access token, use -.Ar token -as the access token. -.It Ic CacheLocation Ar location -Modify the cache location from the default (~/.cache) to -.Ar location . -.It Ic NoCache -Don't cache access tokens. -.It Ic DefaultEvent Ar type -Modify the default event type from the default (m.text) to -.Ar type . -Supported types are m.text, and m.notice. -.It Ic PrettyPrint -Pretty-print the JSON server messages. -.El -.Sh FILES -.Bl -tag -width ~/.config/matrix-send.conf -compact -.It Pa ~/.config/matrix-send.conf -.Xr matrix-send 1 -configuration file. -.It Pa ~/.cache -Default cache location. -.El -.Sh EXAMPLES -The following example logs into the user johndoe of the server with the -Client-Server API address of matrix-client.matrix.org with the password -supersecretpassword, and sets the default event type to m.notice. -.Bd -literal -offset indent -Server matrix-client.matrix.org -Username johndoe -Password supersecretpassword -DefaultEvent m.notice -.Ed -.Sh SEE ALSO -.Xr matrix-send 1 From 1b3bd8db45a1695e7ef9193d487b7db99cf0be5b Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sun, 1 Jan 2023 12:29:03 +1300 Subject: [PATCH 115/133] Update version no. and dependencies in Makefile --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cd74faf..88cb218 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 1.1 +VERSION = 2.0 PREFIX = /usr/local MANPREFIX = ${PREFIX}/man @@ -7,6 +7,10 @@ config: cp config.lua ~/.config/matrix-send/config.lua install: + # How I wish luarocks was better than this + luarocks install luaposix + luarocks install luasocket + luarocks install lua-cjson cp -f matrix-send ${DESTDIR}${PREFIX}/bin chmod +x ${DESTDIR}${PREFIX}/bin/matrix-send mkdir -p ${DESTDIR}${MANPREFIX}/man1 From d133316183ff925782805baba234e122bff6dbe5 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 1 Jan 2023 12:29:03 +1300 Subject: [PATCH 116/133] Update version no. and dependencies in Makefile --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cd74faf..88cb218 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 1.1 +VERSION = 2.0 PREFIX = /usr/local MANPREFIX = ${PREFIX}/man @@ -7,6 +7,10 @@ config: cp config.lua ~/.config/matrix-send/config.lua install: + # How I wish luarocks was better than this + luarocks install luaposix + luarocks install luasocket + luarocks install lua-cjson cp -f matrix-send ${DESTDIR}${PREFIX}/bin chmod +x ${DESTDIR}${PREFIX}/bin/matrix-send mkdir -p ${DESTDIR}${MANPREFIX}/man1 From 01cc0c4a359635965239c7881824744f59e5b9d7 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sun, 1 Jan 2023 12:29:50 +1300 Subject: [PATCH 117/133] Update README and fix manpage format problems --- README.md | 59 +++++++++++++++++++++++++++++++++++++++------------ matrix-send.1 | 24 +++------------------ 2 files changed, 48 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index a71f45c..fbe0354 100644 --- a/README.md +++ b/README.md @@ -18,29 +18,33 @@ There aren't any plans for matrix-send to support encryption. In order to start using matrix-send, you need a config file. To copy the default configuration to .config, clone this repository and type `make config` as the desired user (not root). -Now edit the file ~/.config/matrix-send.conf. You will see three (uncommented) lines. +Now edit the file ~/.config/matrix-send/config.lua. You will first see the `login` table. -``` -Server ... -Username ... -Password ... +```lua +-- This is a comment +login = { + server = "matrix-client.matrix.org" -- matrix.org + username = "user" + password = "password" +} ``` Delete the example values and enter in your credentials. -If you don't want to put your password in plain text, as matrix-send.conf is a shell script, you could do something like this: - -```shell -Password $(gpg -d /path/to/passwd.gpg) -``` - -/path/to/passwd.gpg is a GPG-encrypted file containing only your password, once decrypted. - -For more configuration options, see [matrix-send.conf(5)](https://jtbx.codeberg.page/man/matrix-send.conf.5). +For more configuration options, see [matrix-send-config(5)](https://jtbx.codeberg.page/man/matrix-send-config.5). --- +## Installation + +Before you install, you will need a few dependencies: + + * lua: >= 5.3 + * [luarocks](https://luarocks.org) + * plus some luarocks packages... + To install matrix-send, run `make install` as root, in the cloned repository's directory. +This will install all required packages, and copy matrix-send and its documentation to your system. In order to send messages, you will need the Room ID of your choice. Find the room you want to send to, and find its Room ID in the settings or somewhere else. It will likely be under Advanced or something similar. @@ -52,4 +56,31 @@ matrix-send 'Hi!' \!asdfasdfasdfasdf:matrix.org That will send the message "Hi!" to the Matrix room !asdfasdfasdfasdf:matrix.org. +If you don't want to type the long room ID every time, you can add an alias. + +Open your configuration file, and create a `rooms` table like so: + +```lua +rooms = { +} +``` + +Now, you can add aliases. Say you wanted to add an alias called `lounge` for a room with room ID `!AbCdEfGhIjKlMn:matrix.org`. +You would make it this way: + +```lua +rooms = { + lounge = "!AbCdEfGhIjKlMn:matrix.org" +} +``` + +Multiple aliases are separated by commas (as with any Lua table): + +```lua +rooms = { + lounge = "!AbCdEfGhIjKlMn:matrix.org", -- <-- notice the comma + bathroom = "!OpQrStUvWxYz:matrix.org" +} +``` + For more information, see [matrix-send(1)](https://jtbx.codeberg.page/man/matrix-send.1). diff --git a/matrix-send.1 b/matrix-send.1 index 9b57606..e4aebc8 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -71,24 +71,6 @@ Homeserver dialogue in the sign-in screen, then hovering over it once entered. Your server's Client-Server API URL should appear once you hover over it. If it doesn't appear, you should already have it. .Pp -You may have noticed that with this configuration, your password -is visible in plain sight. - -If you would like to have to encrypt your password before use, -you could -replace the -.Em login.password -line with something similar to this -.Pp - login.password = sh "gpg -d /path/to/passwd.gpg" -.Pp -where -.Em /path/to/passwd.gpg -is a GPG-encrypted plain text file containing only your password. -This line would mean that you would be asked for the passphrase required to -decrypt your password file before authenticating. This way, your password -is not in plain text. - More information on configuration options can be found in .Xr matrix-send-config 5 . .Pp @@ -99,9 +81,9 @@ This will be something like .Em !zyxwvutsrq:example.org . Type the Room ID as the argument after the message you wish to send. -You may have to escape the exclamation mark with a backslash. For example: +You may have to write the Room ID in quotes to avoid shell patterns. .Pp -.Dl matrix-send "Hello world!" \\!zyxwvutsrq:example.org +.Dl matrix-send 'Hello world!' '!zyxwvutsrq:example.org' .Pp That would send a message saying .Em Hello world! @@ -135,7 +117,7 @@ cache directory .Sh EXAMPLES Send a message saying "Hello world!" to the Matrix room !TfbDbeqp:example.org: .Pp -.Dl matrix-send 'Hello world!' \\!TfbDbeqp:example.org +.Dl matrix-send 'Hello world!' '!TfbDbeqp:example.org' .Pp .Sh SEE ALSO From a9c47a81b47c011c646e1c9316ab85a453c8548b Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 1 Jan 2023 12:29:50 +1300 Subject: [PATCH 118/133] Update README and fix manpage format problems --- README.md | 59 +++++++++++++++++++++++++++++++++++++++------------ matrix-send.1 | 24 +++------------------ 2 files changed, 48 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index a71f45c..fbe0354 100644 --- a/README.md +++ b/README.md @@ -18,29 +18,33 @@ There aren't any plans for matrix-send to support encryption. In order to start using matrix-send, you need a config file. To copy the default configuration to .config, clone this repository and type `make config` as the desired user (not root). -Now edit the file ~/.config/matrix-send.conf. You will see three (uncommented) lines. +Now edit the file ~/.config/matrix-send/config.lua. You will first see the `login` table. -``` -Server ... -Username ... -Password ... +```lua +-- This is a comment +login = { + server = "matrix-client.matrix.org" -- matrix.org + username = "user" + password = "password" +} ``` Delete the example values and enter in your credentials. -If you don't want to put your password in plain text, as matrix-send.conf is a shell script, you could do something like this: - -```shell -Password $(gpg -d /path/to/passwd.gpg) -``` - -/path/to/passwd.gpg is a GPG-encrypted file containing only your password, once decrypted. - -For more configuration options, see [matrix-send.conf(5)](https://jtbx.codeberg.page/man/matrix-send.conf.5). +For more configuration options, see [matrix-send-config(5)](https://jtbx.codeberg.page/man/matrix-send-config.5). --- +## Installation + +Before you install, you will need a few dependencies: + + * lua: >= 5.3 + * [luarocks](https://luarocks.org) + * plus some luarocks packages... + To install matrix-send, run `make install` as root, in the cloned repository's directory. +This will install all required packages, and copy matrix-send and its documentation to your system. In order to send messages, you will need the Room ID of your choice. Find the room you want to send to, and find its Room ID in the settings or somewhere else. It will likely be under Advanced or something similar. @@ -52,4 +56,31 @@ matrix-send 'Hi!' \!asdfasdfasdfasdf:matrix.org That will send the message "Hi!" to the Matrix room !asdfasdfasdfasdf:matrix.org. +If you don't want to type the long room ID every time, you can add an alias. + +Open your configuration file, and create a `rooms` table like so: + +```lua +rooms = { +} +``` + +Now, you can add aliases. Say you wanted to add an alias called `lounge` for a room with room ID `!AbCdEfGhIjKlMn:matrix.org`. +You would make it this way: + +```lua +rooms = { + lounge = "!AbCdEfGhIjKlMn:matrix.org" +} +``` + +Multiple aliases are separated by commas (as with any Lua table): + +```lua +rooms = { + lounge = "!AbCdEfGhIjKlMn:matrix.org", -- <-- notice the comma + bathroom = "!OpQrStUvWxYz:matrix.org" +} +``` + For more information, see [matrix-send(1)](https://jtbx.codeberg.page/man/matrix-send.1). diff --git a/matrix-send.1 b/matrix-send.1 index 9b57606..e4aebc8 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -71,24 +71,6 @@ Homeserver dialogue in the sign-in screen, then hovering over it once entered. Your server's Client-Server API URL should appear once you hover over it. If it doesn't appear, you should already have it. .Pp -You may have noticed that with this configuration, your password -is visible in plain sight. - -If you would like to have to encrypt your password before use, -you could -replace the -.Em login.password -line with something similar to this -.Pp - login.password = sh "gpg -d /path/to/passwd.gpg" -.Pp -where -.Em /path/to/passwd.gpg -is a GPG-encrypted plain text file containing only your password. -This line would mean that you would be asked for the passphrase required to -decrypt your password file before authenticating. This way, your password -is not in plain text. - More information on configuration options can be found in .Xr matrix-send-config 5 . .Pp @@ -99,9 +81,9 @@ This will be something like .Em !zyxwvutsrq:example.org . Type the Room ID as the argument after the message you wish to send. -You may have to escape the exclamation mark with a backslash. For example: +You may have to write the Room ID in quotes to avoid shell patterns. .Pp -.Dl matrix-send "Hello world!" \\!zyxwvutsrq:example.org +.Dl matrix-send 'Hello world!' '!zyxwvutsrq:example.org' .Pp That would send a message saying .Em Hello world! @@ -135,7 +117,7 @@ cache directory .Sh EXAMPLES Send a message saying "Hello world!" to the Matrix room !TfbDbeqp:example.org: .Pp -.Dl matrix-send 'Hello world!' \\!TfbDbeqp:example.org +.Dl matrix-send 'Hello world!' '!TfbDbeqp:example.org' .Pp .Sh SEE ALSO From 496fe6ba3bf3c3d3bfd4663248163714bafaa2a5 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sat, 31 Dec 2022 23:30:51 +0000 Subject: [PATCH 119/133] Oops --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fbe0354..79097c6 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ Now edit the file ~/.config/matrix-send/config.lua. You will first see the `logi ```lua -- This is a comment login = { - server = "matrix-client.matrix.org" -- matrix.org - username = "user" + server = "matrix-client.matrix.org", -- matrix.org + username = "user", password = "password" } ``` From bc1272a3e4fe5b8cb65774a75128be6d5b5451dd Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sat, 31 Dec 2022 23:30:51 +0000 Subject: [PATCH 120/133] Oops --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fbe0354..79097c6 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ Now edit the file ~/.config/matrix-send/config.lua. You will first see the `logi ```lua -- This is a comment login = { - server = "matrix-client.matrix.org" -- matrix.org - username = "user" + server = "matrix-client.matrix.org", -- matrix.org + username = "user", password = "password" } ``` From 7890ded40cd35db4b2424cc032ad218b7120d6fc Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sun, 1 Jan 2023 02:44:27 +0000 Subject: [PATCH 121/133] Update 'README.md' --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 79097c6..7fbe876 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,10 @@ A script that sends messages to Matrix rooms. --- -matrix-send is a simple script that sends a message to a Matrix room. +matrix-send is a simple script that sends messages to Matrix rooms. -It does this by sending a JSON message to your Matrix server. The message types that are supported are `m.text`, and `m.notice`. +It does this by directly making requests to the API of your Matrix server. +The supported event types are `m.text` and `m.notice`. It is mainly designed for automation. @@ -16,7 +17,7 @@ There aren't any plans for matrix-send to support encryption. ## Get started -In order to start using matrix-send, you need a config file. To copy the default configuration to .config, clone this repository and type `make config` as the desired user (not root). +In order to start using matrix-send, you need a config file. To copy the default configuration to .config, clone this repository and type `make config` as your user (not root). Now edit the file ~/.config/matrix-send/config.lua. You will first see the `login` table. @@ -54,7 +55,7 @@ To send a message, type `matrix-send` followed by your message and then your Roo matrix-send 'Hi!' \!asdfasdfasdfasdf:matrix.org ``` -That will send the message "Hi!" to the Matrix room !asdfasdfasdfasdf:matrix.org. +That will send the message "Hi!" to the Matrix room `!asdfasdfasdfasdf:matrix.org.` If you don't want to type the long room ID every time, you can add an alias. @@ -83,4 +84,4 @@ rooms = { } ``` -For more information, see [matrix-send(1)](https://jtbx.codeberg.page/man/matrix-send.1). +For more information, see [matrix-send(1)](https://jtbx.codeberg.page/man/matrix-send.1) and [matrix-send-config(5)](https://jtbx.codeberg.page/man/matrix-send-config.5). From 83dcd81e950983cb40feff5ee77135e0fc0ffa34 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sun, 1 Jan 2023 13:08:08 +1300 Subject: [PATCH 122/133] another oopsy --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 88cb218..d8e1712 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ config: cp config.lua ~/.config/matrix-send/config.lua install: - # How I wish luarocks was better than this + @# How I wish luarocks was better than this luarocks install luaposix luarocks install luasocket luarocks install lua-cjson From 91e9801c0fc818bdfd51ee4b0e3f3851a426b84f Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 1 Jan 2023 02:44:27 +0000 Subject: [PATCH 123/133] Update 'README.md' --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 79097c6..7fbe876 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,10 @@ A script that sends messages to Matrix rooms. --- -matrix-send is a simple script that sends a message to a Matrix room. +matrix-send is a simple script that sends messages to Matrix rooms. -It does this by sending a JSON message to your Matrix server. The message types that are supported are `m.text`, and `m.notice`. +It does this by directly making requests to the API of your Matrix server. +The supported event types are `m.text` and `m.notice`. It is mainly designed for automation. @@ -16,7 +17,7 @@ There aren't any plans for matrix-send to support encryption. ## Get started -In order to start using matrix-send, you need a config file. To copy the default configuration to .config, clone this repository and type `make config` as the desired user (not root). +In order to start using matrix-send, you need a config file. To copy the default configuration to .config, clone this repository and type `make config` as your user (not root). Now edit the file ~/.config/matrix-send/config.lua. You will first see the `login` table. @@ -54,7 +55,7 @@ To send a message, type `matrix-send` followed by your message and then your Roo matrix-send 'Hi!' \!asdfasdfasdfasdf:matrix.org ``` -That will send the message "Hi!" to the Matrix room !asdfasdfasdfasdf:matrix.org. +That will send the message "Hi!" to the Matrix room `!asdfasdfasdfasdf:matrix.org.` If you don't want to type the long room ID every time, you can add an alias. @@ -83,4 +84,4 @@ rooms = { } ``` -For more information, see [matrix-send(1)](https://jtbx.codeberg.page/man/matrix-send.1). +For more information, see [matrix-send(1)](https://jtbx.codeberg.page/man/matrix-send.1) and [matrix-send-config(5)](https://jtbx.codeberg.page/man/matrix-send-config.5). From 62a21ca3c8a816daf67a145b53ccb6121a5de5fc Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sun, 1 Jan 2023 17:41:17 +1300 Subject: [PATCH 124/133] Implement server discovery (.well-known/matrix/client), and re-authenticate if access token expired or was invalidated somehow --- matrix-send | 181 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 104 insertions(+), 77 deletions(-) diff --git a/matrix-send b/matrix-send index f042356..ab3cc7d 100755 --- a/matrix-send +++ b/matrix-send @@ -19,11 +19,11 @@ require "luarocks.loader" getopt = require "posix.unistd".getopt -mkdir = require "posix.sys.stat".mkdir -bname = require "posix.libgen".basename -http = require "socket.http" -cjson = require "cjson" -ltn12 = require "ltn12" + mkdir = require "posix.sys.stat".mkdir + bname = require "posix.libgen".basename + http = require "socket.http" + cjson = require "cjson" + ltn12 = require "ltn12" version = "2.0" confdir = string.gsub("~/.config/matrix-send", '~', os.getenv("HOME"), 1) @@ -31,9 +31,10 @@ confpath = confdir .. "/config.lua" confvarv = os.getenv("MATRIXSEND_CONFIG") hostname = io.input("/etc/hostname"):read("l") -json = {} - uri = {} - sh = os.execute +matrix = {} + json = {} + uri = {} + sh = os.execute ----------------- --- Functions --- @@ -50,38 +51,6 @@ function fileexists(file) end end --- Makes an HTTP POST request to uri and sends body. Returns the output of the HTTP server. -function post(uri, body) - local respbody = {} -- for the response body - local result, respcode, respheaders, respstatus = http.request { - method = "POST", - url = uri, - source = ltn12.source.string(body), - headers = { - ["content-type"] = "application/json", - ["content-length"] = tostring(#body) - }, - sink = ltn12.sink.table(respbody) - } - return table.concat(respbody) -end - --- Makes an HTTP PUT request to uri and sends body. Returns the output of the HTTP server. -function put(uri, body) - local respbody = {} -- for the response body - local result, respcode, respheaders, respstatus = http.request { - method = "PUT", - url = uri, - source = ltn12.source.string(body), - headers = { - ["content-type"] = "application/json", - ["content-length"] = tostring(#body) - }, - sink = ltn12.sink.table(respbody) - } - return table.concat(respbody) -end - -- Prints a message to stdout in the following format: -- matrix-send: s function msg(s) @@ -104,20 +73,87 @@ function confpanic(s) os.exit(1) end +------------------------ +--- Matrix functions --- +------------------------ + +function matrix.login(uri, json) + local respbody = {} + local result, respcode, respheaders, respstatus = http.request { + method = "POST", + url = uri, + source = ltn12.source.string(json), + headers = { + ["content-type"] = "application/json", + ["content-length"] = tostring(#json) + }, + sink = ltn12.sink.table(respbody) + } + local body = table.concat(respbody) + local t = cjson.decode(body) + if t.error then + panic("server: " .. t.error) + else + return t.access_token + end +end + +function matrix.send(uri, json, login_uri, login_json) + local respbody = {} + local result, respcode, respheaders, respstatus = http.request { + method = "PUT", + url = uri, + source = ltn12.source.string(json), + headers = { + ["content-type"] = "application/json", + ["content-length"] = tostring(#json) + }, + sink = ltn12.sink.table(respbody) + } + local body = table.concat(respbody) + local t = cjson.decode(body) + if t.error then + if t.errcode == "M_UNKNOWN_TOKEN" then + msg("token expired/invalidated; re-authenticating") + -- I mean, it works + t = setmetatable({}, { + __concat = function(left, right) + if type(left) == "string" then + return left .. tostring(right) + end + return tostring(left) .. tostring(right) + end + }) + t.token = matrix.login(login_uri, login_json) + if not cache.disable then + mkdir(cache.location) + cf = io.open(cache.location .. "/token", 'w+') + cf:write(t.token) + cf:close() + end + matrix.send(string.gsub(uri, "access_token=.+", "access_token=" .. t.token), json, login_uri, login_json) + else + panic("server: " .. t.error) + end + else + return t + end +end + -- Default configuration file default_config = [[ -- Default configuration file for matrix-send -- In comments, here is a simple example configuration. --login = { --- server = "matrix.envs.net", +-- server = "envs.net", -- username = "john", -- password = "examplepassword --} -- You could also do it this way: ---login.server = "matrix.envs.net" +--login.server = "envs.net" --login.username = "john" --login.password = "examplepassword" @@ -242,9 +278,29 @@ else txnid = 0 end -uri.login = string.format("https://%s/_matrix/client/v3/login", login.server) +-- Get .well-known +uri.well_known = string.format("https://%s/.well-known/matrix/client", login.server) +wellknown_body, errno = http.request(uri.well_known) +if errno ~= 200 then + panic("server: Error " .. errno .. " while getting /.well-known/matrix/client") +end +wellknown_t = cjson.decode(wellknown_body) +login.server = wellknown_t["m.homeserver"].base_url + +-- Assign URIs and JSON bodies +uri.login = string.format("%s/_matrix/client/v3/login", login.server) +json.login = string.format([[ +{ + "identifier": { + "type": "m.id.user", + "user": "%s" + }, + "initial_device_display_name": "matrix-send@%s", + "password": "%s", + "type": "m.login.password" +} +]], login.username, hostname, login.password) --- Assemble various JSON messages json.message = string.format([[ { "body": "%s", @@ -259,33 +315,8 @@ if not login.token then login.token = cf:read('l') cf:close() else - -- json.login should only be assigned if it needs to be assigned - json.login = string.format([[ - { - "identifier": { - "type": "m.id.user", - "user": "%s" - }, - "initial_device_display_name": "matrix-send@%s", - "password": "%s", - "type": "m.login.password" - } - - ]], login.username, hostname, login.password) - - -- Send the request! - local body = post(uri.login, json.login) - - -- What else do I call it? - local t = cjson.decode(body) - - -- If there was a server side error, print the error and exit. - if t.error then - panic(login.server .. ": " .. t.error) - end - - -- Log the access token - login.token = t.access_token + -- Login + login.token = matrix.login(uri.login, json.login) -- Cache the access token if not cache.disable then @@ -297,15 +328,11 @@ if not login.token then end end -uri.message = string.format("https://%s/_matrix/client/v3/rooms/%s/send/m.room.message/%d?access_token=%s", +uri.message = string.format("%s/_matrix/client/v3/rooms/%s/send/m.room.message/%d?access_token=%s", login.server, room_id, txnid, login.token) -- Send the message! -body = put(uri.message, json.message) -t = cjson.decode(body) -if t.error then - panic(login.server .. ": " .. t.error) -end +matrix.send(uri.message, json.message, uri.login, json.login) -- Increment txnid and cache if not cache.disable then From 2d8788afd9372402bbf1955f54233ce2b216863d Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 1 Jan 2023 13:08:08 +1300 Subject: [PATCH 125/133] another oopsy --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 88cb218..d8e1712 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ config: cp config.lua ~/.config/matrix-send/config.lua install: - # How I wish luarocks was better than this + @# How I wish luarocks was better than this luarocks install luaposix luarocks install luasocket luarocks install lua-cjson From 932ee958c084df419b1b934df3245b7202165756 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 1 Jan 2023 17:41:17 +1300 Subject: [PATCH 126/133] Implement server discovery (.well-known/matrix/client), and re-authenticate if access token expired or was invalidated somehow --- matrix-send | 181 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 104 insertions(+), 77 deletions(-) diff --git a/matrix-send b/matrix-send index f042356..ab3cc7d 100755 --- a/matrix-send +++ b/matrix-send @@ -19,11 +19,11 @@ require "luarocks.loader" getopt = require "posix.unistd".getopt -mkdir = require "posix.sys.stat".mkdir -bname = require "posix.libgen".basename -http = require "socket.http" -cjson = require "cjson" -ltn12 = require "ltn12" + mkdir = require "posix.sys.stat".mkdir + bname = require "posix.libgen".basename + http = require "socket.http" + cjson = require "cjson" + ltn12 = require "ltn12" version = "2.0" confdir = string.gsub("~/.config/matrix-send", '~', os.getenv("HOME"), 1) @@ -31,9 +31,10 @@ confpath = confdir .. "/config.lua" confvarv = os.getenv("MATRIXSEND_CONFIG") hostname = io.input("/etc/hostname"):read("l") -json = {} - uri = {} - sh = os.execute +matrix = {} + json = {} + uri = {} + sh = os.execute ----------------- --- Functions --- @@ -50,38 +51,6 @@ function fileexists(file) end end --- Makes an HTTP POST request to uri and sends body. Returns the output of the HTTP server. -function post(uri, body) - local respbody = {} -- for the response body - local result, respcode, respheaders, respstatus = http.request { - method = "POST", - url = uri, - source = ltn12.source.string(body), - headers = { - ["content-type"] = "application/json", - ["content-length"] = tostring(#body) - }, - sink = ltn12.sink.table(respbody) - } - return table.concat(respbody) -end - --- Makes an HTTP PUT request to uri and sends body. Returns the output of the HTTP server. -function put(uri, body) - local respbody = {} -- for the response body - local result, respcode, respheaders, respstatus = http.request { - method = "PUT", - url = uri, - source = ltn12.source.string(body), - headers = { - ["content-type"] = "application/json", - ["content-length"] = tostring(#body) - }, - sink = ltn12.sink.table(respbody) - } - return table.concat(respbody) -end - -- Prints a message to stdout in the following format: -- matrix-send: s function msg(s) @@ -104,20 +73,87 @@ function confpanic(s) os.exit(1) end +------------------------ +--- Matrix functions --- +------------------------ + +function matrix.login(uri, json) + local respbody = {} + local result, respcode, respheaders, respstatus = http.request { + method = "POST", + url = uri, + source = ltn12.source.string(json), + headers = { + ["content-type"] = "application/json", + ["content-length"] = tostring(#json) + }, + sink = ltn12.sink.table(respbody) + } + local body = table.concat(respbody) + local t = cjson.decode(body) + if t.error then + panic("server: " .. t.error) + else + return t.access_token + end +end + +function matrix.send(uri, json, login_uri, login_json) + local respbody = {} + local result, respcode, respheaders, respstatus = http.request { + method = "PUT", + url = uri, + source = ltn12.source.string(json), + headers = { + ["content-type"] = "application/json", + ["content-length"] = tostring(#json) + }, + sink = ltn12.sink.table(respbody) + } + local body = table.concat(respbody) + local t = cjson.decode(body) + if t.error then + if t.errcode == "M_UNKNOWN_TOKEN" then + msg("token expired/invalidated; re-authenticating") + -- I mean, it works + t = setmetatable({}, { + __concat = function(left, right) + if type(left) == "string" then + return left .. tostring(right) + end + return tostring(left) .. tostring(right) + end + }) + t.token = matrix.login(login_uri, login_json) + if not cache.disable then + mkdir(cache.location) + cf = io.open(cache.location .. "/token", 'w+') + cf:write(t.token) + cf:close() + end + matrix.send(string.gsub(uri, "access_token=.+", "access_token=" .. t.token), json, login_uri, login_json) + else + panic("server: " .. t.error) + end + else + return t + end +end + -- Default configuration file default_config = [[ -- Default configuration file for matrix-send -- In comments, here is a simple example configuration. --login = { --- server = "matrix.envs.net", +-- server = "envs.net", -- username = "john", -- password = "examplepassword --} -- You could also do it this way: ---login.server = "matrix.envs.net" +--login.server = "envs.net" --login.username = "john" --login.password = "examplepassword" @@ -242,9 +278,29 @@ else txnid = 0 end -uri.login = string.format("https://%s/_matrix/client/v3/login", login.server) +-- Get .well-known +uri.well_known = string.format("https://%s/.well-known/matrix/client", login.server) +wellknown_body, errno = http.request(uri.well_known) +if errno ~= 200 then + panic("server: Error " .. errno .. " while getting /.well-known/matrix/client") +end +wellknown_t = cjson.decode(wellknown_body) +login.server = wellknown_t["m.homeserver"].base_url + +-- Assign URIs and JSON bodies +uri.login = string.format("%s/_matrix/client/v3/login", login.server) +json.login = string.format([[ +{ + "identifier": { + "type": "m.id.user", + "user": "%s" + }, + "initial_device_display_name": "matrix-send@%s", + "password": "%s", + "type": "m.login.password" +} +]], login.username, hostname, login.password) --- Assemble various JSON messages json.message = string.format([[ { "body": "%s", @@ -259,33 +315,8 @@ if not login.token then login.token = cf:read('l') cf:close() else - -- json.login should only be assigned if it needs to be assigned - json.login = string.format([[ - { - "identifier": { - "type": "m.id.user", - "user": "%s" - }, - "initial_device_display_name": "matrix-send@%s", - "password": "%s", - "type": "m.login.password" - } - - ]], login.username, hostname, login.password) - - -- Send the request! - local body = post(uri.login, json.login) - - -- What else do I call it? - local t = cjson.decode(body) - - -- If there was a server side error, print the error and exit. - if t.error then - panic(login.server .. ": " .. t.error) - end - - -- Log the access token - login.token = t.access_token + -- Login + login.token = matrix.login(uri.login, json.login) -- Cache the access token if not cache.disable then @@ -297,15 +328,11 @@ if not login.token then end end -uri.message = string.format("https://%s/_matrix/client/v3/rooms/%s/send/m.room.message/%d?access_token=%s", +uri.message = string.format("%s/_matrix/client/v3/rooms/%s/send/m.room.message/%d?access_token=%s", login.server, room_id, txnid, login.token) -- Send the message! -body = put(uri.message, json.message) -t = cjson.decode(body) -if t.error then - panic(login.server .. ": " .. t.error) -end +matrix.send(uri.message, json.message, uri.login, json.login) -- Increment txnid and cache if not cache.disable then From 8c4b17b9a2063acf13eb4337570418815cc84edb Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Mon, 9 Jan 2023 12:36:48 +1300 Subject: [PATCH 127/133] Precompile Lua into bytecode before running it (see COMPILE) --- .gitignore | 2 +- COMPILE | 35 ++++++++++++++++++++++++++++++++++ Makefile | 4 +++- matrix-send => matrix-send.lua | 0 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 COMPILE rename matrix-send => matrix-send.lua (100%) diff --git a/.gitignore b/.gitignore index 6fd0a37..74ae39b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Compiled Lua sources luac.out +matrix-send # luarocks build files *.src.rock @@ -38,4 +39,3 @@ luac.out *.i*86 *.x86_64 *.hex - diff --git a/COMPILE b/COMPILE new file mode 100644 index 0000000..5caca11 --- /dev/null +++ b/COMPILE @@ -0,0 +1,35 @@ + ___________________ + < Manually building > + ------------------- + +Since matrix-send uses Lua, an interpreted programming language, +building is not necessary; you could just move matrix-send.lua to +/usr/local/bin and be done with it. However, for additional speed, +the Makefile precompiles it to Lua bytecode using +luac which is included +in the Lua distribution. To do this yourself, follow these steps: + + => Create the shebang + +In order to be run by a shell, the compiled bytecode needs a +shebang at the start. To do this, run this command: + + printf '#!/usr/bin/env lua\n' > matrix-send + + + => Precompile + +Now, let's append the bytecode to the file: + + luac -o - matrix-send.lua >> matrix-send + + + => Mark as an executable + +Finally, mark the file as executable: + + chmod +x matrix-send + +The file `matrix-send` is now ready to be run by a shell. + +# vi: ft=txt diff --git a/Makefile b/Makefile index d8e1712..0b18e1e 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,10 @@ install: luarocks install luaposix luarocks install luasocket luarocks install lua-cjson + printf '#!/usr/bin/env lua\n' > matrix-send + luac -o - matrix-send.lua >> matrix-send + chmod +x matrix-send cp -f matrix-send ${DESTDIR}${PREFIX}/bin - chmod +x ${DESTDIR}${PREFIX}/bin/matrix-send mkdir -p ${DESTDIR}${MANPREFIX}/man1 cp -f matrix-send.1 ${DESTDIR}${MANPREFIX}/man1 mkdir -p ${DESTDIR}${MANPREFIX}/man5 diff --git a/matrix-send b/matrix-send.lua similarity index 100% rename from matrix-send rename to matrix-send.lua From a6ee41a6ab51296a6f766688d44d250deb074488 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 9 Jan 2023 12:36:48 +1300 Subject: [PATCH 128/133] Precompile Lua into bytecode before running it (see COMPILE) --- .gitignore | 2 +- COMPILE | 35 ++++++++++++++++++++++++++++++++++ Makefile | 4 +++- matrix-send => matrix-send.lua | 0 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 COMPILE rename matrix-send => matrix-send.lua (100%) diff --git a/.gitignore b/.gitignore index 6fd0a37..74ae39b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Compiled Lua sources luac.out +matrix-send # luarocks build files *.src.rock @@ -38,4 +39,3 @@ luac.out *.i*86 *.x86_64 *.hex - diff --git a/COMPILE b/COMPILE new file mode 100644 index 0000000..5caca11 --- /dev/null +++ b/COMPILE @@ -0,0 +1,35 @@ + ___________________ + < Manually building > + ------------------- + +Since matrix-send uses Lua, an interpreted programming language, +building is not necessary; you could just move matrix-send.lua to +/usr/local/bin and be done with it. However, for additional speed, +the Makefile precompiles it to Lua bytecode using +luac which is included +in the Lua distribution. To do this yourself, follow these steps: + + => Create the shebang + +In order to be run by a shell, the compiled bytecode needs a +shebang at the start. To do this, run this command: + + printf '#!/usr/bin/env lua\n' > matrix-send + + + => Precompile + +Now, let's append the bytecode to the file: + + luac -o - matrix-send.lua >> matrix-send + + + => Mark as an executable + +Finally, mark the file as executable: + + chmod +x matrix-send + +The file `matrix-send` is now ready to be run by a shell. + +# vi: ft=txt diff --git a/Makefile b/Makefile index d8e1712..0b18e1e 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,10 @@ install: luarocks install luaposix luarocks install luasocket luarocks install lua-cjson + printf '#!/usr/bin/env lua\n' > matrix-send + luac -o - matrix-send.lua >> matrix-send + chmod +x matrix-send cp -f matrix-send ${DESTDIR}${PREFIX}/bin - chmod +x ${DESTDIR}${PREFIX}/bin/matrix-send mkdir -p ${DESTDIR}${MANPREFIX}/man1 cp -f matrix-send.1 ${DESTDIR}${MANPREFIX}/man1 mkdir -p ${DESTDIR}${MANPREFIX}/man5 diff --git a/matrix-send b/matrix-send.lua similarity index 100% rename from matrix-send rename to matrix-send.lua From f006c27174a25007a0bb765e40c4ea3ace4e6636 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Mon, 9 Jan 2023 12:48:51 +1300 Subject: [PATCH 129/133] Remove need for Client-Server API addresses in docs --- README.md | 2 +- config.lua | 2 +- matrix-send-config.5 | 6 +++--- matrix-send.1 | 11 ++--------- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 7fbe876..27fdd89 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Now edit the file ~/.config/matrix-send/config.lua. You will first see the `logi ```lua -- This is a comment login = { - server = "matrix-client.matrix.org", -- matrix.org + server = "matrix.org", username = "user", password = "password" } diff --git a/config.lua b/config.lua index f271a49..87ce0c4 100644 --- a/config.lua +++ b/config.lua @@ -1,6 +1,6 @@ login = { -- The Matrix server to use. - server = "matrix-client.matrix.org", -- matrix.org + server = "matrix.org", -- The user to log in to. username = "user", diff --git a/matrix-send-config.5 b/matrix-send-config.5 index b2c468c..717a286 100644 --- a/matrix-send-config.5 +++ b/matrix-send-config.5 @@ -20,7 +20,7 @@ The following configuration options are available: .Bl -tag -width 11n .Bl -tag -width login.server .It Ic login.server Ar server -The Client-Server API address of the Matrix server being used. +The address of the Matrix server being used. .It Ic login.username Ar username The username of the account being used. .It Ic login.password Ar password @@ -50,11 +50,11 @@ default cache directory .El .Sh EXAMPLES The following example logs into the user 'john' of the server -matrix-client.matrix.org, and the password 'supersecretpassword', +matrix.org, and the password 'supersecretpassword', and sets the default event type to m.notice. .Bd -literal -offset indent login = { - server = "matrix-client.matrix.org", + server = "matrix.org", username = "john", password = "supersecretpassword" } diff --git a/matrix-send.1 b/matrix-send.1 index e4aebc8..3a4f4a0 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -51,7 +51,7 @@ Let's say your Matrix server is envs.net, your username is john, and your passwo is supersecretpassword. Your configuration could look like this: .Bd -literal -offset indent login = { - server = "matrix.envs.net", + server = "envs.net", username = "john", password = "supersecretpassword" } @@ -59,18 +59,11 @@ login = { .Pp It could also look like this: .Bd -literal -offset indent -login.server = "matrix.envs.net" +login.server = "envs.net" login.username = "john" login.password = "supersecretpassword" .Ed .Pp -In those examples, we used matrix.envs.net instead of envs.net. This is because -matrix.envs.net is the address in which the Client-Server API is listening on. -You can find this address in Element by entering in your server into the -Homeserver dialogue in the sign-in screen, then hovering -over it once entered. Your server's Client-Server API URL should appear once -you hover over it. If it doesn't appear, you should already have it. -.Pp More information on configuration options can be found in .Xr matrix-send-config 5 . .Pp From 59b9ba67b7b3ed8e31d23ee30ef3d942189ca6d9 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 9 Jan 2023 12:48:51 +1300 Subject: [PATCH 130/133] Remove need for Client-Server API addresses in docs --- README.md | 2 +- config.lua | 2 +- matrix-send-config.5 | 6 +++--- matrix-send.1 | 11 ++--------- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 7fbe876..27fdd89 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Now edit the file ~/.config/matrix-send/config.lua. You will first see the `logi ```lua -- This is a comment login = { - server = "matrix-client.matrix.org", -- matrix.org + server = "matrix.org", username = "user", password = "password" } diff --git a/config.lua b/config.lua index f271a49..87ce0c4 100644 --- a/config.lua +++ b/config.lua @@ -1,6 +1,6 @@ login = { -- The Matrix server to use. - server = "matrix-client.matrix.org", -- matrix.org + server = "matrix.org", -- The user to log in to. username = "user", diff --git a/matrix-send-config.5 b/matrix-send-config.5 index b2c468c..717a286 100644 --- a/matrix-send-config.5 +++ b/matrix-send-config.5 @@ -20,7 +20,7 @@ The following configuration options are available: .Bl -tag -width 11n .Bl -tag -width login.server .It Ic login.server Ar server -The Client-Server API address of the Matrix server being used. +The address of the Matrix server being used. .It Ic login.username Ar username The username of the account being used. .It Ic login.password Ar password @@ -50,11 +50,11 @@ default cache directory .El .Sh EXAMPLES The following example logs into the user 'john' of the server -matrix-client.matrix.org, and the password 'supersecretpassword', +matrix.org, and the password 'supersecretpassword', and sets the default event type to m.notice. .Bd -literal -offset indent login = { - server = "matrix-client.matrix.org", + server = "matrix.org", username = "john", password = "supersecretpassword" } diff --git a/matrix-send.1 b/matrix-send.1 index e4aebc8..3a4f4a0 100644 --- a/matrix-send.1 +++ b/matrix-send.1 @@ -51,7 +51,7 @@ Let's say your Matrix server is envs.net, your username is john, and your passwo is supersecretpassword. Your configuration could look like this: .Bd -literal -offset indent login = { - server = "matrix.envs.net", + server = "envs.net", username = "john", password = "supersecretpassword" } @@ -59,18 +59,11 @@ login = { .Pp It could also look like this: .Bd -literal -offset indent -login.server = "matrix.envs.net" +login.server = "envs.net" login.username = "john" login.password = "supersecretpassword" .Ed .Pp -In those examples, we used matrix.envs.net instead of envs.net. This is because -matrix.envs.net is the address in which the Client-Server API is listening on. -You can find this address in Element by entering in your server into the -Homeserver dialogue in the sign-in screen, then hovering -over it once entered. Your server's Client-Server API URL should appear once -you hover over it. If it doesn't appear, you should already have it. -.Pp More information on configuration options can be found in .Xr matrix-send-config 5 . .Pp From 28c1bbafb0882674fae44b57b241bbc23667e11e Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Mon, 9 Jan 2023 12:58:47 +1300 Subject: [PATCH 131/133] Version 2.0 -> 2.1 --- Makefile | 2 +- matrix-send.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0b18e1e..a230233 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 2.0 +VERSION = 2.1 PREFIX = /usr/local MANPREFIX = ${PREFIX}/man diff --git a/matrix-send.lua b/matrix-send.lua index ab3cc7d..feee075 100755 --- a/matrix-send.lua +++ b/matrix-send.lua @@ -25,7 +25,7 @@ getopt = require "posix.unistd".getopt cjson = require "cjson" ltn12 = require "ltn12" - version = "2.0" + version = "2.1" confdir = string.gsub("~/.config/matrix-send", '~', os.getenv("HOME"), 1) confpath = confdir .. "/config.lua" confvarv = os.getenv("MATRIXSEND_CONFIG") From 3ed1af15d039b1226f656175a5283b01a212ba27 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 9 Jan 2023 12:58:47 +1300 Subject: [PATCH 132/133] Version 2.0 -> 2.1 --- Makefile | 2 +- matrix-send.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0b18e1e..a230233 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 2.0 +VERSION = 2.1 PREFIX = /usr/local MANPREFIX = ${PREFIX}/man diff --git a/matrix-send.lua b/matrix-send.lua index ab3cc7d..feee075 100755 --- a/matrix-send.lua +++ b/matrix-send.lua @@ -25,7 +25,7 @@ getopt = require "posix.unistd".getopt cjson = require "cjson" ltn12 = require "ltn12" - version = "2.0" + version = "2.1" confdir = string.gsub("~/.config/matrix-send", '~', os.getenv("HOME"), 1) confpath = confdir .. "/config.lua" confvarv = os.getenv("MATRIXSEND_CONFIG") From cfef82dc2fcb3673cd63d62df082183dc1687fa1 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 19 Aug 2025 12:31:45 +1200 Subject: [PATCH 133/133] fix weird equals alignment --- matrix-send.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/matrix-send.lua b/matrix-send.lua index feee075..c59d447 100755 --- a/matrix-send.lua +++ b/matrix-send.lua @@ -19,22 +19,22 @@ require "luarocks.loader" getopt = require "posix.unistd".getopt - mkdir = require "posix.sys.stat".mkdir - bname = require "posix.libgen".basename - http = require "socket.http" - cjson = require "cjson" - ltn12 = require "ltn12" +mkdir = require "posix.sys.stat".mkdir +bname = require "posix.libgen".basename +http = require "socket.http" +cjson = require "cjson" +ltn12 = require "ltn12" - version = "2.1" - confdir = string.gsub("~/.config/matrix-send", '~', os.getenv("HOME"), 1) +version = "2.1" +confdir = string.gsub("~/.config/matrix-send", '~', os.getenv("HOME"), 1) confpath = confdir .. "/config.lua" confvarv = os.getenv("MATRIXSEND_CONFIG") hostname = io.input("/etc/hostname"):read("l") matrix = {} - json = {} - uri = {} - sh = os.execute +json = {} +uri = {} +sh = os.execute ----------------- --- Functions ---