Skip to content

Commit

Permalink
Fix #1 plantnet identification on BlueSky
Browse files Browse the repository at this point in the history
  • Loading branch information
boly38 committed May 21, 2024
1 parent cc75c85 commit 3f0a710
Show file tree
Hide file tree
Showing 40 changed files with 7,940 additions and 6 deletions.
57 changes: 57 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[ < Back](../README.md)

# HowTo Contribute

Please create an [issue](https://github.com/boly38/botEnSky/issues) describing your goal / question / bug description...

If you're interested in an existing issue, please contribute by up-voting for it by adding a :+1:.

If you want to push some code :
- fork and prepare a feature-git-branch, then create a [pull request](https://github.com/boly38/botEnSky/pulls) that link your issue.
- execute tests

You could also be critic with existing ticket/PR : all constructive feedbacks are welcome.

## HowTo execute tests
* launch tests using `npm test`.

Think about environment setup.


## Basis reminder
Clone this repository from GitHub:

```
$ git clone https://github.com/boly38/botEnSky.git
```

### Prerequisites

1. Install NodeJs (https://nodejs.org/en/download/)
2. Install dependencies
```bash
npm install
```

### Set your own private environment

- study each required environment variable in the [template](../env/.env.template)
- copy the template in a private file
```bash
cp ./env/.env.template ./env/.env.development
```

### Start the bot

Execute the application
```bash
npm startDev
```
or (production mode)
```bash
npm run start
```

## PullRequests additional information
Activated bot:
- [houndci](https://houndci.com/)
43 changes: 43 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: botensky-audit

on:
schedule:
- cron: '0 10 * * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
scan:
name: npm audit
runs-on: ubuntu-latest

strategy:
matrix:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node-version: [18.x]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
# - run: npm ci # need package.json.lock
run: |
echo "install"
npm install
echo "show outdated (if any)"
npm outdated --depth=3 || echo "you must think about update your dependencies :)"
- name: Audit backend
uses: oke-py/[email protected]
with:
audit_level: moderate
github_token: ${{ secrets.GITHUB_TOKEN }}
issue_assignees: boly38
issue_labels: cybersecurity,bot-created
dedupe_issues: true
41 changes: 41 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# continuous integration
name: botensky-ci

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the prod branch
push:
branches: [ main ]
pull_request:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

strategy:
matrix:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node-version: [18.x]

environment: github_actions_bes #NODE_ENV=test
steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
# npx force-resolutions : in case of Permission denied: run it locally to fix package-lock.json
run: |
echo "install"
npm install
echo "show outdated (if any)"
npm outdated --depth=3 || echo "you must think about update your dependencies :)"
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,10 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# IntelliJ
.idea/
*.iml

# wip
draft/
37 changes: 31 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
#botEnSky
# botEnSky

botEnSky is a bot [BlueSky social app](https://bsky.app/)
botEnSky is a [BlueSky social app](https://bsky.app/) bot born on May 16, 2024.
- written in JavaScript (Node.js ESM Project),
- the worthy successor to [@botentrain1](https://twitter.com/botentrain1) (ex Twitter bot - [code](https://github.com/boly38/botEnTrain)) but for BlueSky.

- status: **Started May 16, work in progress**
The goal is to bring happiness to Bluesky users.

It is a NodeJs application that relies on [bsky api](https://docs.bsky.app/).
## References

The goal is to be the worthy successor to [@botentrain1](https://twitter.com/botentrain1) ([src](https://github.com/boly38/botEnTrain)) but for BlueSky.
- **BlueSky 🤖 Bot account : [@botensky.bsky.social](https://bsky.app/profile/botensky.bsky.social)** 🤖
- Bot webPage : [botensky.onrender.com](https://botensky.onrender.com/)

The search is not the same between the two networks (X, Bsky), so we will have to think about new designs, but the first function considered is plant identification
## Bot features (plugins)

- French help - cf. [botensky.onrender.com](https://botEnSky.onrender.com)
- English [releases notes](https://github.com/boly38/botEnSky/releases) - via [![Automated Release Notes by gren](https://img.shields.io/badge/%F0%9F%A4%96-release%20notes-00B2EE.svg)](https://github-tools.github.io/github-release-notes/)

## How to contribute ?

cf. [CONTRIBUTING](.github/CONTRIBUTING.md)

### Credits

Application and code structure:
- [NodeJs](https://nodejs.org/) and Node dependencies (cf. [graph](https://github.com/boly38/botEnSky/network/dependencies))
- [BlueSky API](https://docs.bsky.app/)

Services ( having free plan 🚀 🌷 )
- [GitHub Actions](https://github.com/features/actions)
- [Render](https://render.com/) free app hosting and automated deployments
- [Cron-job.org](https://cron-job.org/) scheduler
- [PlantNet.org](https://plantnet.org) ([API](https://my.plantnet.org/)) - plant identification service

Team:
- cf. [contributors](https://github.com/boly38/botEnSky/graphs/contributors)
7 changes: 7 additions & 0 deletions bin/InitEnv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import dotEnvFlow from 'dotenv-flow';

export default class InitEnv {
}

//~ project init of environment
dotEnvFlow.config({ path: './env/' });
12 changes: 12 additions & 0 deletions bin/sandbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import InitEnv from './InitEnv.js';//used
import ApplicationConfig from '../src/config/ApplicationConfig.js';
const appConfig = ApplicationConfig.getInstance();

const showResultAsJson = result => console.log(JSON.stringify(result, null, 2));

let botService = appConfig.get('botService');
botService.run();
const pluginName = "Plantnet";
await botService.process("0.0.0.0", true, pluginName)
.then(showResultAsJson)
.catch(console.log)
3 changes: 3 additions & 0 deletions bin/startDev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
. env/.env.bash.development
exec node bin/www
3 changes: 3 additions & 0 deletions bin/startServer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
. env/.env.bash.production
exec node --unhandled-rejections=strict bin/www
4 changes: 4 additions & 0 deletions bin/www.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import InitEnv from './InitEnv.js';//used
import ApplicationConfig from '../src/config/ApplicationConfig.js';
ApplicationConfig.startServerMode()
.catch(console.error);
17 changes: 17 additions & 0 deletions env/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# server default timezone
TZ=Europe/Paris

## BlueSky
##########
# https://bsky.app/settings/app-passwords
BLUESKY_SERVICE=https://bsky.social
# BLUESKY_USERNAME may be full username (user.bsky.social), or user email
BLUESKY_USERNAME=XXXXXXXXXXXX.bsky.social
# PASSWORD may be user password or app password
BLUESKY_PASSWORD=YYYYYYYYYYYYY

## Pla@ntNet
############
PLANTNET_API_PRIVATE_KEY=ZZZZZZZZZZZZZZ
# PLANTNET_SIMULATE=true will simulate Pl@ntNet API result
BOT_PLANTNET_SIMULATE=true
6 changes: 6 additions & 0 deletions env/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.env
.env.*
.env.test
!.env.githubaction
!.env.template
deprecated
Loading

0 comments on commit 3f0a710

Please sign in to comment.