Coder Social home page Coder Social logo

doomscrollbot's Introduction

@doomscrolltsk bot sources

These are the sources of the @doomscrolltsk bot on Twitter. It's implemented via a NodeRED flow that utilizes the node-red-node-twitter and node-red-contrib-cron-plus nodes in addition to the built-in ones.

The messages it sends consist of two parts, one doomscroll heads-up and a suggestion what else to do. The flow picks a random one from each and combines them into the final message, making sure it doesn't exceed the 280 character limit.

To allow for community contributions, the messages are stored in an external json file here on Github that gets pulled in by the flow.

The bot originated from a tweet by @BillieRubenMake asking for a bot to regularly inject doomscroll reminders into her timeline.

Contributing strings

If you have ideas for new strings, be it doomscroll heads-ups or suggestions, add them to messages.json and send me a PR!

Messages should be light hearted. Doomscroll heads-ups may be a bit tongue in cheek, suggestions should be wholesome.

NodeRED flow

For the sake of completeness, this is the used NodeRED flow:

Screenshot of the NodeRED flow

[{"id":"15ffe8f5.329ef7","type":"twitter out","z":"8357254d.c82348","twitter":"","name":"Tweet","x":690,"y":620,"wires":[]},{"id":"8b9ed4fc.1fba3","type":"cronplus","z":"8357254d.c82348","name":"every hour","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"hourly","topic":"hourly","payloadType":"default","payload":"","expressionType":"cron","expression":"0 * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":130,"y":620,"wires":[["c4e146d0.4ba55"]]},{"id":"cc3c477c.8da868","type":"debug","z":"8357254d.c82348","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":720,"y":680,"wires":[]},{"id":"59e506e5.cb55d","type":"comment","z":"8357254d.c82348","name":"@doomscrolltsk bot","info":"","x":130,"y":560,"wires":[]},{"id":"c4e146d0.4ba55","type":"http request","z":"8357254d.c82348","name":"Fetch strings","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://raw.githubusercontent.com/foosel/doomscrollbot/master/messages.json","tls":"","persist":false,"proxy":"","authType":"","x":310,"y":620,"wires":[["ad4181ea.32bc18"]]},{"id":"ad4181ea.32bc18","type":"function","z":"8357254d.c82348","name":"Build message","func":"var messages = msg.payload.doomscroll;\nvar suggestions = msg.payload.suggestions;\n\nif (!messages || !suggestions) {\n    node.error(\"No messages or suggestions found\", msg);\n    return;\n}\n\nvar lastMessage = flow.get(\"lastMessage\");\nvar lastSuggestion = flow.get(\"lastSuggestion\");\nvar message = lastMessage;\nvar suggestion = lastSuggestion;\nvar tweet = \"\";\nwhile (message == lastMessage || suggestion == lastSuggestion || tweet.length > 280) {\n    message = messages[Math.floor(Math.random() * messages.length)];\n    suggestion = suggestions[Math.floor(Math.random() * suggestions.length)];\n    tweet = message + \"\\n\\n\" + suggestion;\n}\nflow.set(\"lastMessage\", message);\nflow.set(\"lastSuggestion\", suggestion);\n\nreturn {\n    payload: tweet\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":500,"y":620,"wires":[["cc3c477c.8da868","15ffe8f5.329ef7"]]}]

License

MIT

doomscrollbot's People

Contributors

foosel avatar sycha avatar gringer avatar lf- avatar mjrider avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.