@@ -10,7 +10,7 @@ class Channel:
1010 def __init__ (self , connection : Connection ) -> None :
1111
1212 # Store the original response
13- self .response_raw : str
13+ self .response_raw : str = ''
1414 """Original response used to see available keys."""
1515
1616 self .response_np : SimpleNamespace
@@ -25,6 +25,14 @@ def __init__(self, connection: Connection) -> None:
2525 def get_error (self ) -> Dfn .RPCError :
2626 return self .Error
2727
28+ @property
29+ def get_response (self ) -> Union [dict , None ]:
30+ return self .Connection .get_response ()
31+
32+ @property
33+ def get_response_np (self ) -> Union [SimpleNamespace , None ]:
34+ return self .Connection .get_response_np ()
35+
2836 def list_ (self , object_detail_level : Literal [0 , 1 , 2 , 3 , 4 ] = 1 ) -> list [Dfn .Channel ]:
2937 """List channels.
3038
@@ -42,10 +50,7 @@ def list_(self, object_detail_level: Literal[0, 1, 2, 3, 4] = 1) -> list[Dfn.Cha
4250 self .DB_CHANNELS = []
4351 self .Connection .EngineError .init_error ()
4452
45- response = self .Connection .query (method = 'channel.list' , param = {'object_detail_level' : object_detail_level })
46-
47- self .response_raw = response
48- self .response_np = self .Connection .json_response_np
53+ response :dict [str , dict ] = self .Connection .query (method = 'channel.list' , param = {'object_detail_level' : object_detail_level })
4954
5055 if response is None :
5156 self .Logs .error ('Empty response' )
@@ -100,9 +105,6 @@ def get(self, channel: str, object_detail_level: int = 3) -> Union[Dfn.Channel,
100105
101106 response : dict [str , dict ] = self .Connection .query (method = 'channel.get' , param = {'channel' : channel , 'object_detail_level' : object_detail_level })
102107
103- self .response_raw = response
104- self .response_np = self .Connection .json_response_np
105-
106108 if response is None :
107109 self .Logs .error ('Empty response' )
108110 self .Connection .EngineError .set_error (code = - 2 , message = 'Empty response' )
@@ -146,7 +148,7 @@ def get(self, channel: str, object_detail_level: int = 3) -> Union[Dfn.Channel,
146148
147149 db_members .append (member_obj )
148150
149- objectChannel = Dfn .Channel (
151+ channel_obj = Dfn .Channel (
150152 ** channel_copy ,
151153 bans = [Dfn .ChannelBans (** ban ) for ban in channel .get ('bans' , [])],
152154 ban_exemptions = [Dfn .ChannelBanExemptions (** ban_ex ) for ban_ex in channel .get ('ban_exemptions' , [])],
@@ -155,7 +157,7 @@ def get(self, channel: str, object_detail_level: int = 3) -> Union[Dfn.Channel,
155157 members = db_members
156158 )
157159
158- return objectChannel
160+ return channel_obj
159161
160162 except KeyError as ke :
161163 self .Logs .error (f'KeyError: { ke } ' )
@@ -178,10 +180,7 @@ def set_mode(self, channel: str, modes: str, parameters: str = "") -> bool:
178180 try :
179181 self .Connection .EngineError .init_error ()
180182
181- response = self .Connection .query (method = 'channel.set_mode' , param = {"channel" : channel ,"modes" : modes ,"parameters" : parameters })
182-
183- self .response_raw = response
184- self .response_np = self .Connection .json_response_np
183+ response :dict [str , dict ] = self .Connection .query (method = 'channel.set_mode' , param = {"channel" : channel ,"modes" : modes ,"parameters" : parameters })
185184
186185 if response is None :
187186 self .Logs .error ('Empty response' )
@@ -202,8 +201,10 @@ def set_mode(self, channel: str, modes: str, parameters: str = "") -> bool:
202201
203202 except KeyError as ke :
204203 self .Logs .error (f'KeyError: { ke } ' )
204+ return False
205205 except Exception as err :
206206 self .Logs .error (f'General error: { err } ' )
207+ return False
207208
208209 def set_topic (self , channel : str , topic : str , set_by : str = None , set_at : str = None ) -> bool :
209210 """Set a topic on a channel.
@@ -220,10 +221,7 @@ def set_topic(self, channel: str, topic: str, set_by: str = None, set_at: str =
220221 try :
221222 self .Connection .EngineError .init_error ()
222223
223- response = self .Connection .query (method = 'channel.set_topic' , param = {"channel" : channel , "topic" : topic , "set_by" : set_by , "set_at" : set_at })
224-
225- self .response_raw = response
226- self .response_np = self .Connection .json_response_np
224+ response :dict [str , dict ] = self .Connection .query (method = 'channel.set_topic' , param = {"channel" : channel , "topic" : topic , "set_by" : set_by , "set_at" : set_at })
227225
228226 if response is None :
229227 self .Logs .error ('Empty response' )
@@ -244,8 +242,10 @@ def set_topic(self, channel: str, topic: str, set_by: str = None, set_at: str =
244242
245243 except KeyError as ke :
246244 self .Logs .error (f'KeyError: { ke } ' )
245+ return False
247246 except Exception as err :
248247 self .Logs .error (f'General error: { err } ' )
248+ return False
249249
250250 def kick (self , channel : str , nick : str , reason : str ) -> bool :
251251 """Kick a user from a channel
@@ -261,10 +261,7 @@ def kick(self, channel: str, nick: str, reason: str) -> bool:
261261 try :
262262 self .Connection .EngineError .init_error ()
263263
264- response = self .Connection .query (method = 'channel.kick' , param = {"channel" : channel , "nick" : nick , "reason" : reason })
265-
266- self .response_raw = response
267- self .response_np = self .Connection .json_response_np
264+ response :dict [str , dict ] = self .Connection .query (method = 'channel.kick' , param = {"channel" : channel , "nick" : nick , "reason" : reason })
268265
269266 if response is None :
270267 self .Logs .error ('Empty response' )
@@ -285,5 +282,7 @@ def kick(self, channel: str, nick: str, reason: str) -> bool:
285282
286283 except KeyError as ke :
287284 self .Logs .error (f'KeyError: { ke } ' )
285+ return False
288286 except Exception as err :
289- self .Logs .error (f'General error: { err } ' )
287+ self .Logs .error (f'General error: { err } ' )
288+ return False
0 commit comments