-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #1 plantnet identification on BlueSky
fix warn / distinct simulate / add deltaHours / fix tests
- Loading branch information
Showing
45 changed files
with
9,609 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 :)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,3 +128,10 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
# IntelliJ | ||
.idea/ | ||
*.iml | ||
|
||
# wip | ||
draft/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# jshint last release was 2 years ago, and hang locally | ||
jshint: | ||
config_file: .jshintrc | ||
# ESLint supported version | ||
# http://help.houndci.com/en/articles/2461415-supported-linters | ||
eslint: | ||
enabled: true | ||
version: 8.1.0 | ||
config_file: .hound_eslint_config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"root": true, | ||
"extends": [ | ||
"eslint:recommended" | ||
], | ||
"env" : { | ||
"browser" : true, | ||
"node" : true, | ||
"es6" : true | ||
}, | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaVersion": 2022 | ||
}, | ||
"plugins": [ | ||
], | ||
"rules": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"esversion": 6 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import dotEnvFlow from 'dotenv-flow'; | ||
export const initEnv = () => { | ||
//~ project init of environment | ||
dotEnvFlow.config({ path: './env/' }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import console from "node:console"; | ||
import {initEnv} from "./commonEnv.js"; | ||
import ApplicationConfig from '../src/config/ApplicationConfig.js'; | ||
|
||
initEnv(); | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
. ./env/.env.bash.development | ||
exec node ./bin/www |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import console from "node:console"; | ||
import {initEnv} from "./commonEnv.js"; | ||
import ApplicationConfig from '../src/config/ApplicationConfig.js'; | ||
|
||
initEnv(); | ||
ApplicationConfig.startServerMode() | ||
.catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
export NODE_ENV=development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
export NODE_ENV=production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.env | ||
.env.* | ||
.env.test | ||
!.env.githubaction | ||
!.env.template | ||
!.env.bash.development | ||
!.env.bash.production | ||
deprecated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// https://eslint.org/docs/latest | ||
import js from "@eslint/js"; | ||
import globals from "globals"; | ||
import mochaPlugin from 'eslint-plugin-mocha'; // https://www.npmjs.com/package/eslint-plugin-mocha | ||
import stylisticJs from '@stylistic/eslint-plugin-js' | ||
export default [ | ||
js.configs.recommended, // Recommended config applied to all files | ||
mochaPlugin.configs.flat.recommended, // or `mochaPlugin.configs.flat.all` to enable all | ||
{ | ||
"files": ["lib/**/*.js", "examples/**/*.js", "tests/**/*.js"], | ||
"languageOptions": { | ||
ecmaVersion: 2022, | ||
sourceType: "module", | ||
globals: { | ||
...globals.node, | ||
"process": true | ||
}, | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"allowImportExportEverywhere": true | ||
}, | ||
}, | ||
plugins: { | ||
'@stylistic/js': stylisticJs | ||
}, | ||
"rules": { | ||
"mocha/no-mocha-arrows": "off", /* pff */ | ||
'@stylistic/js/no-extra-semi': "error", /* to match houndci : https://eslint.org/docs/latest/rules/no-extra-semi */ | ||
} | ||
} | ||
]; |
Oops, something went wrong.