Code Monkey home page Code Monkey logo

mastodon-bot's Introduction

This Repository has been moved to https://gitlab.com/yogthos/mastodon-bot

please follow and find current development there

description

Node.js CI

the bot will post the timeline from the specified Twitter/Tumblr accounts and RSS feeds to Mastodon

NPM

installation

  1. prerequisits: should be installed: Node.js, npm
  2. install mastodon-bot with: sudo npm install mastodon-bot -g
  3. run with: mastodon-bot <path to config>

usage

  • create a Mastodon API key following the instructions here
  • create a Twitter API key following the instructions here
  • create a Tumblr API key following the instructions here
  • create a file called config.edn with the following contents:

NOTE: the bot checks the specified Mastodon account to see the timestamp of the last post, and only posts content with later timestamps to avoid duplicate posts. On the first run the timestamp will default to current time.

{:auth {;; add Twitter config to mirror Twitter accounts
        :twitter {:consumer_key "XXXX"
                  :consumer_secret "XXXX"
                  :access_token_key "XXXX"
                  :access_token_secret "XXXX"}
        :mastodon {:access_token "XXXX"
                   ;; account number you see when you log in and go to your profile
                   ;; e.g: https://mastodon.social/web/accounts/294795
                   :account-id "XXXX"
                   :api_url "https://botsin.space/api/v1/"}
        :tumblr {:consumer_key "XXXX"
                 :consumer_secret "XXXX"
                 :token "XXXX"
                 :token_secret "XXXX"}}
 
:transform [{:source {:source-type :twitter
                       ;; optional, defaults to false
                       :include-replies? false
                       ;; optional, defaults to false
                       :include-rts? false
                       ;; Replace Twitter links by Nitter
                       :nitter-urls? false
                       ;; accounts you wish to mirror
                       :accounts ["arstechnica" "WIRED"]}
             :target {:target-type :mastodon
                      ;; optional flag specifying wether the name of the account
                      ;; will be appended in the post, defaults to false
                      :append-screen-name? false
                      ;; optional visibility flag: direct, private, unlisted, public
                      ;; defaults to public
                      :visibility "unlisted"
                      ;; optional boolean to mark content as sensitive. Defaults to true.
                      :sensitive? true
                      ;; optional boolean defaults to false
                      ;; only sources containing media will be posted when set to true
                      :media-only? true
                      ;; optional limit for the post length. Defaults to 300.
                      :max-post-length 300
                      ;; optional signature for posts. Defaults to "not present".
                      :signature "#newsbot"}
             ;; optionally try to resolve URLs in posts to skip URL shorteners
             ;; defaults to false
             :resolve-urls? true
             ;; optional content filter regexes
             ;; any posts matching the regexes will be filtered out
             :content-filters [".*bannedsite.*"]
             ;; optional keyword filter regexes
             ;; any posts not matching the regexes will be filtered out
             :keyword-filters [".*clojure.*"]
             ;; optional replacements
             ;; When the strings on the left side of this map are encountered in the source,
             ;; they are replaced with the string on the right side of the map:
             :replacements {
               "@openSUSE" "@[email protected]",
               "@conservancy" "@[email protected]"}}

             {:source {:source-type :rss
                       ;; add RSS config to follow feeds
                       :feeds [["Hacker News" "https://hnrss.org/newest"]
                               ["r/Clojure" "https://www.reddit.com/r/clojure/.rss"]]}
             :target {:target-type :mastodon
                      ...}
             :resolve-urls? ...}

             {:source {:source-type :tumblr
                       ;; optional limit for number of posts to retrieve, default: 5
                       :limit 10
                       :accounts ["cyberpunky.tumblr.com" "scipunk.tumblr.com"]
             :target {:target-type :mastodon
                      ...}
             :resolve-urls? ...}}
             ]
}
  • the bot looks for config.edn at its relative path by default, an alternative location can be specified either using the MASTODON_BOT_CONFIG environment variable or passing the path to config as an argument

  • transformations have source (s/def ::source-type #{:twitter :rss :tumblr}) und target (s/def ::target-type #{:mastodon}) you can combine freely. Multiple transformations for same source-target combination are possible. Source and targets refer to the auth section for their credentials.

  • install NPM modules: npm install

  • compile: npx shadow-cljs release app

  • run the bot: npm start

  • to poll at intervals setup a cron job such as:

    */30 * * * * npm start /path/to/config.edn > /dev/null 2>&1

License

Copyright © 2018 Dmitri Sotnikov

Distributed under the MIT License.

mastodon-bot's People

Contributors

andybalaam avatar daquinons avatar ebendinelli avatar jerger avatar josephnuthalapati2244 avatar raboof avatar rohieb avatar strugee avatar svmbrown avatar technologyclassroom avatar tscs37 avatar uhnuser avatar yogthos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mastodon-bot's Issues

action is outside the authorized scopes

It tried the mastodon-bot with twitter & my mastodon server (ver. 2.9.2) and get these message:

root@6b3c928e7c96:/app/mastodon-bot# ./mastodon-bot.cljs
This action is outside the authorized scopes

Unsure whether this message comes from twitter or mastodon ... but google search seems to know this message as mastodon client issue - correct?

I reviewed all my api keys, the mastodon api url is working e.g. for https://social.meissa-gmbh.de/api/v1/accounts/1.

The mastodon app has the permissions to read* write* follow push ... any idea what could be wrong?

Fails silently for Pleroma accounts

I was successfully running a news bot on a Mastodon instance using mastodon-bot. However, when I follow the same instructions for a Pleroma instance, the bot fails silently with no errors.

I have added multiple RSS feeds to the bot's config.edn, but no posts are made.

The OAuth token is not shown in the Security tab of the Pleroma user settings, but there are CSP errors and blocked inline JS, so I'm not sure about that. I was able to get to the last step of the instructions successfully and obtained an access token which I entered into config.edn

Running bot ends with no output

I've been trying to run the bot to mirror a twitter account over to Mastodon. However, whenever I run it with the config it just ends. At first I thought maybe that was because the twitter account had not posted new content, but now that it has I'm seeing that the bot still just stops running without posting anything new.

Failed to start on NPM v3.5.2 with Node v8.10.0

> [email protected] start /home/lain/mastodon-bot
> ./mastodon-bot.cljs

Could not locate the bindings file. Tried:
 → /home/lain/mastodon-bot/node_modules/deasync/build/deasync.node
 → /home/lain/mastodon-bot/node_modules/deasync/build/Debug/deasync.node
 → /home/lain/mastodon-bot/node_modules/deasync/build/Release/deasync.node
 → /home/lain/mastodon-bot/node_modules/deasync/out/Debug/deasync.node
 → /home/lain/mastodon-bot/node_modules/deasync/Debug/deasync.node
 → /home/lain/mastodon-bot/node_modules/deasync/out/Release/deasync.node
 → /home/lain/mastodon-bot/node_modules/deasync/Release/deasync.node
 → /home/lain/mastodon-bot/node_modules/deasync/build/default/deasync.node
 → /home/lain/mastodon-bot/node_modules/deasync/compiled/11.13.0/linux/x64/deasync.node
	 bindings (/home/lain/mastodon-bot/node_modules/bindings/bindings.cljs:88:9)
	 (/home/lain/mastodon-bot/node_modules/deasync/index.cljs:34:32)
	 Object.<anonymous> (/home/lain/mastodon-bot/node_modules/deasync/index.cljs:76:2)
	 Module._compile (internal/modules/cjs/loader.cljs:805:30)
	 Object.Module._extensions..js (internal/modules/cjs/loader.cljs:816:10)
	 Module.load (internal/modules/cjs/loader.cljs:672:32)
	 tryModuleLoad (internal/modules/cjs/loader.cljs:612:12)
	 Function.Module._load (internal/modules/cjs/loader.cljs:604:3)
	 Module.require (internal/modules/cjs/loader.cljs:711:19)
	 require (internal/modules/cjs/helpers.cljs:14:16)


npm ERR! Linux 4.15.0-52-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `./mastodon-bot.cljs`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script './mastodon-bot.cljs'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the mastodon-bot package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ./mastodon-bot.cljs
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs mastodon-bot
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls mastodon-bot
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/lain/mastodon-bot/npm-debug.log   

Lumo got stuck with high CPU usage after some hours

This bot works pretty good, but I've faced an issue:

I'm calling it every 5 mins via a cron job. That works well for a few hours, then my monitoring sends me an alarm about high CPU usage of the VM.

When I check I see Lumo permanently using 100% on each vCPU of the VM. I need to kill the process and then it's working the next couple of hours until it happens again.

Any ideas what can be the issue?

LICENSE file missing from root directory

I see this project is under MIT. Adding a LICENSE file to the root directory would make this very obvious for people new to the project and show up in the About header on the first page view of the project.

Would you like me to make a PR to create the file?

Installation failed

Node.js 14
Ubuntu 20.04 LTS

root@bot:~# sudo npm install mastodon-bot -g
npm WARN deprecated [email protected]: request has been deprecated, see request/request#3142
npm WARN deprecated [email protected]: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated [email protected]: this library is no longer supported
/usr/bin/mastodon-bot -> /usr/lib/node_modules/mastodon-bot/mastodon-bot.js

[email protected] install /usr/lib/node_modules/mastodon-bot/node_modules/deasync
node ./build.js

gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/14.15.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/mastodon-bot/node_modules/deasync/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/mastodon-bot/node_modules/deasync/.node-gyp'
gyp ERR! System Linux 5.4.0-1028-oracle
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/mastodon-bot/node_modules/deasync
gyp ERR! node -v v14.15.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
Build failed
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node ./build.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-11-03T11_48_12_882Z-debug.log

README needs updating

I'm a bit confused how to build/run the project after #43 and #44: neither npm start/npm test nor npx shadow-cljs release app seem to work anymore.

Feature request: replace Twitter links by Nitter

It would be great to have the option to replace Twitter links with their non-tracking/privacy friendly Nitter equivalent. E.g.: automatically replace https://twitter.com/privacyint by https://nitter.net/privacyint in the body of the post (this also works for post).

I imagine this requires parsing the content of the post, use a regex to catch all twitter.com links and replace by nitter. I don't master the language of this bot so it's not easy for me but I'm happy to give it a try with some guidance.

Markdown export

Would it be possible to add support for exporting or saving syndicated content into a Markdown file? Similar in operation to how belong.io or latest.is works (harvests urls from specific users on Twitter, generates a webpage of links), this could be integrated in a static site generator publishing process such as Jekyll or Hugo.

Automatically parsing Tweets despite length limts

I have set the length limit well above the 240 character limit of Twitter, but it is still parsing tweets into links above a certain threshold.

From mastodon-bot.cljs I have set:

(def max-post-length 1000)

and from individual config.edn files I have set
:max-post-length 1000

I am using this Exclusively for Mirroring twitter accounts to their mastodon counterparts but it seems anything over about two hundred characters is parsed into a link.

Any suggestions? Or can I just remove the entire trim-text section?

missing Mastodon client configuration!

Not sure whats going on with this one, when i go to run the script it just exits with that error. I have that area of the config file filled out fully.

Add an option of adding twitter feeds via search

As it now stands, this bot requires Twitter API application keys

Getting them is too much hoops to jump through. You need an account itself and also the phone number is required.

This project needs no Twitter account, it gust needs a username.
https://github.com/ciderpunx/twitrssme/blob/master/fcgi/twitter_user_to_rss.pl

From what I understand, it does it via twitter's search.
It would be nice to add this feature here, while also saving multiple images capability.

Sync gitlab with github

We should either sync both repos (gitlab -> github) or archive the github repo (and leave a prominent link to gitlab).

As our pipelines are running on gitlab I would prefer at least MR / PR / Development in gitlab.

@yogthos what do you think ?

Help on create Twitter API

Any can recreate this step ?
I can't make it

  • create a Twitter API key following the instructions here

typo in example

there is an error in the last line of the config example.
It shows now ": nitter-urls" and this fails with an error about a single colon.
Should be ':nitter-urls'

Lack of clarity on how to run the application

There seems to be some lack of clarity on how exactly the application should be run. I installed it just fine on Ubuntu 20.04.1 LTS with sudo npm install mastodon-bot -g and created a config.edn file in a directory. Then I tried to run it with mastodon-bot -h. The output that follows is:

usage:
                  
  node target/mastodon-bot.js [-h] /path/to/config.edn 
  
  or
  
  npm start [-h] /path/to/config.edn

This already contradicts the README instructions. Trying the first option is futile since it seems to expect that you're in the project directory (and thus assumes you have the code locally). The second seems to assume the same thing, but even when I did clone the directory, it seems that there's no configuration for start? I'm not really sure how to run the bot.

I did clone the project eventually and compiled it with the command npx shadow-cljs release app. As I mentioned earlier, there seems to be no configuration for start as running npm start produces the following error: npm ERR! missing script: start. I tried node mastodon-bot.js -h config.edn and received the following error:

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'mastodon-api'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at /home/rosalogia/Projects/mbot/mastodon-bot/mastodon-bot.js:4861:615
    at Object.<anonymous> (/home/rosalogia/Projects/mbot/mastodon-bot/mastodon-bot.js:5275:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)

So I'm really not sure how I'm meant to run this. Thanks in advance for your help! Really nice looking project here 😄

Find better CI-automation

I think gitlab-actions had some hard issues. Maybe can setup travis ci ?
Travis will be harder for setting up the credentials but a way smarter for automating steps.

Provide schema as jar

I would like to use the defined schema to validate inputs in https://gitlab.com/domaindrivenarchitecture/k8s-mastodon-bot

k8s-mastodon-bot creates k8s deployment.yaml - comparable to helm.

It can be used as webapp but also as compiled graalvm-binary. Therefore it would be nice to have the spec also as jar-dependency (you know, fail fast, validate early :-).

Provided a firs impression in https://gitlab.com/yogthos/mastodon-bot/-/merge_requests/7

If you like the idea I will proceed :-)

Pls. review the settings in project.clj - e.g. provide your clojars group.

All Rss Feeds are tooted with each call

Every time I call my config with ./mastodon-vot.cljs hamburg_de.edn all posts are tooted, not just the new ones.

How can I debug the script and find my issue?

Here is my config:

{
;; add RSS config to follow feeds
   :rss {"hamburg.de news" "http://www.hamburg.de/,rss"
     	      "hamburg.de erlebnis" "http://www.hamburg.de/erlebnis-sport,rss/"
     	      "hamburg.de wochenende" "http://www.hamburg.de/wochenendtipps,rss/"}
           :mastodon {:access_token "my_key"
           :api_url "https://my_url/api/v1/"
           ;; optional boolean to mark content as sensitive
           ;; :sensitive? true
           ;; optional boolean defaults to false
           ;; only sources containing media will be posted when set to true
           ;; :media-only? true
           ;; optional visibility flag: direct, private, unlisted, public
           ;; defaults to public        
           :visibility "private"
           ;; optional limit for the post length
           :max-post-length 300
           ;; optional flag specifying wether the name of the account
           ;; will be appended in the post, defaults to false
           :append-screen-name? false
           ;; optional signature for posts
           ;; :signature "#newsbot"
           ;; optionally try to resolve URLs in posts to skip URL shorteners
           ;; defaults to false
           :resolve-urls? true
           ;; optional content filter regexes
           ;; any posts matching the regexes will be filtered out
           ;; :content-filters [".*bannedsite.*"]
           ;; optional keyword filter regexes
           ;; any posts not matching the regexes will be filtered out
           ;; :keyword-filters [".*clojure.*"]
   }
}

EDIT: Within the mastodon account the bot is allowed to read:statuses and write:statuses.

No effect

Hi there,

Thanks a lot for this bot. I've installed it successfully and managed to run it but litteraly nothing happens, no error message and not posts either. The source Twitter account had a tweet posted 3 hours after the latest Toot of the destination account. Any suggestion? Any logs I could look at to understand what' not working?

Thanks

nodejs -v 
v10.15.1
npm -v
6.4.1
:api_url "https://mastodon.xyz/api/v1/"

Visibility always set to unlisted

Problem: all toots posted by mastodon-bot are unlisted idependantly of the value of "visibility"
How to reproduce: Change visibility value in config.edn, posts are always unlisted

So I made a huge version jump as the result of a server move and with the latest version of mastodon-bot all the toos on our account are unlisted (see: https://mastodon.xyz/web/accounts/257584 )

I've tried commenting the visibility parameter, setting it to "public" but it seems to have no effect. Nothing changed on the account side but I checked and the default visibility is "public"

Here is my config.edn:

{:auth {;; add Twitter config to mirror Twitter accounts
        :twitter {:consumer_key "xxx"
                  :consumer_secret "xxx"
                  :access_token_key "xxx"
                  :access_token_secret "xxx"}
        :mastodon {:access_token "xxx"
                   ;; account number you see when you log in and go to your pro
                   ;; e.g: https://mastodon.social/web/accounts/294795
                   :account-id "257584"
                   :api_url "https://mastodon.xyz/api/v1/"}}
:transform [{:source {:source-type :twitter
                       ;; optional, defaults to false
                       :include-replies? true
                       ;; optional, defaults to false
                       :include-rts? false
                       ;; Replace Twitter links by Nitter
                       :nitter-urls? true
                       ;; accounts you wish to mirror
                       :accounts ["privacyint"]}
             :target {:target-type :mastodon
                      ;; optional flag specifying wether the name of the account
                      ;; will be appended in the post, defaults to false
                      :append-screen-name? false
                      ;; optional visibility flag: direct, private, unlisted, public
                      ;; defaults to public
                      :visibility "public"
                      ;; optional boolean to mark content as sensitive. Defaults to true.
                      :sensitive? false
                      ;; optional boolean defaults to false
                      ;; only sources containing media will be posted when set to true
                      :media-only? false}
             ;; optionally try to resolve URLs in posts to skip URL shorteners
             ;; defaults to false
             :resolve-urls? true}
             ]
}

I checked the code but don't seem to spot anything weird. Is anyone able to reproduce? Thanks.

Reverse order of tweets posted

Thanks for mastodon-bot!

I noticed that when posting multiple tweets to Mastodon, the most recent tweet is posted first and the oldest is posted last, resulting in a reverse ordering.

How little work would it be to reverse the ordering of the twitter feed before processing it?

Unfortunately I have zero insights in Clojure development, so I am not able to solve this issue on my own.

Ignoring replies

I have tried a variety of regular expressions to ignore any replies that start with @, but nothing seems to work. Is there an option I can use in the .cljs file to accomplish this?

Unexpected EOF

When running Mastodon-bot I get this error:

Error: Unexpected EOF while reading item 1 of vector.

Using rss source

optimizations cause runtime crash

Since 9c29c13, mastodon-bot crashes on me:

[:app] Compiling ...
[:app] Build completed. (83 files, 0 compiled, 0 warnings, 11.40s)
/home/aengelen/dev/mastodon-bot/mastodon-bot.js:78
function B(a){if(null==a)return null;if(null!=a&&(a.h&8388608||l===a.ke))return a.ea(null);if(dc(a)||"string"===typeof a)return 0===a.length?null:new ce(a,0,null);if(kc(id,a))return jd(a);throw Error([p.a(a)," is not ISeqable"].join(""));}function C(a){if(null==a)return null;if(null!=a&&(a.h&64||l===a.N))return a.Ka(null);a=B(a);return null==a?null:Hc(a)}function de(a){return null!=a?null!=a&&(a.h&64||l===a.N)?a.Oa(null):(a=B(a))?a.Oa(null):ee:ee}
                                                                                                                                                                                            ^

Error: [object Object] is not ISeqable
    at B (/home/aengelen/dev/mastodon-bot/mastodon-bot.js:78:195)
    at /home/aengelen/dev/mastodon-bot/mastodon-bot.js:205:56
    at pg (/home/aengelen/dev/mastodon-bot/mastodon-bot.js:152:54)
    at og.k.ea (/home/aengelen/dev/mastodon-bot/mastodon-bot.js:154:302)
    at B (/home/aengelen/dev/mastodon-bot/mastodon-bot.js:78:83)
    at Bj (/home/aengelen/dev/mastodon-bot/mastodon-bot.js:364:305)
    at g (/home/aengelen/dev/mastodon-bot/mastodon-bot.js:390:194)
    at /home/aengelen/dev/mastodon-bot/mastodon-bot.js:390:399
    at te (/home/aengelen/dev/mastodon-bot/mastodon-bot.js:84:275)
    at uc (/home/aengelen/dev/mastodon-bot/mastodon-bot.js:129:80)

Map literals must contain an even number of forms.

Hi there, i have used the config example from the readme and added my keys and some twitter accounts to follow but i am getting the error "Error: The map literal starting with :target-type contains 3 form(s). Map literals must contain an even number of forms." when trying to run here is the full output

/usr/lib/node_modules/mastodon-bot/mastodon-bot.js:4829
e,d):f.call(null,a,e,d);if(g!==a)return g}else return cljs.tools.reader.edn.read_symbol(a,e)}}}catch(h){if(h instanceof Error){b=h;if(cljs.tools.reader.impl.utils.ex_info_QMARK_(b)){c=cljs.core.ex_data(b);if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs$cst$keyword$reader_DASH_exception,cljs$cst$keyword$type.cljs$core$IFn$_invoke$arity$1(c)))throw b;throw cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3(b.message,cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.PersistentArrayMap(null,
                                                                                                                                                                                                                                                                                                                                                            ^
Error: The map literal starting with :target-type contains 3 form(s). Map literals must contain an even number of forms.
    at new cljs.core.ExceptionInfo (/usr/lib/node_modules/mastodon-bot/mastodon-bot.js:2218:47)
    at Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (/usr/lib/node_modules/mastodon-bot/mastodon-bot.js:2221:72)
    at Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$2 (/usr/lib/node_modules/mastodon-bot/mastodon-bot.js:2220:449)
    at Function.cljs.tools.reader.impl.errors.throw_ex.cljs$core$IFn$_invoke$arity$variadic (/usr/lib/node_modules/mastodon-bot/mastodon-bot.js:4598:168)
    at Function.cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic (/usr/lib/node_modules/mastodon-bot/mastodon-bot.js:4600:141)
    at Object.cljs.tools.reader.impl.errors.throw_odd_map (/usr/lib/node_modules/mastodon-bot/mastodon-bot.js:4610:113)
    at cljs.tools.reader.edn.read_map (/usr/lib/node_modules/mastodon-bot/mastodon-bot.js:4797:438)
    at Object.cljs.tools.reader.edn.read_delimited (/usr/lib/node_modules/mastodon-bot/mastodon-bot.js:4794:418)
    at cljs.tools.reader.edn.read_map (/usr/lib/node_modules/mastodon-bot/mastodon-bot.js:4797:238)
    at Object.cljs.tools.reader.edn.read_delimited (/usr/lib/node_modules/mastodon-bot/mastodon-bot.js:4794:418) {
  data: {
    meta: null,
    cnt: 2,
    arr: [
      {
        ns: null,
        name: 'type',
        fqn: 'type',
        _hash: 1174270348,
        'cljs$lang$protocol_mask$partition0$': 2153775105,
        'cljs$lang$protocol_mask$partition1$': 4096
      },
      {
        ns: null,
        name: 'reader-exception',
        fqn: 'reader-exception',
        _hash: -1938323098,
        'cljs$lang$protocol_mask$partition0$': 2153775105,
        'cljs$lang$protocol_mask$partition1$': 4096
      },
      {
        ns: null,
        name: 'ex-kind',
        fqn: 'ex-kind',
        _hash: 1581199296,
        'cljs$lang$protocol_mask$partition0$': 2153775105,
        'cljs$lang$protocol_mask$partition1$': 4096
      },
      {
        ns: null,
        name: 'reader-error',
        fqn: 'reader-error',
        _hash: 1610253121,
        'cljs$lang$protocol_mask$partition0$': 2153775105,
        'cljs$lang$protocol_mask$partition1$': 4096
      }
    ],
    __hash: null,
    'cljs$lang$protocol_mask$partition0$': 16647951,
    'cljs$lang$protocol_mask$partition1$': 139268
  },
  cause: null,
  description: undefined,
  number: undefined,
  fileName: undefined,
  lineNumber: undefined,
  columnNumber: undefined
}

and here is the config with keys api url and accounts to follow removed


{:auth {;; add Twitter config to mirror Twitter accounts
        :twitter {:consumer_key ""
                  :consumer_secret ""
                  :access_token_key ""
                  :access_token_secret ""}
        :mastodon {:access_token ""
                   ;; account number you see when you log in and go to your profile
                   ;; e.g: https://mastodon.social/web/accounts/294795
                   :account-id "2"
                   :api_url "my_api_url"}
        :tumblr {:consumer_key "XXXX"
                 :consumer_secret "XXXX"
                 :token "XXXX"
                 :token_secret "XXXX"}}

:transform [{:source {:source-type :twitter
                       ;; optional, defaults to false
                       :include-replies? false
                       ;; optional, defaults to false
                       :include-rts? false
                       ;; Replace Twitter links by Nitter
                       :nitter-urls? true
                       ;; accounts you wish to mirror
                       :accounts ["some" "accounts" "to" "follow"]}
             :target {:target-type :mastodon
                      ;; optional flag specifying wether the name of the account
                      ;; will be appended in the post, defaults to false
                      :append-screen-name? false
                      ;; optional visibility flag: direct, private, unlisted, public
                      ;; defaults to public
                      :visibility "unlisted"
                      ;; optional boolean to mark content as sensitive. Defaults to true.
                      :sensitive? true
                      ;; optional boolean defaults to false
                      ;; only sources containing media will be posted when set to true
                      :media-only? true
                      ;; optional limit for the post length. Defaults to 300.
                      :max-post-length 300
                      ;; optional signature for posts. Defaults to "not present".
                      :signature "#newsbot"}
             ;; optionally try to resolve URLs in posts to skip URL shorteners
             ;; defaults to false
             :resolve-urls? true
             ;; optional content filter regexes
             ;; any posts matching the regexes will be filtered out
             :content-filters [".*bannedsite.*"]
             ;; optional keyword filter regexes
             ;; any posts not matching the regexes will be filtered out
             :keyword-filters [".*clojure.*"]
             ;; optional replacements
             ;; When the strings on the left side of this map are encountered in the source,
             ;; they are replaced with the string on the right side of the map:
             :replacements {
               "@openSUSE" "@[email protected]",
               "@conservancy" "@[email protected]"}}

             {:source {:source-type :rss
                       ;; add RSS config to follow feeds
                       :feeds []
                           
             :target {:target-type :mastodon
                      ...}
             :resolve-urls? ...}

             {:source {:source-type :tumblr
                       ;; optional limit for number of posts to retrieve, default: 5
                       :limit 10
                       :accounts []
             :target {:target-type :mastodon
                      ...}
             :resolve-urls? ...}}
             ]
}

Sync mastodon -> twitter?

I like using mastodon, but I can not force all my network to switch from twitter.
So I'm searching for a way to keep the twitter part informed (and invite them with each post to our mastodon :).

Can you imagine to support the way back in your bot or do you say "that's clearly outside"?

Special character &amp;

I've noticed the character & is being transformed to &amp; when posted to Mastodon (see here). I guess this comes from how the text scrapped from tweets is considered (HTML instead of text).

Any idea how to fix that?

Filter posts pulled

With the recent Tumblr nonsense pushing artists to twitter it would be great if this bot could be selective about what type of post it pulled. Such as only tweets that had media etc.

More differentiated transformation

I've about 20 twitter accounts I follow. I would like to read them on mastodon. But some are technical and some are more political. So it would be cool, to use different signatures / keyword-filters / twitter-reply settings for groups of accounts.

I can imagine two options to achieve this:

  1. I can create several configs and run the bot for each config. In this case it would be cool, if config filename can be handed over as cli parameter.
  2. refactor configuration to separate api-authorization from transformation configurations (we could have a sequence of transformations (e.g. some rss->mastodon, twitter(having tech.-accounts) -> mastodon) od twitter(having political accounts) -> mastodon)

Layout could be sth like

{:twitter-auth { ... all the keys ...}
 :masto-auth {:access_token "XXXX"
                      :account-id "XXXX"
                      :api_url "https://botsin.space/api/v1/"}
 :transformations [
   {:source-rss {"Hacker News" "https://hnrss.org/newest"}
    :target-masto {:signature "#rssbot"
                           :resolve-urls? true
                           :keyword-filters [".*clojure.*"]}}
   {:source-twitter {:include-replies? false
                             :accounts ["WIRED"]}
    :target-masto {:signature "#twitterwiredbot"
                           :resolve-urls? true
                           :keyword-filters [".*clojure.*"]}}
 ]
}

What do you think about ?

Add timestamp of tweet to toot

Can we get a feature that adds the timestamp of the tweet to the corresponding toot?

Something like "Tweeted at 2020-01-28 10:20"

Bot runs forever but no content posted

I finally worked through all config problems and i thought got it working as it posted something! But it then didn't post anything else and more importantly never stopped running. I can't really tell what happened since it doesn't seem to have a verbose option at least not that i can find but something clearly is getting stuck after just one post. I can recreate this by just waiting for new content to pile up and try again. Same result, posts one thing then dies with the process just running forever taking cpu

Publish to npmjs.org

I'd like to have mastodon-bot published to npmjs.org (because that makes it much easier to get it packaged for Nix).

I can take have a look at settings things up. Would that be OK with you, or would you prefer not to?

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.