Skip to content

Commit

Permalink
Add AskBioclip plugin - fix #86
Browse files Browse the repository at this point in the history
  • Loading branch information
boly38 committed Sep 8, 2024
1 parent bc6c9a9 commit d3242bd
Show file tree
Hide file tree
Showing 22 changed files with 414 additions and 72 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/trigger_askbioclip_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# create bot action trigger
name: BES_trigger_askbioclip_action
on:
# cf. readme
schedule: # 09h00, 12h00, 15h00, 17h00, 18h00 et 21h00 (FR timezone)
# (CET) Standard time (UTC+1)
- cron: '00 8,11,14,16,17,20 * 11-12,1-3 *'
# (CET) Daylight saving time (UTC+2)
- cron: '00 7,10,13,15,16,19 * 4-10 *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

environment: github_actions_bes
steps:
- name: trigger botEnSky AskBioclip ACTION
env:
BES_ACTION_TOKEN: ${{ secrets.BES_ACTION_TOKEN }}
BES_ACTION_URL: ${{ secrets.BES_ACTION_URL }}
run: |
curl -q -H "API-TOKEN: ${BES_ACTION_TOKEN}" -H "PLUGIN-NAME: AskBioclip" "${BES_ACTION_URL}"
18 changes: 18 additions & 0 deletions .github/workflows/trigger_askbioclip_simulation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# create bot simulation trigger
name: BES_trigger_askbioclip_simulation
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

environment: github_actions_bes
steps:
- name: trigger botEnSky AskBioclip simulation
env:
BES_SIMULATION_TOKEN: ${{ secrets.BES_SIMULATION_TOKEN }}
BES_SIMULATION_URL: ${{ secrets.BES_SIMULATION_URL }}
run: |
curl -q -H "API-TOKEN: ${BES_SIMULATION_TOKEN}" -H "PLUGIN-NAME: AskBioclip" "${BES_SIMULATION_URL}"
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ His ambition is to **bring 😊 happiness to 🦋 Bluesky 👤 users**.

- 🧩 [askPlantnet](src/plugins/AskPlantnet.js) plugin

*search a post with one of [askPlantnet](src/data/askPlantnet.json) mention, and try to identify the parent post using the same previous logic except that bad score or nothing detected will produce a reply.*
*search a post with one of [askPlantnet](src/data/askPlantnet.json) mention, and try to identify the parent post first image using the same previous logic except that bad score or nothing detected will produce a reply to the mention.*


- 🧩 [unMute](src/plugins/UnMute.js) plugin
Expand All @@ -42,6 +42,10 @@ His ambition is to **bring 😊 happiness to 🦋 Bluesky 👤 users**.
- on **good score** result: post a reply with confident ratio, species, genus, family, common name, and a link to flickr gallery (provided by [Avibase](https://avibase.bsc-eoc.org/))
- on **bad score** result, or **nothing detected** result: mute author and don't reply. The action to "mute" the author is to avoid to replay the same classification twice a day (for same result). Muted authors are unMuted by UnMute plugin at the end of the day.

- 🧩 [askBioclip](src/plugins/AskBioclip.js) plugin

*search a post with one of [askBioclip](src/data/askBioclip.json) mention, and try to classify the parent post first image using the same previous logic except that bad score or nothing detected will produce a reply to the mention.*


### Bot trigger
- Github Actions [workflows](.github/workflows) (`trigger_*`) are used to trigger the bot, they are based on `schedule` directives (UTC time, [doc](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule))
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
"test": "echo ci-test&& set NODE_ENV=test&&c8 mocha --exit --unhandled-rejections=strict tests/*.test.js --timeout 50000",
"ci-test": "echo ci-test&& export NODE_ENV=test&& c8 --reporter text --reporter=lcov --lines 66 mocha --unhandled-rejections=strict tests/*.test.js --timeout 50000",
"c8-test": "echo c8-test&& set NODE_ENV=test&& c8 --reporter text --reporter=lcov --lines 66 mocha --unhandled-rejections=strict tests/*.test.js --timeout 50000",
"wipAPN": "curl -v -H 'API-TOKEN: SIMULATE_WITH_LOCAL_DEV_ACCOUNT' -H 'PLUGIN-NAME: AskPlantnet' http://localhost:5000/api/hook",
"wipABC": "curl -v -H 'API-TOKEN: SIMULATE_WITH_LOCAL_DEV_ACCOUNT' -H 'PLUGIN-NAME: AskBioclip' http://localhost:5000/api/hook",
"wipBio": "curl -v -H 'API-TOKEN: SIMULATE_WITH_LOCAL_DEV_ACCOUNT' -H 'PLUGIN-NAME: BioClip' http://localhost:5000/api/hook",
"wipAPN": "curl -v -H 'API-TOKEN: SIMULATE_WITH_LOCAL_DEV_ACCOUNT' -H 'PLUGIN-NAME: AskPlantnet' http://localhost:5000/api/hook",
"wipPN": "curl -v -H 'API-TOKEN: SIMULATE_WITH_LOCAL_DEV_ACCOUNT' -H 'PLUGIN-NAME: Plantnet' http://localhost:5000/api/hook",
"wipUM": "curl -v -H 'API-TOKEN: SIMULATE_WITH_LOCAL_DEV_ACCOUNT' -H 'PLUGIN-NAME: UnMute' http://localhost:5000/api/hook"
},
Expand All @@ -26,7 +27,8 @@
"bluesky",
"bot",
"botEnSky",
"Pl@ntNet"
"Pl@ntNet",
"Bioclip"
],
"metadata": {
"projectDiscussions": "https://github.com/boly38/botEnSky/discussions",
Expand Down
16 changes: 15 additions & 1 deletion src/config/ApplicationConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import GrBirdApiService from "../servicesExternal/GrBirdApiService.js";
import AviBaseService from "../servicesExternal/AviBaseService.js";
import BioClip from "../plugins/BioClip.js";
import PluginsCommonService from "../services/PluginsCommonService.js";
import AskBioclip from "../plugins/AskBioclip.js";

export default class ApplicationConfig {
constructor() {
Expand Down Expand Up @@ -71,6 +72,11 @@ export default class ApplicationConfig {
.addArgument(container.get('blueskyService'))
.addArgument(container.get('pluginsCommonService'));

container.register('bioclipCommonService', PlantnetCommonService)
.addArgument(container.get('loggerService'))
.addArgument(container.get('blueskyService'))
.addArgument(container.get('pluginsCommonService'));

container.register('aviBaseService', AviBaseService)
.addArgument(container.get('loggerService'));

Expand Down Expand Up @@ -130,9 +136,17 @@ export default class ApplicationConfig {
.addArgument(container.get('config'))
.addArgument(container.get('loggerService'))
.addArgument(container.get('pluginsCommonService'))
.addArgument(container.get('bioclipCommonService'))
.addArgument(container.get('grBirdApiService'));
container.register('askBioclip', AskBioclip)
.addArgument(container.get('config'))
.addArgument(container.get('loggerService'))
.addArgument(container.get('blueskyService'))
.addArgument(container.get('pluginsCommonService'))
.addArgument(container.get('bioclipCommonService'))
.addArgument(container.get('grBirdApiService'));
this.plugins.push(container.get('bioclip'));

this.plugins.push(container.get('askBioclip'));
}

constructBot() {
Expand Down
3 changes: 3 additions & 0 deletions src/data/askBioclip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
"AskBioclip"
]
51 changes: 51 additions & 0 deletions src/data/simulation/bioclipPostFakeAskBot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"uri": "at://did:plc:iy7q3r5p5jagqaznuudppucr/app.bsky.feed.post/3l3j2h5kla52e",
"cid": "bafyreiczxxar6rn264wo27v2zkiagh745eg2lbdmtqwfrdxmamihrttnqe",
"author": {
"did": "did:plc:iy7q3r5p5jagqaznuudppucr",
"handle": "boly38.bsky.social",
"displayName": "Boly38",
"avatar": "https://cdn.bsky.app/img/avatar/plain/did:plc:iy7q3r5p5jagqaznuudppucr/bafkreignropk7wuesbc4levrkxtzbh3l554mxduheh4htfkvr6afforkaq@jpeg",
"associated": {
"chat": {
"allowIncoming": "all"
}
},
"viewer": {
"muted": false,
"blockedBy": false,
"following": "at://did:plc:jkvb3exm4wg3jt5veu75qppn/app.bsky.graph.follow/3kskfpio2672i",
"followedBy": "at://did:plc:iy7q3r5p5jagqaznuudppucr/app.bsky.graph.follow/3kt3v2qa3tu2p"
},
"labels": [],
"createdAt": "2024-05-14T19:54:08.801Z"
},
"record": {
"$type": "app.bsky.feed.post",
"createdAt": "2024-09-06T19:06:19.440Z",
"langs": [
"fr"
],
"reply": {
"parent": {
"cid": "bafyreigpy6vlpdbavucz6vrk6sa4fjf4th6ngpdv3hjnefjxfaqalqubxm",
"uri": "at://did:plc:iy7q3r5p5jagqaznuudppucr/app.bsky.feed.post/3l3izvrzfdp2g"
},
"root": {
"cid": "bafyreigpy6vlpdbavucz6vrk6sa4fjf4th6ngpdv3hjnefjxfaqalqubxm",
"uri": "at://did:plc:iy7q3r5p5jagqaznuudppucr/app.bsky.feed.post/3l3izvrzfdp2g"
}
},
"text": "mais askbioclip STP !"
},
"replyCount": 0,
"repostCount": 0,
"likeCount": 0,
"quoteCount": 0,
"indexedAt": "2024-09-06T19:06:19.440Z",
"viewer": {
"threadMuted": false,
"embeddingDisabled": false
},
"labels": []
}
49 changes: 49 additions & 0 deletions src/data/simulation/bioclipPostFakeAskBotBadScore.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"uri": "at://did:plc:zkfih2cilqkmhg7fz7oqvuw7/app.bsky.feed.post/3l3lhran3vt2f",
"cid": "bafyreibixmlvz2b44vqsra5cpuemm4rrsysqxugoo5tdxdrmmv3gjwi2wu",
"author": {
"did": "did:plc:zkfih2cilqkmhg7fz7oqvuw7",
"handle": "isabelletg.bsky.social",
"displayName": "",
"avatar": "https://cdn.bsky.app/img/avatar/plain/did:plc:zkfih2cilqkmhg7fz7oqvuw7/bafkreih6ajhl23wwualh7iimu3gkkuql2pko2vbozqzl2lojhdc4umtmme@jpeg",
"associated": {
"chat": {
"allowIncoming": "all"
}
},
"viewer": {
"muted": false,
"blockedBy": false
},
"labels": [],
"createdAt": "2023-09-19T17:22:22.566Z"
},
"record": {
"$type": "app.bsky.feed.post",
"createdAt": "2024-09-07T18:09:56.737Z",
"langs": [
"fr"
],
"reply": {
"parent": {
"cid": "bafyreidmhbxgyzevc7uvzt3llajbcd6mrb76fqezaaweprcg6yznp5hgxq",
"uri": "at://did:plc:4vcqn56njmlf3n6mu5rzugbc/app.bsky.feed.post/3l3lgomd5qm2f"
},
"root": {
"cid": "bafyreidmhbxgyzevc7uvzt3llajbcd6mrb76fqezaaweprcg6yznp5hgxq",
"uri": "at://did:plc:4vcqn56njmlf3n6mu5rzugbc/app.bsky.feed.post/3l3lgomd5qm2f"
}
},
"text": "Bon appétit 😉"
},
"replyCount": 1,
"repostCount": 0,
"likeCount": 1,
"quoteCount": 0,
"indexedAt": "2024-09-07T18:09:56.737Z",
"viewer": {
"threadMuted": false,
"embeddingDisabled": false
},
"labels": []
}
9 changes: 6 additions & 3 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
"home.best_likes": "Best likes",
"principles.besplantnet.head": "the robot answers to some posts that embeds a flower image !",
"principles.besplantnet.body": "At certain times of the day, the robot searches for images of flowers/plants.\n\n Then it tries to identify the plant, and if successful, it answers the author of the post with an example image.",
"principles.besaskplantnet.head": "the robot answers to certain mentions!",
"principles.besaskplantnet.body": "For the moment it is possible to ask the robot to identify a flower/plant.\n\n To do this, answer a post containing an image of a flower/plant with the mention <code>@botensky.bsky.social</code>.<br/>\n Then you must wait for the robot to wake up for the <b>AskPlantnet</b> plugin (see FAQ)",
"principles.besaskplantnet.head": "the robot answers to certain mentions to identify plant/flower!",
"principles.besaskplantnet.body": "It is possible to ask the robot to identify a flower/plant.\n\n To do this, answer a post containing an image of a flower/plant with the mention <code>@botensky.bsky.social</code>.<br/>\n Then you must wait for the robot to wake up for the <b>AskPlantnet</b> plugin (see FAQ)",
"principles.besbioclip.head": "the robot answers to some posts that embeds a bird image !",
"principles.besbioclip.body": "At certain times of the day, the robot searches for bird images.\n Then it tries to classify the species, and if successful, answers the author of the post with a link to a photo gallery (Avibase).",
"principles.besaskbioclip.head": "the robot responds to certain mentions to identify birds!",
"principles.besaskbioclip.body": "It is possible to ask the robot to identify a bird.<br/>\n To do this, reply to a post containing a bird image with the mention <code>AskBioclip</code>.<br/>\n Then you must wait for the robot to wake up for the <b>AskBioclip</b> plugin (see FAQ)",
"principles.bot_principles": "Bot’s principles",
"principles.functions": "Functions",
"project.line1": "BotEnSky is an open-source project that tries to identify plants or flowers (click on the black GitHub corner).",
Expand All @@ -39,10 +41,11 @@
"faq.body1c": "It takes a little time (sometimes up to 6 minutes) to wake up the server, but then it responds normally.",
"faq.head2": "What time do you wake up?",
"faq.tag2": "🕐",
"faq.body2": "For the moment the scheduled shots are 08:30, 11:30, 14:30, 16:30, 17:30, 20:30 (FR)",
"faq.body2": "For the moment the scheduled shots are 08:30, 11:30, 14:30, 16:30, 17:30, 20:30 (FR). Exact time is not guaranteed by the planner.",
"faq.body2a": "For the <b>PlantNet</b> plugin: I practice at the time of the shot.",
"faq.body2b": "For the <b>AskPlantnet</b> plugin: I practice 10 min after the time of the shot.",
"faq.body2c": "For the <b>BioClip</b> plugin (in test phase): I practice 20 min after the time of the shot.",
"faq.body2d": "For the <b>AskBioClip</b> plugin: I practice 30 min after the time of the shot.",
"server.error.unexpected": "Unexpected error",
"server.error.unavailable": "I am currently under maintenance, please try again later",
"server.error.internal": "an internal error has occurred, the team will be notified, try again in a few days or check the tickets",
Expand Down
9 changes: 6 additions & 3 deletions src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
"home.best_likes": "+ de 'j'aime'",
"principles.besplantnet.head": "le robot réponds à certains posts comportant l'image d'une fleur !",
"principles.besplantnet.body": "A certains moments de la journée, le robot recherche des images de fleur/plante.\n Ensuite il tente d'identifier la plante, et en cas de réussite répond à l'auteur du post avec une image en exemple.",
"principles.besaskplantnet.head": "le robot réponds à certaines mentions !",
"principles.besaskplantnet.body": "Pour le moment il est possible de demander au robot d'identifier une fleur/plante.<br/>\n Pour cela, répondez à un post comportant une image de fleur/plante avec la mention <code>@botensky.bsky.social</code>.<br/>\n Ensuite vous devez attendre le réveil du robot pour le plugin <b>AskPlantnet</b> (cf. FAQ)",
"principles.besaskplantnet.head": "le robot réponds à certaines mentions pour identifier les plantes!",
"principles.besaskplantnet.body": "Il est possible de demander au robot d'identifier une fleur/plante.<br/>\n Pour cela, répondez à un post comportant une image de fleur/plante avec la mention <code>@botensky.bsky.social</code>.<br/>\n Ensuite vous devez attendre le réveil du robot pour le plugin <b>AskPlantnet</b> (cf. FAQ)",
"principles.besbioclip.head": "le robot réponds à certains posts comportant l'image d'un oiseau !",
"principles.besbioclip.body": "A certains moments de la journée, le robot recherche des images d'oiseaux.\n Ensuite il tente de classifier l'espèce, et en cas de réussite répond à l'auteur du post avec un lien vers une galerie de photos (Avibase).",
"principles.besaskbioclip.head": "le robot réponds à certaines mentions pour identifier les oiseaux !",
"principles.besaskbioclip.body": "Il est possible de demander au robot d'identifier un oiseau.<br/>\n Pour cela, répondez à un post comportant une image d'oiseau avec la mention <code>AskBioclip</code>.<br/>\n Ensuite vous devez attendre le réveil du robot pour le plugin <b>AskBioclip</b> (cf. FAQ)",
"principles.bot_principles": "Principes du robot",
"principles.functions": "Fonctions",
"project.line1": "BotEnSky est un projet open-source qui tente d'identifier des plantes ou fleurs (cliquez sur le coin noir GitHub).",
Expand All @@ -39,10 +41,11 @@
"faq.body1c": "Il faut un peu de temps (parfois jusque 6 minutes) pour réveiller le serveur, mais ensuite il répond normalement.",
"faq.head2": "A quelle heure te réveilles-tu ?",
"faq.tag2": "🕐",
"faq.body2": "Pour le moment les tirs planifiés sont 08h30, 11h30, 14h30, 16h30, 17h30, 20h30 (FR)",
"faq.body2": "Pour le moment les tirs planifiés sont 08h30, 11h30, 14h30, 16h30, 17h30, 20h30 (FR). L'heure exacte n'est pas garantie par le planificateur.",
"faq.body2a": "Pour le plugin <b>PlantNet</b> : je pratique au moment du tir.",
"faq.body2b": "Pour le plugin <b>AskPlantnet</b> : je pratique 10 min après le moment du tir.",
"faq.body2c": "Pour le plugin <b>BioClip</b> (en phase de test) : je pratique 20 min après le moment du tir.",
"faq.body2d": "Pour le plugin <b>AskBioClip</b> : je pratique 30 min après le moment du tir.",
"server.error.unexpected": "Erreur inattendue",
"server.error.unavailable": "je suis actuellement en maintenance, retentez plus tard",
"server.error.internal": "une erreur interne s'est produite, l'équipe sera prévenue, retentez dans quelques jours ou consultez les tickets",
Expand Down
Loading

0 comments on commit d3242bd

Please sign in to comment.