Onionr/static-data/official-plugins/wot/main.py

62 lines
1.6 KiB
Python
Raw Normal View History

2022-08-16 14:55:01 +00:00
"""Onionr - Private P2P Communication.
2022-09-17 05:02:49 +00:00
Web of Trust Plugin
2022-08-16 14:55:01 +00:00
"""
import sys
import os
import locale
from time import sleep
from typing import Set, TYPE_CHECKING
from threading import Thread, local
from gossip.peerset import gossip_peer_set
from logger import log as logging
2022-08-16 14:55:01 +00:00
import onionrplugins
2022-10-01 04:25:46 +00:00
from onionrplugins.pluginapis import plugin_apis
2022-08-16 14:55:01 +00:00
locale.setlocale(locale.LC_ALL, '')
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
# import after path insert
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
plugin_name = 'wot'
2022-10-01 04:25:46 +00:00
PLUGIN_VERSION = '0.0.1'
2022-09-26 20:06:05 +00:00
from wot.identity import identities
from cli import main_ui
from onionrplugins import plugin_apis
import wot
2022-09-26 20:06:05 +00:00
from wot.loadfromblocks import load_identities_from_blocks
2022-08-16 14:55:01 +00:00
def on_init(api, data=None):
logging.info(
f"Web of Trust Plugin v{PLUGIN_VERSION} enabled")
2022-10-01 04:25:46 +00:00
list(
map(
lambda x: identities.add(x),
load_identities_from_blocks())
)
plugin_apis['rpc.add_module_to_api'](wot)
2022-10-01 04:25:46 +00:00
def on_wot_cmd(api, data=None):
main_ui()