Skip to main content

501(c)(3) nonprofit lookup plugin for Sopel IRC bots. Based on Publication 78 data.

Project description

sopel-501c3

501(c)(3) nonprofit lookup plugin for Sopel IRC bots.

Consumes Publication 78 data.

⚠️ Important Notice

Use of this plugin WILL inflate your bot's database size. It intentionally uses local storage in lieu of making an HTTP call out to someone's API every time a command is called.

Importing the whole list of Publication 78 entries into a mostly empty test instance grew the default SQLite .db file to approximately 300 MB. At time of writing, the list consisted of 1,330,000 items occupying ~94 MB in decompressed .txt format as provided by the IRS. (The final database size also includes several column indexes, some of which are currently unused.)

Installing

Releases are hosted on PyPI, so after installing Sopel, all you need is pip:

$ pip install sopel-501c3

Configuring

The easiest way to configure sopel-501c3 is via Sopel's configuration wizard—simply run sopel-plugins configure 501c3 and enter the values for which it prompts you.

Only one option is present in the interactive wizard at this time:

  • update_interval: how often (in days) the plugin should redownload the Publication 78 data file and merge the contents with its database

First startup

The first time Sopel is run with this plugin enabled, the plugin will immediately fetch the latest Publication 78 data and start populating its database table. This is a blocking update, and the bot will not continue with startup until the data import is finished. Finishing the initial data import could take several minutes—or longer, depending on system performance.

If interrupted (e.g. by pressing Ctrl+C), the initial import will resume the next time Sopel is started—still in a blocking mode. Entries already added will be checked again; while re-checking entries is somewhat faster than adding new ones, letting the initial data load complete in a single go will ultimately require the smallest amount of wall time.

After the full initial import finishes once, subsequent updates are run in a background thread.

Using

sopel-501c3 provides one command with two names:

  • .501c3/.npo: If passed an EIN, looks up that EIN. Otherwise, looks for nonprofits whose names contain the query as a substring and responds with up to three of them.

Fuzzier search would be a desirable feature someday, but this initial implementation doesn't attempt it.

Likewise, the ability to "page" past the first three search results would be handy, but that's a project for the future (or perhaps an eager contributor).

Uninstalling

If you wish to remove this plugin, but keep using the bot instance for other tasks, it's recommended to DROP TABLE `501c3_npos`; after the plugin is deactivated/deleted.

How to do this will depend on the database backend you're using. For Sopel's default SQLite backend, that would look like:

⚠️ WARNING: Destructive command with no confirmation step!

sqlite3 /path/to/.sopel/configname.db "DROP TABLE '501c3_npos';" "VACUUM;"

Replace configname with the name of your Sopel config. If you don't specify one when starting your bot (no -c argument), the name is probably default.

This one-liner removes the sopel-501c3 table with all of its data, and compacts the database file. (Note: VACUUM could require up to 2x the original file size in temporary disk space.)

Run against the same test instance mentioned earlier, doing this reduced the .db file from ~300 MB back down to ~50 KB.

Changelog

0.1.0

First release of sopel-501c3.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sopel_501c3-0.1.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sopel_501c3-0.1.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file sopel_501c3-0.1.0.tar.gz.

File metadata

  • Download URL: sopel_501c3-0.1.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for sopel_501c3-0.1.0.tar.gz
Algorithm Hash digest
SHA256 00bab3b18d365724d495a7b348003315adedc8e426d8157e6271a96e25f7dd52
MD5 5aeb5e2eeab9b5a2da430c3886504855
BLAKE2b-256 9f7e354eb95ed735286b114839ad10ef5f6b0e3aaea4e4b84408768bd847c46e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sopel_501c3-0.1.0.tar.gz:

Publisher: pypi.yml on dgw/sopel-501c3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sopel_501c3-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sopel_501c3-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for sopel_501c3-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf4819790e5ba8bdc2c0f18d663646611c7f27e56236b7e890c7290f8d9334b5
MD5 d2664192865f568d510f98d1a8e5379a
BLAKE2b-256 59516220ef1dfe9768b8f19ec7ce5eaabe32845158a7bd31be1880bb5197afc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for sopel_501c3-0.1.0-py3-none-any.whl:

Publisher: pypi.yml on dgw/sopel-501c3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page