Skip to content

Commit

Permalink
refactor: Rust rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyko committed Nov 8, 2023
1 parent 28c3855 commit 299f4db
Show file tree
Hide file tree
Showing 61 changed files with 9,763 additions and 123 deletions.
2,115 changes: 1,998 additions & 117 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[workspace]
members = ["services/thothd"]
members = ["services/thothd", "services/thoth"]
resolver = "2"
73 changes: 73 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true

[config]
default_to_workspace = false

[tasks.setup]
script = '''
echo # installing git hooks
pre-commit --version || pip install pre-commit
pre-commit install || echo "failed to install git hooks!" 1>&2
echo # things required to install things
cargo install cargo-binstall
echo # things required for `cargo make test`
cargo binstall -y cargo-nextest
'''

[tasks.dev]
env_files = [".env.dev"]
args = ["run", "--bin", "thoth"]
command = "cargo"
watch = { watch = ["services/thoth"] }

[tasks.lint]
install_crate = "clippy"
command = "cargo"
args = ["clippy", "--tests", "--examples", "--all-targets", "--all-features"]

[tasks.lint-ci]
install_crate = "clippy"
command = "cargo"
args = [
"clippy",
"--tests",
"--examples",
"--all-targets",
"--all-features",
"--",
"-D",
"warnings",
]

[tasks.format]
install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--all"]

[tasks.fmt]
alias = "format"

[tasks.format-ci]
install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--all", "--", "--check"]

[tasks.test]
env = { "RUN_MODE" = "test", "RUST_LOG" = "info", "RUST_BACKTRACE" = 0 }
command = "cargo"
args = [
"nextest",
"run",
"--examples",
"--all-targets",
"--all-features",
"${@}",
]

[tasks.test-ci]
env = { "RUN_MODE" = "ci", "RUST_LOG" = "info" }
command = "cargo"
args = ["nextest", "run", "--examples", "--all-targets", "--all-features"]
28 changes: 28 additions & 0 deletions services/thoth/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "thoth"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1"
redis = { version = "0.23", features = ["tokio-comp", "connection-manager"] }
reqwest = { version = "0.11", features = ["json"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread", "time"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["fmt", "env-filter", "json"] }
twilight-http = { version = "0.15", default-features = false, features = ["rustls-webpki-roots"] }
twilight-cache-inmemory = { version = "0.15", features = ["permission-calculator"] }
twilight-gateway = { version = "0.15", default-features = false, features = ["rustls-webpki-roots", "twilight-http"] }
twilight-model = "0.15"
serde = { version = "1.0.192", features = ["derive"] }
once_cell = "1.18.0"
envy = "0.4.2"
sqlx = { version = "0.7.2", features = ["postgres", "runtime-tokio-rustls"] }
vesper = { version = "0.11.0", features = ["bulk"] }
rust-i18n = "2.2.1"
rand = "0.8.5"
indoc = "2.0.4"
url = "2.4.1"
url-search-params = "12.0.0"
216 changes: 216 additions & 0 deletions services/thoth/locales/bg/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
{
"common": {
"commands": {
"args": {
"limit": {
"name": "limit",
"description": "The maximum amount of results to return (max & default: 50)."
},
"starts-with": {
"name": "starts-with",
"description": "Only return words that start with this value (mutually exclusive with ends-with)."
},
"ends-with": {
"name": "ends-with",
"description": "Only return words that end with this value (mutually exclusive with starts-with)."
}
},
"starts_with_blurb": " that starts with {{word}}",
"ends_with_blurb": " that ends with {{word}}"
},
"errors": {
"with_clause_exclusivity": "The `starts-with` and `ends-with` options are mutually exclusive -- you can't use them both at the same time.",
"not_found": "I'm sorry, I couldn't find any results for your query!",
"not_found_w_suggestions": "I'm sorry, I couldn't find any results for your query! Perhaps you meant: ",
"unauthorized": "Unauthorized.",
"no_permissions": "You don't have permission to use this command.",
"banned": "I'm afraid you've been banned from using Thoth.\nReason: {{- reason}}"
},
"titles": {
"definitions": "Definitions"
}
},
"commands": {
"adjective": {
"meta": {
"name": "adjective",
"description": "Responds with adjectives that describe your query.",
"args": {
"word": {
"name": "word",
"description": "The noun to search relavent adjectives for (eg: ocean)."
}
}
},
"success": "I found `{{found_count}}` adjectives to describe `{{word}}`: \n\n{{words}}"
},
"definition": {
"meta": {
"name": "definition",
"description": "Responds with the definition of your query from Merriam Webster.",
"args": {
"word": {
"name": "word",
"description": "The word to search a definition for (eg: ocean)."
},
"short": {
"name": "short",
"description": "Only return the first definition (default: false)."
}
}
}
},
"invite": {
"meta": {
"name": "invite",
"description": "Returns an invite link to add Thoth to your server."
},
"success": "Want to add Thoth to your server? [Click here]({{link}})!"
},
"match-word": {
"meta": {
"name": "match-word",
"description": "Responds with words that match the word you provide (eg: a??le -> apple, d??? -> date).",
"args": {
"word": {
"name": "word",
"description": "The word to find matches for (example: a??le)."
}
}
},
"success": "I found `{{found_count}}` words that match `{{word}}`: \n\n{{words}}"
},
"noun": {
"meta": {
"name": "noun",
"description": "Responds with nouns that are often described by your query.",
"args": {
"word": {
"name": "word",
"description": "TThe adjective to search relevant nouns for (eg: yellow)."
}
}
},
"success": "I found `{{found_count}}` nouns for `{{word}}`: \n\n{{words}}"
},
"ping": {
"meta": {
"name": "ping",
"description": "Ensures the bot is responding to commands."
},
"pongs": [
"Uhh, hello?",
"What can I do ya' for?",
"Why are you bothering me?",
"Mhm?",
"Yea?",
"What's with you puny humans and the constant desire to bother me?",
"Out of everyone here, you chose to bother me?",
"So *this* is the meaning of life?",
"Can we just get this over with?? I have stuff to do.",
"That's all?",
"Pong!",
"Do it again. I dare you."
]
},
"rhyme": {
"meta": {
"name": "rhyme",
"description": "Responds with words that rhyme with your query.",
"args": {
"word": {
"name": "word",
"description": "The word to search rhymes for (eg: dime)."
}
}
},
"success": "I found `{{found_count}}` words that rhyme with `{{word}}`: \n\n{{words}}"
},
"setup": {
"meta": {
"name": "setup",
"description": "An assortment of configuration commands."
},
"wotd": {
"meta": {
"name": "wotd",
"description": "Configure the Word of the Day channel.",
"args": {
"channel": {
"name": "channel",
"description": "The channel to set as the Word of the Day channel."
}
}
},
"errors": {
"guild_text_only": "The Word of The Day channel must be a text channel!",
"no_perms": "I don't have permissions to create a webhook in {{- channel}}."
},
"success": "The Word of The Day will be posted in {{- channel}} every day at <t:1667538001:t> (12am GMT-5).",
"no_channel": "You must provide a channel to set as the Word of the Day channel."
}
},
"similar-meaning": {
"meta": {
"name": "similar-meaning",
"description": "Response with words that have a similar meaning to your query.",
"args": {
"word": {
"name": "word",
"description": "The word to search similar words for (eg: transgressions)."
}
}
},
"generic_success": "I found `{{found_count}}` words that are similar to `{{word}}`{{rest}}: \n\n{{words}}",
"starts_with_success": "I found `{{found_count}}` words that are similar to `{{word}}` and start with `{{starts_with}}`: \n\n{{words}}",
"ends_with_success": "I found `{{found_count}}` words that are similar to `{{word}}` and end with `{{ends_with}}`: \n\n{{words}}"
},
"similar-spelling": {
"meta": {
"name": "similar-spelling",
"description": "Responds with words that have a similar spelling to your query.",
"args": {
"word": {
"name": "word",
"description": "The word to search similar words for (eg: agile)."
}
}
},
"success": "I found `{{found_count}}` words that're similarly spelled to `{{word}}`: \n\n{{words}}"
},
"sounds-like": {
"meta": {
"name": "sounds-like",
"description": "Responds with words that sound like your query.",
"args": {
"word": {
"name": "word",
"description": "The word to search similarly sounding words for (eg: agile)."
}
}
},
"success": "I found `{{found_count}}` words that sound like `{{word}}`: \n\n{{words}}"
},
"that-follow": {
"meta": {
"name": "that-follow",
"description": "Responds with words that could logically follow query.",
"args": {
"word": {
"name": "word",
"description": "The word to search following words for (eg: open)."
}
}
},
"generic_success": "I found `{{found_count}}` words that logically follow `{{word}}`: \n\n{{words}}",
"starts_with_success": "I found `{{found_count}}` words that logically follow `{{word}}` that start with `{{starts_with}}`: \n\n{{words}}",
"ends_with_success": "I found `{{found_count}}` words that logically follow `{{word}}` that end with `{{ends_with}}`: \n\n{{words}}"
},
"word-of-the-day": {
"meta": {
"name": "word-of-the-day",
"description": "Responds with the word of the day from Merriam Webster."
}
}
}
}
Loading

0 comments on commit 299f4db

Please sign in to comment.