Skip to content

Commit 1c0c81d

Browse files
committed
chore: staticmethod
1 parent f27e968 commit 1c0c81d

File tree

9 files changed

+40
-26
lines changed

9 files changed

+40
-26
lines changed

examples/multisession_async.py

+1
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ async def handler(client: NewAClient, message: MessageEv):
312312
),
313313
)
314314

315+
315316
@client_factory.event(PairStatusEv)
316317
async def PairStatusMessage(_: NewAClient, message: PairStatusEv):
317318
log.info(f"logged as {message.ID.User}")

goneonize/__main__.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,6 @@ def build_android():
161161
# shell=os.name == "nt",
162162
# )
163163

164-
if __name__ == '__main__':
165-
build()
164+
165+
if __name__ == "__main__":
166+
build()

neonize/_binder.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -466,10 +466,7 @@ def get_bytes(self):
466466
ctypes.c_int,
467467
]
468468
gocode.SendFBMessage.restype = Bytes
469-
gocode.SendPresence.argtypes = [
470-
ctypes.c_char_p,
471-
ctypes.c_char_p
472-
]
469+
gocode.SendPresence.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
473470
gocode.SendPresence.restype = ctypes.c_char_p
474471
else:
475472
gocode: Any = object()

neonize/aioze/client.py

+18-12
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@
182182

183183

184184
class GoCode:
185+
@staticmethod
185186
def execute_sync_function(
186-
self, func: Callable[SyncFunctionParams, ReturnType]
187+
func: Callable[SyncFunctionParams, ReturnType],
187188
) -> Callable[SyncFunctionParams, Awaitable[ReturnType]]:
188189
def call(
189190
*args: SyncFunctionParams.args, **kwargs: SyncFunctionParams.kwargs
@@ -2672,13 +2673,12 @@ async def send_fb_message(
26722673
len(extra_buff),
26732674
)
26742675
return SendResponse.FromString(response.get_bytes())
2676+
26752677
async def send_presence(self, presence: Presence):
2676-
response = await self.__client.SendPresence(
2677-
self.uuid,
2678-
presence.value
2679-
)
2680-
if response:
2681-
raise SendPresenceError(response)
2678+
response = await self.__client.SendPresence(self.uuid, presence.value)
2679+
if response:
2680+
raise SendPresenceError(response)
2681+
26822682
async def connect(self):
26832683
"""Establishes a connection to the WhatsApp servers."""
26842684
# Convert the list of functions to a bytearray
@@ -2723,8 +2723,6 @@ def disconnect(self) -> None:
27232723
self.__client.Disconnect(self.uuid)
27242724

27252725

2726-
2727-
27282726
class ClientFactory:
27292727
def __init__(self, database_name: str = "neonize.db") -> None:
27302728
"""
@@ -2753,7 +2751,12 @@ def get_all_devices_from_db(db: str) -> List[Device]:
27532751
id, server = id.split("@")
27542752
jid = build_jid(id, server)
27552753

2756-
device = Device(JID=jid, PushName=push_name, BussinessName=bussniess_name, Initialized=initialized == "true")
2754+
device = Device(
2755+
JID=jid,
2756+
PushName=push_name,
2757+
BussinessName=bussniess_name,
2758+
Initialized=initialized == "true",
2759+
)
27572760
devices.append(device)
27582761

27592762
return devices
@@ -2763,7 +2766,10 @@ def get_all_devices(self) -> List["Device"]:
27632766
return self.get_all_devices_from_db(self.database_name)
27642767

27652768
def new_client(
2766-
self, jid: Optional[JID] = None, uuid: Optional[str] = None, props: Optional[DeviceProps] = None
2769+
self,
2770+
jid: Optional[JID] = None,
2771+
uuid: Optional[str] = None,
2772+
props: Optional[DeviceProps] = None,
27672773
) -> NewAClient:
27682774
"""
27692775
This function creates a new instance of the client. If the jid parameter is not provided, a new client will be created.
@@ -2787,4 +2793,4 @@ def new_client(
27872793
return client
27882794

27892795
async def run(self):
2790-
return await asyncio.gather(*[client.connect() for client in self.clients])
2796+
return await asyncio.gather(*[client.connect() for client in self.clients])

neonize/aioze/events.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def callback(func: Callable[[NewAClient, EventType], Awaitable[None]]) -> None:
149149

150150
return callback
151151

152+
152153
class EventsManager:
153154
def __init__(self, client_factory: ClientFactory):
154155
self.client_factory = client_factory
@@ -165,6 +166,8 @@ def __call__(
165166
:return: A decorator that registers the callback function.
166167
:rtype: Callable[[Callable[[NewClient, EventType], None]], None]
167168
"""
169+
168170
def callback(func: Callable[[NewAClient, EventType], Awaitable[None]]) -> None:
169171
self.list_func.update({EVENT_TO_INT[event]: func})
170-
return callback
172+
173+
return callback

neonize/client.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -2522,13 +2522,12 @@ def send_fb_message(
25222522
len(extra_buff),
25232523
)
25242524
return SendResponse.FromString(response.get_bytes())
2525+
25252526
def send_presence(self, presence: Presence):
2526-
response = self.__client.SendPresence(
2527-
self.uuid,
2528-
presence.value
2529-
)
2527+
response = self.__client.SendPresence(self.uuid, presence.value)
25302528
if response:
25312529
raise SendPresenceError(response)
2530+
25322531
def connect(self):
25332532
"""Establishes a connection to the WhatsApp servers."""
25342533
# Convert the list of functions to a bytearray
@@ -2601,7 +2600,12 @@ def get_all_devices_from_db(db: str) -> List[Device]:
26012600
id, server = id.split("@")
26022601
jid = build_jid(id, server)
26032602

2604-
device = Device(JID=jid, PushName=push_name, BussinessName=bussniess_name, Initialized=initialized == "true")
2603+
device = Device(
2604+
JID=jid,
2605+
PushName=push_name,
2606+
BussinessName=bussniess_name,
2607+
Initialized=initialized == "true",
2608+
)
26052609
devices.append(device)
26062610

26072611
return devices

neonize/events.py

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class EventsManager:
105105
def __init__(self, client_factory: ClientFactory):
106106
self.client_factory = client_factory
107107
self.list_func: Dict[int, Callable[[NewClient, Message], None]] = {}
108+
108109
def __call__(
109110
self, event: Type[EventType]
110111
) -> Callable[[Callable[[NewClient, EventType], None]], None]:

neonize/exc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,4 @@ class GetChatSettingsError(Exception):
240240

241241

242242
class SendPresenceError(Exception):
243-
pass
243+
pass

neonize/utils/enum.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ class ParticipantRequestChange(Enum):
348348
APPROVE = "approve"
349349
REJECT = "reject"
350350

351+
351352
class Presence(Enum):
352353
AVAILABLE = b"available"
353-
UNAVAILABLE = b"unavailable"
354+
UNAVAILABLE = b"unavailable"

0 commit comments

Comments
 (0)