Code Monkey home page Code Monkey logo

fletchling's Introduction

Fletchling

Fletchling is a Golbat webhook receiver that processes pokemon webhooks and computes nesting pokemon.

Features

  • Receives and processes pokemon on the fly via webhook from Golbat
  • Uses global spawn data to not confuse event spawns (CD, Spotlight, etc) with nesting pokemon.
  • No reliance on external sites for event or current nesting mon data.
  • Tool for importing nests from overpass (fletchling-osm-importer)
  • API to pull stats, purge stats, reload config, etc.

Configuration

  1. Copy configs/fletchling.toml.example to configs/fletchling.toml and edit it.
  2. In golbat, add a new webhook entry to its config. It should look like this:
[[webhooks]]
url = "http://FLETCHLING-HOSTNAME:9042/webhook"
types = ["pokemon_iv"]

Replace 'FLETCHLING-HOSTNAME' with your host that is running Fletchling. If you are using pm2 and not using docker, this should likely be '127.0.0.1'. If you are using docker, your fletchling hostname will likely be 'fletchling'.

After adding the config to Golbat, restart Golbat to have it take effect.

  1. If you plan to use docker-compose, copy docker-compose.yml.example to docker-compose.yml and edit.

Running

docker

  1. There is an included docker-compose.yml.example file. Copy it to docker-compose.yml and edit it, if needed.
  2. docker-compose up -d

pm2

Requirements

You will need to have at least golang 1.22.1 installed. It is rather new as of the time of this writing. You may need to install it manually. See the instructions and download links.

Building and starting

  1. make
  2. pm2 start ./fletchling --name fletchling -o /dev/null

Verifying it is working

  1. curl http://localhost:9042/api/config -- this should give you the current processor configuration
  2. Check the logs in logs/ (or the log_dir that you configured in fletchling.toml) for errors.
    • Every minute, a log message will appear saying how many pokemon were processed. If this is 0, it means that Fletchling is not getting any webhooks. Check your Golbat webhooks configuration. Check the address Fletchling is listening on (http section in config).

Migrating from other nest processors

nestcollector to Fletching using existing Golbat DB for nests (SIMPLEST)

  1. Gather your Golbat DB info.
  2. Create configs/fletchling.toml as per 'Configuration' instructions above.
    • configure your existing golbat db in configs/fletchling.toml in BOTH 'nests_db' and 'golbat_db' sections.
    • fix the listen address in 'http' section, if necessary.
  3. nuke your cronjob.
  4. start up fletchling per 'Running' section above.

Others

I would just start over, personally. :)

Importing OSM data

Importing docs can be found here.

API

API docs can be found here.

FAQ

FAQ can be found here.

Credits

Thanks to the folks who put a lot of time and effort into nestcollector! Most of the importing, nest-activation filtering, and so forth were either copied/ported from nestcollector or used as a guide to achieve some amount of compatibility.

Enjoy!

All your nest are belong to us.

fletchling's People

Contributors

comstud avatar lenisko avatar cronick avatar fabio1988 avatar na-ji avatar reuschelcgn avatar

Stargazers

IdkxdAsf avatar  avatar  avatar M4IK avatar M3G4THEKING avatar  avatar Malte avatar  avatar Athrun avatar  avatar

Watchers

 avatar James Berry avatar  avatar  avatar RaizeTheLimit avatar

fletchling's Issues

Add option to disable nests with low nest spawn counts

Some stuff from nc:

 echo "update nests set discarded=NULL where pokemon_avg >= $nest_min_spawn_hr and active=1 and discarded = 'spawnhr_warn';" >&3
 echo "update nests set discarded='spawnhr_ban', active=0, pokemon_id=NULL, pokemon_form=NULL where pokemon_avg < $nest_min_spawn_hr and active=1 and discarded = 'spawnhr_warn';" >&3
 echo "update nests set discarded='spawnhr_warn' where pokemon_avg < $nest_min_spawn_hr and active=1 and (discarded <> 'spawnhr_ban' or discarded is NULL);" >&3

overlap query should unset pokemon_id

Fletchling makes sure to unset pokemon_id when disabling a nest due to area/spawnpoints, however it doesn't unset if disabled due to overlap and it should.

Writes logs into pm2 error stream

It writes the out into the wrong error stream ,we initially had that issue with Golbat as well, should be an easy fix to write to right stream :)

Webhook area matching

Need to do something about webhook area matching. There's code for this but disabled at the moment.

I think this should work like Golbat, but the problem is if you have parents on your areas.

DB only has "area_name" right now. Not sure if people have "parent/area" in this column or just "area".

Inaccuracies when areas span multiple timezones.

If one has areas in multiple time zones, the global spawn data is all mixed together. If only 1 small area is in a completely separate timezone, it's effectively comparing against global spawn data that contains mostly data for another time zone. This would mess up the logic that prevents CD/Spotlight hour mons from being counted as nesting.

I wondered if anyone would have this. Apparently at least 1 person does.

Add option for koji `replace` param

When I use /api/v1/geofence/feature-collection/Nest?replace=%22-nest%22 I'm getting error:

INFO 2024-03-24 12:40:02 Reloading areas from koji project 'Nest'
ERRO 2024-03-24 12:40:02 Failed to load areas: invalid character '<' looking for beginning of value.

That's actually a big issue for me cause I can't duplicate some areas with same names (eg. new york -> New York) and that would require rethink my whole koji setup and rename lots of areas :(

To fix it I simply opened my url and saved content to a file that I used in config instead of koji. It works but it requires manual updates each time I change anything in koji :/

Importer - optimize contained

Run a contanied check only within the same area name. Otherwise, the end of great amount of areas will be heavy as hell :)

fletchling-importer: process all areas flag

Having a looong list of areas, I think it makes sense to process all areas from an input project. Maybe a switch like -all-input-areas that would allow to process without -overpass-area

./bin/fletchling-importer/fletchling-importer -overpass-areas-src koji -overpass-koji-project 'EnabledAreas' -overpass-area 'Warszawa' overpass db

Reload API endpoint does not refresh/re-run spawnpoint count

I don't know if I am doing something wrong or skipping any step. I have some Nests that are filled with 0 spawnpoints, but I have checked in RM and Koji that in fact there are spawnpoints in there...
Captura_de_pantalla_2024-03-13_a_las_13 05 41

I have tried to reload fletchling, with refresh=1 and with refresh=1&spawnpoints=all and it continues counting 0 spawnpoints.

EDIT:
I had to manually remove the nest from db and import it again. Then using refresh=1&spawnpoints=all spawnpoints have been counted. It seems that this api endpoint http://localhost:9042/api/config/reload?refresh=1&spawnpoints=all doesn't rerun/refresh spawnpoint count if it has a value. It only refreshes if it is NULL.

EDIT 2:
Okey, I think I have been able to reproduce it
If a nest is activated and you force spawnpoints to 0, if you reload with spawnpoint=all, spawnpoints are populated.
If a nest is not activated and it has 0 spawnpoints, if you reload it, it wont update spawnpoints

Importer - add only-new flag

Add a flag to quickly process areas missing in nests table. Useful to quickly add nests for newly added areas.

Example usage:

./fletchling-osm-importer -all-areas -only-new

That would fetch all unique area_name and process only unmatched areas.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.