fix: run lint and spellchecker
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details

pull/15/head
Davide Polonio 2022-01-05 16:59:45 +01:00
parent 05dc99685d
commit d79ea7c4fa
2 changed files with 64 additions and 20 deletions

View File

@ -19,21 +19,22 @@ start a series about it, maybe.
## Telegram bots ## Telegram bots
Telegram bots are not something new to me and nowdays are pretty much easy to Telegram bots are not something new to me and nowadays are pretty much easy to
make, so I consider them like a gym where to try out new technologies and make, so I consider them like a gym where to try out new technologies and
experiment with stuff. I wrote plentiful of them, some of those are open source experiment with stuff. I wrote plentiful of them, some of those are open source
like for example https://github.com/Augugrumi/TorreArchimedeBot (which is now like for example <https://github.com/Augugrumi/TorreArchimedeBot> (which is
broken 😭) that was useful when going to University, because it scraped the currently broken 😭) that was useful when going to University, because it
university free room web page and from there it was able to tell you which rooms scraped the university free room web page and from there it was able to tell you
where without any lessons and for how much time, allowing you to easily find a which rooms where without any lessons and for how much time, allowing you to
place where to study with your mates (yep, we didn't like library too much). easily find a place where to study with your mates (yep, we didn't like library
too much).
{{< figure src="/content/songlify/telegramscreen.png" alt=`A screenshot of {{< figure src="/content/songlify/telegramscreen.png" alt=`A screenshot of
TorreArchimedeBot in action.` caption=`A screenshot of TorreArchimedeBot in TorreArchimedeBot in action.` caption=`A screenshot of TorreArchimedeBot in
action.` >}} action.` >}}
Also another one bot worthy of mention is Also another one bot worthy of mention is
https://github.com/Polpetta/RedditToTelegram, that allowed our D&D group to <https://github.com/Polpetta/RedditToTelegram>, that allowed our D&D group to
receive push notifications of our private Subreddit in our Telegram group. receive push notifications of our private Subreddit in our Telegram group.
As you can see, all of these bots are quite simple, but they have the added As you can see, all of these bots are quite simple, but they have the added
@ -92,13 +93,13 @@ the time I started the project.
So, after choosing what was going to use to build the bot, I needed a _reason_ So, after choosing what was going to use to build the bot, I needed a _reason_
to build it. to build it.
With my friends we usually share a lot of songs (via Spotify links), so I tought With my friends we usually share a lot of songs (via Spotify links), so I
it was a good idea to build a bot around it. I integrated a Spotify API library thought it was a good idea to build a bot around it. I integrated a Spotify API
in it and started hacking up a bot. library in it and started hacking up a bot.
> ⚠ Note that at the time of writing I have just notice the library I use for > ⚠ Note that at the time of writing I have just noticed that the library I use
> talking with Spotify, [aspotify](https://crates.io/crates/aspotify) has been > for speaking with Spotify, [aspotify](https://crates.io/crates/aspotify) has
> deprecated in favour of [rspotify](https://crates.io/crates/rspotify) > been deprecated in favour of [rspotify](https://crates.io/crates/rspotify)
The first bot version was something very simple, and it was a single-file The first bot version was something very simple, and it was a single-file
program with nothing very fancy (I have written it in a night): program with nothing very fancy (I have written it in a night):
@ -182,10 +183,11 @@ async fn main() {
As you can see, basically every time a request arrived to the bot, login to As you can see, basically every time a request arrived to the bot, login to
Spotify was performed and track information and name retrieved from there. Of Spotify was performed and track information and name retrieved from there. Of
course this was only the beginning. Now the bot supports albums and playlists course this was only the beginning (also you can "appreciate" the number of
too, with the possibility to go through each song in the playlist and collect nested blocks there...). Now the bot supports albums and playlists too, with the
general information such as how many artists are in that playlist, how many possibility to go through each song in the playlist and collect general
songs and other little information like that. If you see the [bot information such as how many artists are in that playlist, how many songs and
other little information like that. If you see the [bot
repository](https://git.poldebra.me/polpetta/Songlify) you can see now that repository](https://git.poldebra.me/polpetta/Songlify) you can see now that
Spotify functions live in a separate module. Spotify functions live in a separate module.
@ -201,7 +203,7 @@ dependencies inside the final image. I used the images distributed by the
[Github repository](https://github.com/GoogleContainerTools/distroless)) in [Github repository](https://github.com/GoogleContainerTools/distroless)) in
order to obtain the smallest possible image. The final result? order to obtain the smallest possible image. The final result?
``` ```txt
λ ~/Desktop/git/songlify/ docker images λ ~/Desktop/git/songlify/ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
test/test latest 8ac7a7018719 5 seconds ago 34MB test/test latest 8ac7a7018719 5 seconds ago 34MB
@ -217,7 +219,7 @@ able to run, which by default weights 20MB. A plus of these images is that they
do not run as root user and they do not have any shell of bash integrated, do not run as root user and they do not have any shell of bash integrated,
making a possible surface attack smaller (not that Docker is secure anyway...). making a possible surface attack smaller (not that Docker is secure anyway...).
I upload the images on Docker Hub, where you can find them here I upload the images on Docker Hub, where you can find them here
https://hub.docker.com/r/polpetta/songlify <https://hub.docker.com/r/polpetta/songlify>
Finally, to run the bot I use a very simple docker-compose definition, that can Finally, to run the bot I use a very simple docker-compose definition, that can
be found in my [server-dotfiles be found in my [server-dotfiles

View File

@ -35,4 +35,46 @@ Terraform
dojo dojo
Gitea Gitea
orchestrators orchestrators
md md
Spotify
spotify
ORM
Songlify
dotfiles
txt
amd
cd
gcr
OCI
songlify
TorreArchimedeBot
Subreddit
JetBrains
IntelliJ
UI
async
GC
README
tokio
teloxide
fn
env
repl
telegramscreen
SpotifyURL
aspotify
ClientCredentials
enum
url
str
TrackInfo
Ok
TrackInfo
Dockerfile
Distroless
bc
fb
ffa
struct
Vec
creds