neptune/core/lib/manage/threshold.py

107 lines
2.3 KiB
Python
Raw Normal View History

2022-07-27 19:53:41 +00:00
import urllib.parse
from core.lib.threshold import threshold_request
2022-07-25 18:08:28 +00:00
def get_irc_stats():
url = "irc/stats"
payload = {}
stats = threshold_request(url, payload)
if not stats:
return {}
return stats
2022-07-25 18:08:28 +00:00
def get_irc_networks():
url = "irc/networks"
payload = {}
networks = threshold_request(url, payload)
if not networks:
return {}
2022-07-25 18:08:28 +00:00
return networks
2022-07-26 21:15:30 +00:00
def get_irc_network(net):
url = f"irc/network/{net}"
payload = {}
network = threshold_request(url, payload)
if not network:
return {}
return network
2022-07-27 07:58:57 +00:00
def edit_irc_network(net, data):
url = f"irc/network/{net}/edit"
payload = dict(data)
2022-07-27 19:53:41 +00:00
result = threshold_request(url, payload)
return result
def change_network_status(net, num, status):
url = f"irc/network/{net}/{num}"
payload = {"status": status}
result = threshold_request(url, payload)
return result
2022-07-27 07:58:57 +00:00
2022-07-26 21:15:30 +00:00
def get_irc_relays(net):
url = f"irc/network/{net}/relays"
payload = {}
relays = threshold_request(url, payload)
if not relays:
2022-07-27 19:53:41 +00:00
return {}
2022-07-26 21:15:30 +00:00
return relays
def get_irc_channels(net):
url = f"irc/network/{net}/channels"
payload = {}
channels = threshold_request(url, payload)
if not channels:
2022-07-27 19:53:41 +00:00
return {}
2022-07-26 21:15:30 +00:00
return channels
2022-07-27 19:53:41 +00:00
def part_channel(net, channel):
channel = urllib.parse.quote(channel, safe="")
url = f"irc/network/{net}/channel/{channel}"
payload = {}
parted = threshold_request(url, payload, method="DELETE")
if not parted:
return {}
return parted
def join_channel(net, channel):
channel = urllib.parse.quote(channel, safe="")
url = f"irc/network/{net}/channel/{channel}"
payload = {}
joined = threshold_request(url, payload, method="PUT")
if not joined:
return {}
return joined
2022-07-29 21:22:22 +00:00
2022-07-29 16:28:41 +00:00
2022-07-29 21:22:22 +00:00
def get_aliases():
url = "aliases"
payload = {}
aliases = threshold_request(url, payload, method="GET")
return aliases
2022-07-29 16:28:41 +00:00
def add_relay(net, num):
2022-07-29 21:41:53 +00:00
if num:
url = f"irc/network/{net}/{num}"
else:
url = f"irc/network/{net}"
2022-07-29 16:28:41 +00:00
payload = {}
created = threshold_request(url, payload, method="PUT")
return created
2022-07-29 21:11:34 +00:00
def del_relay(net, num):
url = f"irc/network/{net}/{num}"
payload = {}
deleted = threshold_request(url, payload, method="DELETE")
return deleted