Implement joining and parting channels

This commit is contained in:
2022-07-27 20:53:41 +01:00
parent 3d91c4164e
commit b401fe939f
9 changed files with 262 additions and 36 deletions

View File

@@ -1,3 +1,5 @@
import urllib.parse
from core.lib.threshold import threshold_request
@@ -31,8 +33,15 @@ def get_irc_network(net):
def edit_irc_network(net, data):
url = f"irc/network/{net}/edit"
payload = dict(data)
network = threshold_request(url, payload)
return network
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
def get_irc_relays(net):
@@ -40,7 +49,7 @@ def get_irc_relays(net):
payload = {}
relays = threshold_request(url, payload)
if not relays:
return []
return {}
return relays
@@ -49,5 +58,25 @@ def get_irc_channels(net):
payload = {}
channels = threshold_request(url, payload)
if not channels:
return []
return {}
return channels
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