Base Commit + License
This commit is contained in:
commit
e5378fe160
202
LICENSE
Normal file
202
LICENSE
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
11
README.md
Normal file
11
README.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Crosspost
|
||||||
|
|
||||||
|
An image crossposting tool that supports...
|
||||||
|
|
||||||
|
* An SFTP Dir + Gemini Blog
|
||||||
|
* Instagram
|
||||||
|
* Pixelfed / Mastodon
|
||||||
|
* Cohost
|
||||||
|
* Discord
|
||||||
|
* *Unsplash* (WIP)
|
||||||
|
* *Tumblr* (WIP)
|
830
flow.json
Normal file
830
flow.json
Normal file
@ -0,0 +1,830 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "503ae6a51f28e7b1",
|
||||||
|
"type": "tab",
|
||||||
|
"label": "Crossposter",
|
||||||
|
"disabled": false,
|
||||||
|
"info": "",
|
||||||
|
"env": [
|
||||||
|
{
|
||||||
|
"name": "IG_USERNAME",
|
||||||
|
"value": "sciencegirl100",
|
||||||
|
"type": "str"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "IG_PASSWORD",
|
||||||
|
"value": "REDACTED",
|
||||||
|
"type": "str"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "dbbaebd1d08b6537",
|
||||||
|
"type": "junction",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"x": 560,
|
||||||
|
"y": 540,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"1a034ddb27d958b5"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "357518949dc85909",
|
||||||
|
"type": "junction",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"x": 240,
|
||||||
|
"y": 620,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"27049be02da427ed",
|
||||||
|
"f210817c6ad103fd",
|
||||||
|
"f79dc0217d77183f"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "adf4bd06e9a983c8",
|
||||||
|
"type": "junction",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"x": 240,
|
||||||
|
"y": 380,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"76555f3a45184d26",
|
||||||
|
"3976c42cbd4334ce"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "3fbfea693a42d5c4",
|
||||||
|
"type": "junction",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"x": 640,
|
||||||
|
"y": 180,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"82e5483fa9d750fd",
|
||||||
|
"251a52bf8516a9fb"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "7a5c537d1408488e",
|
||||||
|
"type": "junction",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"x": 120,
|
||||||
|
"y": 380,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"adf4bd06e9a983c8",
|
||||||
|
"357518949dc85909",
|
||||||
|
"90184654071f780e"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "90184654071f780e",
|
||||||
|
"type": "junction",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"x": 240,
|
||||||
|
"y": 820,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"82750e07d294a22f",
|
||||||
|
"c9d2ca3b6d642103"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "61ed3bd3811096b7",
|
||||||
|
"type": "telegram sender",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Post Links",
|
||||||
|
"bot": "9fe44d40e8bd80ac",
|
||||||
|
"haserroroutput": false,
|
||||||
|
"outputs": 1,
|
||||||
|
"x": 730,
|
||||||
|
"y": 440,
|
||||||
|
"wires": [
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "0949c2e6fce901db",
|
||||||
|
"type": "comment",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Discord Details",
|
||||||
|
"info": "REDACTED",
|
||||||
|
"x": 800,
|
||||||
|
"y": 60,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "bc207948e399d00d",
|
||||||
|
"type": "python-function-ps",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Cohost Post Py",
|
||||||
|
"pythonPathType": "local",
|
||||||
|
"pythonPath": "python3",
|
||||||
|
"globalPythonName": "",
|
||||||
|
"importPathList": [],
|
||||||
|
"fnCodePre": "\n# user code here.\n",
|
||||||
|
"fnCode": "from cohost.models.user import User\nfrom cohost.models.block import AttachmentBlock, MarkdownBlock\n\nnode.log(\"PYTHON\")\nmsg[\"topic\"] = \"cohost\"\nuser = User.loginWithCookie(\"REDACTED\")\nproject = user.getProject(\"sciencegirl100\")\nblocks = [\n MarkdownBlock(msg[\"payload\"][\"desc\"])\n]\n\nfor i in range(len(msg[\"payload\"][\"files\"])):\n blocks = blocks + [AttachmentBlock(msg[\"payload\"][\"files\"][i][\"file\"], alt_text=msg[\"payload\"][\"images\"][i])]\n\nif msg[\"payload\"][\"spoil\"]:\n post = project.post(msg[\"payload\"][\"title\"], blocks, cws=msg[\"payload\"][\"seo\"], tags=msg[\"payload\"][\"seo\"])\nelse:\n post = project.post(msg[\"payload\"][\"title\"], blocks, tags=msg[\"payload\"][\"seo\"])\n\nmsg[\"payload\"] = post.url\nreturn msg\n",
|
||||||
|
"fnCodePost": "\n# user code here.\n",
|
||||||
|
"x": 400,
|
||||||
|
"y": 460,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"1a034ddb27d958b5"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "953700757800ebd2",
|
||||||
|
"type": "comment",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Cohost Details",
|
||||||
|
"info": "https://github.com/valknight/cohost.py",
|
||||||
|
"x": 800,
|
||||||
|
"y": 100,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "3976c42cbd4334ce",
|
||||||
|
"type": "function",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Discord JS",
|
||||||
|
"func": "let channels = [\n [ \"REDACTED\", \"REDACTED\"]\n]\nlet run = async () => {\n const client = new discordUserBots.Client(\"REDACTED\")\n node.log({msg: \"Discord Init\"})\n client.on.ready = async () => {\n node.log({msg:\"Discord Client Logged In\"})\n let content = {\n content: `**${msg.payload.title}**\\n${msg.payload.desc}\\n#${msg.payload.seo.join(\" #\")}`,\n attachments: []\n }\n let images = msg.payload.files\n for (let i = 0; i < images.length; i++){\n let ext = images[i].file.replace(/^.*\\./, \"\")\n content.attachments.push({\n path: `/home/liz/.node-red/temp/crosspost/24/${images[i].file}`,\n name: `${msg.payload.spoil?\"SPOILER_\":\"\"}image_${i}.${ext}`,\n description: images[i].descr\n })\n }\n let links = [];\n for (let i = 0; i<channels.length; i++){\n let message = await client.send(channels[i][1], content)\n .catch(e => node.error(e))\n links.push(`https://discord.com/channels/${channels[i][0]}/${channels[i][1]}/${message.id}`)\n }\n msg.payload = links\n msg.topic = \"discord\"\n node.send(msg)\n node.done()\n }\n}\n\nrun()",
|
||||||
|
"outputs": 1,
|
||||||
|
"timeout": 0,
|
||||||
|
"noerr": 0,
|
||||||
|
"initialize": "",
|
||||||
|
"finalize": "",
|
||||||
|
"libs": [
|
||||||
|
{
|
||||||
|
"var": "discordUserBots",
|
||||||
|
"module": "discord-user-bots"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "uuid",
|
||||||
|
"module": "uuid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "fs",
|
||||||
|
"module": "fs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "childProcess",
|
||||||
|
"module": "child_process"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x": 390,
|
||||||
|
"y": 340,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"1a034ddb27d958b5"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "981f827a7dc6659f",
|
||||||
|
"type": "comment",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Mastodon Details",
|
||||||
|
"info": "REDACTED",
|
||||||
|
"x": 800,
|
||||||
|
"y": 180,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "cae4545707e742f4",
|
||||||
|
"type": "http in",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "/post",
|
||||||
|
"url": "/post",
|
||||||
|
"method": "post",
|
||||||
|
"upload": true,
|
||||||
|
"swaggerDoc": "",
|
||||||
|
"x": 70,
|
||||||
|
"y": 40,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"5e011ac0717c733a",
|
||||||
|
"9acd68078c47fcde"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "5e011ac0717c733a",
|
||||||
|
"type": "function",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Request Authentication",
|
||||||
|
"func": "let error = null\nconst acceptedKey = [\n \"REDACTED\"\n]\nif (typeof msg.payload.key != 'string'){\n error = \"Missing Authentication\"\n}else {\n if (!acceptedKey.includes(msg.payload.key.toString(\"utf-8\"))){\n error = \"Invalid Authentication\"\n }\n}\n\nif (error) {\n if (msg.payload.key.toString()!=\"debug\"){\n msg.payload = error\n }\n return [ null, msg ]\n}else {\n return [ msg, null ]\n}",
|
||||||
|
"outputs": 2,
|
||||||
|
"timeout": 0,
|
||||||
|
"noerr": 0,
|
||||||
|
"initialize": "",
|
||||||
|
"finalize": "",
|
||||||
|
"libs": [],
|
||||||
|
"x": 210,
|
||||||
|
"y": 100,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"8175b77dc61e31ac"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"2d28ed050f457ff5",
|
||||||
|
"05bfe494ddc5ae1c"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "8175b77dc61e31ac",
|
||||||
|
"type": "function",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Payload Verification",
|
||||||
|
"func": "let error = null\nif (typeof msg.payload.images != 'string' ||\n typeof msg.payload.seo != 'string' ||\n typeof msg.payload.title != 'string' ||\n typeof msg.payload.desc != 'string'\n){\n error = \"Missing payload value\"\n} else {\n /* Expected Payload:\n {\n title: UTF-8 String,\n desc: UTF-8 String,\n seo: Array of UTF-8 Strings,\n images: Array of image alt text Strings\n }\n */\n try {\n let SPOIL = (typeof msg.payload.spoil != 'undefined')\n let imageDescriptions = []\n if ([...msg.payload.images.split(\";\")].length == msg.req.files.length){\n imageDescriptions = [...msg.payload.images.split(\";\")]\n }else if ([...msg.payload.images.split(\"\\n\")].length == msg.files.length){\n imageDescriptions = [...msg.payload.images.split(\"\\n\")]\n }else {\n node.warn({error: \"File Mismatch Conversion\", i: msg.payload.images, f:msg.req.files})\n error = \"Filedata Mismatch Conversion\"\n }\n msg.payload = {\n title: msg.payload.title,\n desc: msg.payload.desc,\n seo: [...msg.payload.seo.split(\";\")],\n images: imageDescriptions,\n spoil: SPOIL\n }\n if (msg.payload.images.length != msg.req.files.length){\n node.warn({error: \"File Mismatch\", i: msg.payload.images, f:msg.req.files})\n error = \"Filedata Mismatch\"\n }\n if (msg.payload.title.length + msg.payload.descr > 1900){\n error = \"Text Too Long\"\n }\n } catch(e) {\n error = \"Data Validation Error: \" + e.toString()\n }\n}\n\nif (error) {\n msg.payload = error\n return [ null, msg ]\n}else {\n return [ msg, null ]\n}\n",
|
||||||
|
"outputs": 2,
|
||||||
|
"timeout": 0,
|
||||||
|
"noerr": 0,
|
||||||
|
"initialize": "",
|
||||||
|
"finalize": "",
|
||||||
|
"libs": [],
|
||||||
|
"x": 470,
|
||||||
|
"y": 80,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"3fbfea693a42d5c4"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"2d28ed050f457ff5"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "251a52bf8516a9fb",
|
||||||
|
"type": "function",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "API Response",
|
||||||
|
"func": "/*\n set msg.topic to the output type\nOutputs:\n - HTTP Response\n - Discord\n - Hackers.Town\n - Cohost\n - Instagram\n - Gemini Blog\n*/\n\n// HTTP API Response\nmsg.topic = \"http\"\nmsg.payload = \"Success\"\n\n\nreturn msg;",
|
||||||
|
"outputs": 1,
|
||||||
|
"timeout": 0,
|
||||||
|
"noerr": 0,
|
||||||
|
"initialize": "",
|
||||||
|
"finalize": "",
|
||||||
|
"libs": [],
|
||||||
|
"x": 400,
|
||||||
|
"y": 260,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"d93e3cd6bf6bbc6b"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "2d28ed050f457ff5",
|
||||||
|
"type": "http response",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Error",
|
||||||
|
"statusCode": "401",
|
||||||
|
"headers": {},
|
||||||
|
"x": 490,
|
||||||
|
"y": 120,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "9acd68078c47fcde",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Dump API Input",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": false,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "true",
|
||||||
|
"targetType": "full",
|
||||||
|
"statusVal": "",
|
||||||
|
"statusType": "auto",
|
||||||
|
"x": 240,
|
||||||
|
"y": 40,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "f552c81b990c1ded",
|
||||||
|
"type": "function",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Assemble Links",
|
||||||
|
"func": "// node.warn(msg)\nlet payload = `${msg.req.body.title}\\n`\nfor (let k in msg.payload){\n if (k == \"discord\"){\n for (let y=0; y<msg.payload.discord.length; y++){\n payload += `${msg.payload.discord[y]}\\n`\n }\n }else{\n payload += `${msg.payload[k]}\\n`\n }\n}\nmsg.payload = {\n chatId: 1005895002,\n type: \"message\",\n content: payload\n};\nreturn msg;",
|
||||||
|
"outputs": 1,
|
||||||
|
"timeout": 0,
|
||||||
|
"noerr": 0,
|
||||||
|
"initialize": "",
|
||||||
|
"finalize": "",
|
||||||
|
"libs": [],
|
||||||
|
"x": 720,
|
||||||
|
"y": 380,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"61ed3bd3811096b7",
|
||||||
|
"4e16d4b24f87bd40"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "1a034ddb27d958b5",
|
||||||
|
"type": "join",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Aggregate Results",
|
||||||
|
"mode": "custom",
|
||||||
|
"build": "object",
|
||||||
|
"property": "payload",
|
||||||
|
"propertyType": "msg",
|
||||||
|
"key": "topic",
|
||||||
|
"joiner": "\\n",
|
||||||
|
"joinerType": "str",
|
||||||
|
"accumulate": true,
|
||||||
|
"timeout": "",
|
||||||
|
"count": "5",
|
||||||
|
"reduceRight": false,
|
||||||
|
"reduceExp": "",
|
||||||
|
"reduceInit": "",
|
||||||
|
"reduceInitType": "",
|
||||||
|
"reduceFixup": "",
|
||||||
|
"x": 700,
|
||||||
|
"y": 340,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"f552c81b990c1ded",
|
||||||
|
"75b13d43522adb78"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "d93e3cd6bf6bbc6b",
|
||||||
|
"type": "http response",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Return API",
|
||||||
|
"statusCode": "200",
|
||||||
|
"headers": {},
|
||||||
|
"x": 610,
|
||||||
|
"y": 260,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "76555f3a45184d26",
|
||||||
|
"type": "function",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Save Files",
|
||||||
|
"func": "let run = async () => {\n node.log({msg:\"Saving Attachments Locally for Cohost\"})\n let images = []\n for (let i = 0; i<msg.payload.images.length; i++){\n images.push({\n file: `/home/liz/.node-red/temp/crosspost/4/${msg.payload.files[i].file}`, \n descr: msg.payload.images[i]\n })\n }\n msg.payload.files = images\n node.send(msg)\n node.done()\n}\n\nrun()",
|
||||||
|
"outputs": 1,
|
||||||
|
"timeout": 0,
|
||||||
|
"noerr": 0,
|
||||||
|
"initialize": "",
|
||||||
|
"finalize": "",
|
||||||
|
"libs": [
|
||||||
|
{
|
||||||
|
"var": "uuid",
|
||||||
|
"module": "uuid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "fs",
|
||||||
|
"module": "fs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "childProcess",
|
||||||
|
"module": "child_process"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x": 390,
|
||||||
|
"y": 420,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"bc207948e399d00d"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "39f818538e39eb2d",
|
||||||
|
"type": "comment",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Master Plan 🌋",
|
||||||
|
"info": "Outputs:\n X HTTP Response\n X Discord\n X Hackers.Town\n X Cohost\n X Instagram\n X Gemini Blog\n \n \nTODO:\n * Discord support CW tags (seo)\n * use image rescale for all instead of each (large remodel)",
|
||||||
|
"x": 560,
|
||||||
|
"y": 40,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "27049be02da427ed",
|
||||||
|
"type": "function",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Instagram",
|
||||||
|
"func": "let run = async () => {\n node.log(\"Initialize Instagram API\")\n let ig = new instagramPrivateApi.IgApiClient()\n ig.state.generateDevice(env.get(\"IG_USERNAME\") + os.hostname());\n \n node.log(\"Instagram Log In\")\n // await ig.simulate.preLoginFlow()\n const user = await ig.account.login(env.get(\"IG_USERNAME\"), env.get(\"IG_PASSWORD\"))\n // await ig.simulate.postLoginFlow()\n \n node.log(\"Instagram Save Images Locally\")\n // let tempDir = \"/home/liz/.node-red/temp/instagram\"\n // if (!fs.existsSync(tempDir)){\n // node.log(\"Creating temp dir for Instagram\")\n // fs.mkdirSync(tempDir, {\n // recursive: true\n // })\n // }\n let albumImages = []\n for (let i = 0; i<msg.payload.images.length; i++){\n // let fileUUID = tempDir + \"/\" + uuid.v4() + \".\" + msg.req.files[i].originalname.replace(/^.*\\./, \"\")\n // fs.writeFileSync(fileUUID, msg.req.files[i].buffer)\n // if (Buffer.byteLength(msg.req.files[i].buffer) > 24000000){ // File is over 24MB\n // let resizeCMD = `/usr/bin/convert \"${fileUUID}\" -define jpeg:extent=30MB \"${fileUUID+\".jpeg\"}\"`\n // node.log(resizeCMD)\n // await childProcess.exec(resizeCMD, (err, stdo, stdi) => {\n // node.warn({msg: \"Instagram Resize\", err, stdo, stdi})\n // return;\n // })\n // fileUUID += \".jpeg\"\n // }\n // node.log({msg: \"Created \" + fileUUID})\n let filePath = `/home/liz/.node-red/temp/crosspost/4/${msg.payload.files[i].file}`\n node.log(`IG Append ${filePath}`)\n albumImages.push({\n file: fs.readFileSync(filePath)\n })\n }\n \n node.log(\"Instagram Sending Album\")\n let payload = {\n caption: `${msg.payload.title} - ${msg.payload.desc}`,\n items: albumImages\n }\n node.warn(payload)\n let result = null\n if (payload.items.length < 2){\n result = await ig.publish.photo({\n caption: payload.caption,\n file: payload.items[0].file\n })\n .catch(e => node.error(e))\n }else {\n result = await ig.publish.album(payload)\n .catch(e => node.error(e))\n }\n node.log(JSON.stringify(result))\n msg.topic = \"instagram\"\n msg.payload = \"\" //`https://www.instagram.com/p/${result.media.code}/` // might cause issues with multi-photo uploads\n node.send(msg)\n node.done()\n}\n\nrun()",
|
||||||
|
"outputs": 1,
|
||||||
|
"timeout": 0,
|
||||||
|
"noerr": 0,
|
||||||
|
"initialize": "",
|
||||||
|
"finalize": "",
|
||||||
|
"libs": [
|
||||||
|
{
|
||||||
|
"var": "instagramPrivateApi",
|
||||||
|
"module": "instagram-private-api"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "os",
|
||||||
|
"module": "os"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "fs",
|
||||||
|
"module": "fs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "uuid",
|
||||||
|
"module": "uuid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "childProcess",
|
||||||
|
"module": "child_process"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x": 380,
|
||||||
|
"y": 540,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"dbbaebd1d08b6537"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "bc5f12b832a7fadd",
|
||||||
|
"type": "comment",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Gemini Details",
|
||||||
|
"info": "\n/home/liz/public_gemini/images/UUID.EXT\n\n```\n# TITLE\n\nDESCR\n\n> #[TAGS]\n\n=> PHOTO ALT\n\n```\n\n/home/liz/public_gemini/blog/photos.gmi",
|
||||||
|
"x": 790,
|
||||||
|
"y": 140,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "1e64b09285a83d77",
|
||||||
|
"type": "ssh-v3",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Prepend Photo File",
|
||||||
|
"conf": "6661ed2f46f73a90",
|
||||||
|
"debug": false,
|
||||||
|
"x": 730,
|
||||||
|
"y": 620,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"79d0b8d8b2235392"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "5b520ce2508b2e19",
|
||||||
|
"type": "sftp in",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"sftp": "178ffcb2099210a1",
|
||||||
|
"operation": "put",
|
||||||
|
"filename": "",
|
||||||
|
"localFilename": "",
|
||||||
|
"fileContents": "",
|
||||||
|
"fileExtension": "",
|
||||||
|
"workdir": "/home/liz/public_gemini/images/",
|
||||||
|
"savedir": "/home/liz/public_gemini/images/",
|
||||||
|
"name": "Put Image",
|
||||||
|
"x": 810,
|
||||||
|
"y": 680,
|
||||||
|
"wires": [
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "f210817c6ad103fd",
|
||||||
|
"type": "function",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Gemini Blog",
|
||||||
|
"func": "/*\nOUTPUTS:\n - Link String * type\n - SSH command to prepend file\n - Array of SFTP objects\n*/\n\nlet run = async () => {\n let response = [\n ]\n let tags = \"#\" + msg.payload.seo.join(' #').replaceAll(\"'\", \"\\\\'\")\n // node.warn(msg.payload.seo.length)\n response[0] = \"gemini://gemini.hackers.town/liz/blog/photos.gmi\"\n msg.topic = \"gemini\"\n response[1] = `echo -e $'# ${msg.payload.title.replaceAll(\"'\", \"\\\\'\")}\\\\n\\\\n${msg.payload.desc.replace(\"'\", \"\\\\'\")}\\\\n\\\\n> ${tags}\\\\n\\\\n`\n response[2] = []\n \n node.log(\"Saving Attachments Locally for Gemini\")\n // Upload images to temp dir $HOME/.node-red/temp/discord/UUID.EXT\n // let tempDir = \"/home/liz/.node-red/temp/gemini\"\n // if (!fs.existsSync(tempDir)){\n // node.log({msg: \"Creating temp dir for Gemini\"})\n // fs.mkdirSync(tempDir, {\n // recursive: true\n // })\n // }\n for (let i = 0; i<msg.payload.images.length; i++){\n // let fileUUID = tempDir + \"/\" + uuid.v4() + \".\" + msg.req.files[i].originalname.replace(/^.*\\./, \"\")\n // fs.writeFileSync(fileUUID, msg.req.files[i].buffer)\n // if (Buffer.byteLength(msg.req.files[i].buffer) > 64000000){ // File is over 64MB\n // await childProcess.exec(`/usr/bin/convert \"${fileUUID}\" -define jpeg:extent=64MB \"${fileUUID+\".jpeg\"}\"`, (err, stdo, stdi) => {\n // return;\n // })\n // fileUUID += \".jpeg\"\n // }\n // node.log({msg: \"Created \" + fileUUID})\n let fileUUID = `/home/liz/.node-red/temp/crosspost/24/${msg.payload.files[i].file}`\n response[1] += `=> gemini://gemini.hackers.town/liz/images/${fileUUID.replace(/^.*\\//, \"\")} ${msg.payload.images[i]}\\\\n`.replaceAll(\"'\", \"\\\\'\")\n \n response[2].push({\n filename: \"/home/liz/public_gemini/images/\" + fileUUID.replace(/^.*\\//, \"\"),\n filedata: fs.readFileSync(fileUUID)\n })\n }\n response[1] += \"\\\\n' > /home/liz/public_gemini/photos.tmp; cat /home/liz/public_gemini/blog/photos.gmi >> /home/liz/public_gemini/photos.tmp; cat /home/liz/public_gemini/photos.tmp > /home/liz/public_gemini/blog/photos.gmi; rm /home/liz/public_gemini/photos.tmp\"\n // node.warn(response)\n node.send([{...msg, payload:response[0]}, {...msg, payload:response[1]}, {...msg, payload:response[2]}, ])\n node.done()\n}\n\nrun()",
|
||||||
|
"outputs": 3,
|
||||||
|
"timeout": 0,
|
||||||
|
"noerr": 0,
|
||||||
|
"initialize": "",
|
||||||
|
"finalize": "",
|
||||||
|
"libs": [
|
||||||
|
{
|
||||||
|
"var": "fs",
|
||||||
|
"module": "fs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "uuid",
|
||||||
|
"module": "uuid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "childProcess",
|
||||||
|
"module": "child_process"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x": 390,
|
||||||
|
"y": 700,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"dbbaebd1d08b6537"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"1e64b09285a83d77"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"94e42cfb52d1a60c"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "94e42cfb52d1a60c",
|
||||||
|
"type": "split",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "",
|
||||||
|
"splt": "\\n",
|
||||||
|
"spltType": "str",
|
||||||
|
"arraySplt": 1,
|
||||||
|
"arraySpltType": "len",
|
||||||
|
"stream": false,
|
||||||
|
"addname": "",
|
||||||
|
"x": 650,
|
||||||
|
"y": 680,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"5b520ce2508b2e19"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "f79dc0217d77183f",
|
||||||
|
"type": "function",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Pixelfed",
|
||||||
|
"func": "const key = \"REDACTED\"\n\nlet run = async () => {\n node.log(\"Saving Attachments Locally for Pixelfed\")\n // Upload images to temp dir $HOME/.node-red/temp/discord/UUID.EXT\n // let tempDir = \"/home/liz/.node-red/temp/pixelfed\"\n // if (!fs.existsSync(tempDir)){\n // node.log(\"Creating temp dir for Pixelfed\")\n // fs.mkdirSync(tempDir, {\n // recursive: true\n // })\n // }\n let images = []\n for (let i = 0; i<msg.payload.images.length; i++){\n // let fileUUID = tempDir + \"/\" + uuid.v4() + \".\" + msg.req.files[i].originalname.replace(/^.*\\./, \"\")\n // fs.writeFileSync(fileUUID, msg.req.files[i].buffer)\n // if (Buffer.byteLength(msg.req.files[i].buffer) > 15000000){ // File is over 15MB (Pixelfed Limit)\n // node.warn({msg: \"Must convert image \", file: fileUUID})\n // await childProcess.exec(`/usr/bin/convert \"${fileUUID}\" -define jpeg:extent=15MB \"${fileUUID+\".jpeg\"}\"`, (err, stdo, stdi) => {\n // return;\n // })\n // fileUUID += \".jpeg\"\n // }\n // node.log(\"Created \" + fileUUID)\n let media = new formData()\n media.append(\"file\", fs.createReadStream(`/home/liz/.node-red/temp/crosspost/15/${msg.payload.files[i].file}`))\n media.append(\"description\", msg.payload.images[i])\n let resp = await axios.request({\n method: \"post\",\n url: \"https://pixel.maddie.info/api/v1/media\",\n headers: {\n \"Authorization\": `Bearer ${key}`,\n \"Content-Type\": \"multipart/form-data\"\n },\n data: media\n }).catch(e=>node.error(e))\n // node.warn({MediaID: resp.data.id})\n images.push(resp.data.id)\n }\n let data = {\n status: `${msg.payload.title}\\n${msg.payload.desc}`,\n visibility: \"public\",\n media_ids: images, // `${images.join(\",\")}`,\n sensitive: msg.payload.spoil\n }\n if (msg.payload.spoil){\n data.spoiler_text = msg.payload.seo.join(\", \")\n }\n // node.warn({d:data})\n let resp = await axios.request({\n method: \"post\",\n url: \"https://pixel.maddie.info/api/v1/statuses\",\n headers: {\n \"Authorization\": `Bearer ${key}`,\n \"Content-Type\": \"application/json\"\n },\n data: data\n }).catch(e=>node.error(e))\n // node.warn({resp:resp})\n msg.payload = resp.data.url\n msg.topic = \"pixelfed\"\n node.send(msg)\n node.done()\n}\n\nrun()",
|
||||||
|
"outputs": 1,
|
||||||
|
"timeout": 0,
|
||||||
|
"noerr": 0,
|
||||||
|
"initialize": "",
|
||||||
|
"finalize": "",
|
||||||
|
"libs": [
|
||||||
|
{
|
||||||
|
"var": "fs",
|
||||||
|
"module": "fs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "childProcess",
|
||||||
|
"module": "child_process"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "uuid",
|
||||||
|
"module": "uuid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "axios",
|
||||||
|
"module": "axios"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "formData",
|
||||||
|
"module": "form-data"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x": 380,
|
||||||
|
"y": 620,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"dbbaebd1d08b6537"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "79d0b8d8b2235392",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "",
|
||||||
|
"active": false,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": false,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "true",
|
||||||
|
"targetType": "full",
|
||||||
|
"statusVal": "",
|
||||||
|
"statusType": "auto",
|
||||||
|
"x": 770,
|
||||||
|
"y": 580,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "75b13d43522adb78",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": false,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "true",
|
||||||
|
"targetType": "full",
|
||||||
|
"statusVal": "",
|
||||||
|
"statusType": "auto",
|
||||||
|
"x": 870,
|
||||||
|
"y": 300,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "05bfe494ddc5ae1c",
|
||||||
|
"type": "function",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Debug layer",
|
||||||
|
"func": "msg.payload = {\n chatId: REDACTED,\n type: \"message\",\n conetent: JSON.stringify(msg.req.body)\n}\nreturn msg;",
|
||||||
|
"outputs": 1,
|
||||||
|
"timeout": 0,
|
||||||
|
"noerr": 0,
|
||||||
|
"initialize": "",
|
||||||
|
"finalize": "",
|
||||||
|
"libs": [],
|
||||||
|
"x": 250,
|
||||||
|
"y": 140,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"2ad8a1b0d62f3f26"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "82e5483fa9d750fd",
|
||||||
|
"type": "function",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Resize Images",
|
||||||
|
"func": "let run = async () => {\n let tempDir = \"/home/liz/.node-red/temp/crosspost\"\n let sizes = [4, 15, 24]\n for(let i=0; i<sizes.length; i++){\n if (!fs.existsSync(`${tempDir}/${sizes[i]}`)){\n node.log(`Creating temp dir for Images ${sizes[i]}`)\n fs.mkdirSync(`${tempDir}/${sizes[i]}`, {\n recursive: true\n })\n }\n }\n // 24MB Discord\n // 5MB Cohost\n // 24MB Instagram\n // 15MB Pixelfed\n // 24MB Gemini\n // 5 - 15 - 24\n let images = []\n for (let i = 0; i<msg.payload.images.length; i++){\n let fileUUID = uuid.v4() + \".\" + msg.req.files[i].originalname.replace(/^.*\\./, \"\")\n fs.writeFileSync(`${tempDir}/${fileUUID}`, msg.req.files[i].buffer)\n for (let y=0; y<sizes.length; y++){\n let fullName = `${tempDir}/${sizes[y]}/${fileUUID}`\n await childProcess.execSync(`/usr/bin/convert \"${tempDir}/${fileUUID}\" -define jpeg:extent=${sizes[y]}MB \"${fullName}\"`)\n node.log({msg: \"Created \" + fullName})\n }\n \n images.push({\n file: fileUUID, \n descr: msg.payload.images[i]\n })\n }\n node.log(\"CONVERSION COMPLETE\")\n msg.payload.files = images\n node.send(msg)\n node.done()\n}\n\n\nrun()",
|
||||||
|
"outputs": 1,
|
||||||
|
"timeout": 0,
|
||||||
|
"noerr": 0,
|
||||||
|
"initialize": "",
|
||||||
|
"finalize": "",
|
||||||
|
"libs": [
|
||||||
|
{
|
||||||
|
"var": "fs",
|
||||||
|
"module": "fs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "childProcess",
|
||||||
|
"module": "child_process"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "uuid",
|
||||||
|
"module": "uuid"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x": 120,
|
||||||
|
"y": 260,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"7a5c537d1408488e"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "4e16d4b24f87bd40",
|
||||||
|
"type": "olfnf-folder-operations",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"operation": "remove",
|
||||||
|
"folder": "/home/liz/.node-red/temp/crosspost",
|
||||||
|
"folder_type": "str",
|
||||||
|
"recursive": true,
|
||||||
|
"name": "Remove Temp Dir",
|
||||||
|
"x": 930,
|
||||||
|
"y": 380,
|
||||||
|
"wires": [
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "08692e5a11d876cb",
|
||||||
|
"type": "comment",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Unsplash Details",
|
||||||
|
"info": "",
|
||||||
|
"x": 560,
|
||||||
|
"y": 780,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "c1b0c978b8e7dbe9",
|
||||||
|
"type": "comment",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Tumblr Details",
|
||||||
|
"info": "",
|
||||||
|
"x": 550,
|
||||||
|
"y": 860,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "c9d2ca3b6d642103",
|
||||||
|
"type": "function",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Tumblr",
|
||||||
|
"func": "\nreturn msg;",
|
||||||
|
"outputs": 1,
|
||||||
|
"timeout": 0,
|
||||||
|
"noerr": 0,
|
||||||
|
"initialize": "",
|
||||||
|
"finalize": "",
|
||||||
|
"libs": [
|
||||||
|
{
|
||||||
|
"var": "fs",
|
||||||
|
"module": "fs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"var": "tumblrJs",
|
||||||
|
"module": "tumblr.js"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x": 370,
|
||||||
|
"y": 860,
|
||||||
|
"wires": [
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "82750e07d294a22f",
|
||||||
|
"type": "function",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Unsplash",
|
||||||
|
"func": "\nreturn msg;",
|
||||||
|
"outputs": 1,
|
||||||
|
"timeout": 0,
|
||||||
|
"noerr": 0,
|
||||||
|
"initialize": "",
|
||||||
|
"finalize": "",
|
||||||
|
"libs": [],
|
||||||
|
"x": 380,
|
||||||
|
"y": 780,
|
||||||
|
"wires": [
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "2ad8a1b0d62f3f26",
|
||||||
|
"type": "telegram sender",
|
||||||
|
"z": "503ae6a51f28e7b1",
|
||||||
|
"name": "Post Debug Data",
|
||||||
|
"bot": "9fe44d40e8bd80ac",
|
||||||
|
"haserroroutput": false,
|
||||||
|
"outputs": 1,
|
||||||
|
"x": 450,
|
||||||
|
"y": 180,
|
||||||
|
"wires": [
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "9fe44d40e8bd80ac",
|
||||||
|
"type": "telegram bot",
|
||||||
|
"botname": "cross_liz_bot",
|
||||||
|
"usernames": "",
|
||||||
|
"chatids": "",
|
||||||
|
"baseapiurl": "",
|
||||||
|
"updatemode": "polling",
|
||||||
|
"pollinterval": "300",
|
||||||
|
"usesocks": false,
|
||||||
|
"sockshost": "",
|
||||||
|
"socksprotocol": "socks5",
|
||||||
|
"socksport": "6667",
|
||||||
|
"socksusername": "anonymous",
|
||||||
|
"sockspassword": "",
|
||||||
|
"bothost": "",
|
||||||
|
"botpath": "",
|
||||||
|
"localbotport": "8443",
|
||||||
|
"publicbotport": "8443",
|
||||||
|
"privatekey": "",
|
||||||
|
"certificate": "",
|
||||||
|
"useselfsignedcertificate": false,
|
||||||
|
"sslterminated": false,
|
||||||
|
"verboselogging": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "6661ed2f46f73a90",
|
||||||
|
"type": "ssh-conf",
|
||||||
|
"ssh": "REDACTED",
|
||||||
|
"name": "HacktsTown",
|
||||||
|
"userlabel": "HacktsTown"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "178ffcb2099210a1",
|
||||||
|
"type": "sftp",
|
||||||
|
"host": "tty.hackers.town",
|
||||||
|
"port": "22",
|
||||||
|
"username": "liz",
|
||||||
|
"password": "",
|
||||||
|
"sshkey": "REDACTED",
|
||||||
|
"hmac": [
|
||||||
|
"hmac-sha2-512-96"
|
||||||
|
],
|
||||||
|
"cipher": [
|
||||||
|
"aes256-gcm@openssh.com"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user