5 Commits

Author SHA1 Message Date
VC
e99a666b18 Merge branch 'fix_rand_doc' into 'main'
Fix rand doc

See merge request veretcle/oolatoocs!22
2024-10-09 09:26:25 +00:00
VC
3b18dac2fb 📝: update doc 2024-10-09 11:22:06 +02:00
VC
af977a1ee0 : remove rand 2024-10-09 11:14:07 +02:00
VC
b90b727783 Merge branch 'feat_www' into 'main'
💄: remove www. from url

See merge request veretcle/oolatoocs!21
2024-10-08 08:33:03 +00:00
VC
f8227f99c1 💄: remove www. from url 2024-10-08 10:24:22 +02:00
4 changed files with 22 additions and 17 deletions

7
Cargo.lock generated
View File

@@ -1280,7 +1280,7 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
[[package]]
name = "oolatoocs"
version = "3.1.0"
version = "3.1.1"
dependencies = [
"atrium-api",
"bsky-sdk",
@@ -1292,7 +1292,6 @@ dependencies = [
"log",
"megalodon",
"oauth1-request",
"rand",
"regex",
"reqwest 0.11.27",
"rusqlite",
@@ -1435,9 +1434,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.86"
version = "1.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a"
dependencies = [
"unicode-ident",
]

View File

@@ -1,12 +1,11 @@
[package]
name = "oolatoocs"
version = "3.1.0"
version = "3.1.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rand = "^0.8" # /!\ to be removed
chrono = "^0.4"
clap = "^4"
env_logger = "^0.10"

View File

@@ -1,10 +1,13 @@
# oolatoocs, a Mastodon to Twitter bot
# oolatoocs, a Mastodon to Twitter/Bluesky bot
## A little bit of history
So what is it? Originally, I wrote, with some help, [Scootaloo](https://framagit.org/veretcle/scootaloo/) which was a Twitter to Mastodon Bot to help the [writers at NintendojoFR](https://www.nintendojo.fr) not to worry about Mastodon: the vast majority of writers were posting to Twitter, the bot scooped everything and arranged it properly for Mastodon and everything was fine and dandy. It was also used, in an altered beefed-up version, for [Nupes.social](https://nupes.social) to make the tweets from the NUPES political alliance on Twitter, more easily accessible in Mastodon.
So what is it? Originally, I wrote, with some help, [Scootaloo](https://framagit.org/veretcle/scootaloo/) which was a Twitter to Mastodon Bot to help the [writers at NintendojoFR](https://www.nintendojo.fr) not to worry about Mastodon: the vast majority of writers were posting to Twitter, the bot scooped everything and arranged it properly for Mastodon and everything was fine and dandy. It was also used, in an altered beefed-up version, for the (now defunct) Mastodon Instance [Nupes.social](https://nupes.social) to make the tweets from the NUPES political alliance on Twitter, more easily accessible for Mastodon users.
But then Elon came, and we couldnt read data from Twitter anymore. So we had to rely on copy/pasting things from one to another, which is not fun nor efficient.
Hence `oolatoocs`, which takes a Mastodon Timeline and reposts it to Twitter as properly as possible. And since Bluesky seems to be hype right now, it also incorporates Bluesky support since v3.0.0.
## And now…
Hence `oolatoocs`, which takes a Mastodon Timeline and reposts it to Twitter as properly as possible. And since Bluesky seems to be hype right now, it also incorporates Bluesky support since v3.
Bluesky support is mandatory for now on: you cant have Twitter or Bluesky, you must have both. I might change this behaviour in a near future, especially when I will inevitably have to drop support for Twitter. If you just want Twitter support, just stick with v2.4.x release, itll get the job done exactly as the newer version for now.
@@ -16,8 +19,11 @@ What it can do:
* Reproduces the Toot content into the Tweet/Record;
* Cuts (poorly) the Toot in half in its too long for Twitter/Bluesky and thread it (this is cut using a word count, not the best method, but it gets the job done);
* Reuploads images/gifs/videos from Mastodon to Twitter/Bluesky
* ⚠️ Bluesky does not support mixing images and videos. You can have up to 4 images on a Bsky record **or** 1 video but not mix around. If you do so, only the video will be posted on Bluesky.
* ⚠️ Bluesky does not support images greater than 1Mb (that is 1,000,000,000 bytes or 976.6 KiB). I might incorporate soon a image quality reducer or WebP transcoding to avoid this issue.
* Can reproduce threads from Mastodon to Twitter/Bluesky
* Can reproduce poll from Mastodon to Twitter/Bluesky
* Can reproduce poll from Mastodon to Twitter
* ⚠️ Bluesky does support polls for now. So the poll itself is just presented as text from Mastodon instead which is not the most elegant.
* Can prevent a Toot from being tweeted/recorded to Bluesky by using the #NoTweet (case-insensitive) hashtag in Mastodon
# Configuration file
@@ -26,7 +32,7 @@ The configuration is relatively easy to follow:
```toml
[oolatoocs]
db_path = "/var/lib/oolatoocs/db.sqlite3" # the path to the DB where toot/tweet are stored
db_path = "/var/lib/oolatoocs/db.sqlite3" # the path to the DB where toots/tweets/records are stored
[mastodon] # This part can be generated, see below
base = "https://m.nintendojo.fr"
@@ -41,7 +47,7 @@ consumer_secret = "<REDACTED>"
oauth_token = "<REDACTED>"
oauth_token_secret = "<REDACTED>"
[bluesky]
[bluesky] # this is your Bsky handle and password + a writable path for the session handling
handle = "nintendojofr.bsky.social"
password = "<REDACTED>"
config_path = "/var/lib/oolatoocs/bsky.json"

View File

@@ -59,10 +59,10 @@ pub async fn build_post_record(
let insert_chars = "";
let re = Regex::new(r#"(https?://)(\S{1,26})(\S*)"#).unwrap();
let re = Regex::new(r#"(https?://)(www\.)?(\S{1,26})(\S*)"#).unwrap();
while let Some(found) = re.captures(&rt.text.clone()) {
if let Some(group) = found.get(3) {
if let Some(group) = found.get(4) {
if !group.is_empty() {
rt.insert(group.start(), insert_chars);
rt.delete(
@@ -72,7 +72,8 @@ pub async fn build_post_record(
}
}
if let Some(group) = found.get(1) {
rt.delete(group.start(), group.start() + group.len());
let www: usize = found.get(2).map_or(0, |x| x.len());
rt.delete(group.start(), group.start() + www + group.len());
}
}
@@ -222,8 +223,8 @@ mod tests {
#[tokio::test]
async fn test_build_post_record() {
let text = "@factornews@piaille.fr Retrouvez-nous ici https://www.nintendojo.fr/articles/editos/le-mod-renovation-de-8bitdo-pour-manette-n64 et là https://www.nintendojo.fr/articles/analyses/vite-vu/vite-vu-morbid-the-lords-of-ire et un lien très court http://vsl.ie/TaMere";
let expected_text = "@factornews@piaille.fr Retrouvez-nous ici www.nintendojo.fr/articles… et là www.nintendojo.fr/articles… et un lien très court vsl.ie/TaMere";
let text = "@factornews@piaille.fr Retrouvez-nous ici https://www.nintendojo.fr/articles/editos/le-mod-renovation-de-8bitdo-pour-manette-n64 et là https://www.nintendojo.fr/articles/analyses/vite-vu/vite-vu-morbid-the-lords-of-ire et un lien très court http://vsl.ie/TaMere et un autre https://p.nintendojo.fr/w/kV3CBbKKt1nPEChHhZiNve + http://www.xxx.com + https://www.youtube.com/watch?v=dQw4w9WgXcQ&pp=ygUJcmljayByb2xs";
let expected_text = "@factornews@piaille.fr Retrouvez-nous ici nintendojo.fr/articles/edi… et là nintendojo.fr/articles/ana… et un lien très court vsl.ie/TaMere et un autre p.nintendojo.fr/w/kV3CBbKK… + xxx.com + youtube.com/watch?v=dQw4w9…";
let bsky_conf = BlueskyConfig {
handle: "tamerelol.bsky.social".to_string(),