Skip to content

Commit 908c64a

Browse files
committed
feat: Add a simple groupbot.
1 parent d9b2c11 commit 908c64a

29 files changed

+1134
-134
lines changed

.circleci/config.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ version: 2
33

44
workflows:
55
version: 2
6-
build_linux:
6+
circleci:
77
jobs:
88
- asan
9+
- bazel-opt
910

1011
jobs:
1112
asan:
@@ -60,3 +61,14 @@ jobs:
6061
export LD_PRELOAD=libasan.so.8
6162
export PYTHONPATH=.
6263
python3 -m unittest $(find test -name "*_test.py")
64+
65+
66+
bazel-opt:
67+
working_directory: /tmp/cirrus-ci-build
68+
docker:
69+
- image: toxchat/toktok-stack:latest-release
70+
71+
steps:
72+
- checkout
73+
- run: /src/workspace/tools/inject-repo py_toxcore_c
74+
- run: cd /src/workspace && bazel test -k //py_toxcore_c/...

.cirrus.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
---
2-
bazel-opt_task:
3-
container:
4-
image: toxchat/toktok-stack:latest-release
5-
cpu: 2
6-
memory: 6G
7-
configure_script:
8-
- /src/workspace/tools/inject-repo py_toxcore_c
9-
test_all_script:
10-
- cd /src/workspace && bazel test -k
11-
//py_toxcore_c/...
1+
# ---
2+
# bazel-opt_task:
3+
# container:
4+
# image: toxchat/toktok-stack:latest-release
5+
# cpu: 2
6+
# memory: 6G
7+
# configure_script:
8+
# - /src/workspace/tools/inject-repo py_toxcore_c
9+
# test_all_script:
10+
# - cd /src/workspace && bazel test -k
11+
# //py_toxcore_c/...

.restyled.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
restylers:
3+
- pyment:
4+
enabled: false
5+
- "*"

BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_python//python:defs.bzl", "py_library")
12
load("//third_party/python:build_defs.bzl", "mypy_test", "pyx_library")
23
load("//tools/project:build_defs.bzl", "project")
34

@@ -32,3 +33,10 @@ mypy_test(
3233
),
3334
path = ["py_toxcore_c"],
3435
)
36+
37+
py_library(
38+
name = "py_toxcore_c",
39+
srcs = ["__init__.py"],
40+
visibility = ["//visibility:public"],
41+
deps = [":pytox"],
42+
)

__init__.py

Whitespace-only changes.

cspell.config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: "0.2"
2+
dictionaryDefinitions: []
3+
dictionaries: []
4+
ignoreWords: []
5+
flagWords: []
6+
import: []
7+
ignorePaths:
8+
- BUILD.bazel
9+
- LICENSE*
10+
words:
11+
- bazel
12+
- cdef
13+
- chatlist
14+
- cython
15+
- dgram
16+
- getset
17+
- groupbot
18+
- iphy
19+
- iphydf
20+
- linetrace
21+
- malloc
22+
- norequest
23+
- nospam
24+
- pytox
25+
- toktok
26+
- toxav
27+
- toxcore
28+
- toxencryptsave
29+
- typevars

pytox/toxav/toxav.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from libcpp cimport bool
33
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, int16_t, int32_t, int64_t
44
from libc.stdlib cimport malloc, free
5+
from typing import Optional
56

67
cimport pytox.toxcore.tox as tox
78
cdef extern from "tox/toxav.h":

pytox/toxcore/tox.pxd

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from libcpp cimport bool
33
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, int16_t, int32_t, int64_t
44
from libc.stdlib cimport malloc, free
5+
from typing import Optional
56

67
cdef extern from "tox/tox.h":
78
cpdef enum Tox_Err_Options_New:
@@ -178,6 +179,7 @@ cdef extern from "tox/tox.h":
178179
TOX_ERR_CONFERENCE_JOIN_DUPLICATE
179180
TOX_ERR_CONFERENCE_JOIN_INIT_FAIL
180181
TOX_ERR_CONFERENCE_JOIN_FAIL_SEND
182+
TOX_ERR_CONFERENCE_JOIN_NULL
181183
cpdef enum Tox_Err_Conference_Send_Message:
182184
TOX_ERR_CONFERENCE_SEND_MESSAGE_OK
183185
TOX_ERR_CONFERENCE_SEND_MESSAGE_CONFERENCE_NOT_FOUND
@@ -324,6 +326,7 @@ cdef extern from "tox/tox.h":
324326
TOX_ERR_GROUP_INVITE_ACCEPT_PASSWORD
325327
TOX_ERR_GROUP_INVITE_ACCEPT_FRIEND_NOT_FOUND
326328
TOX_ERR_GROUP_INVITE_ACCEPT_FAIL_SEND
329+
TOX_ERR_GROUP_INVITE_ACCEPT_NULL
327330
cpdef enum Tox_Group_Exit_Type:
328331
TOX_GROUP_EXIT_TYPE_QUIT
329332
TOX_GROUP_EXIT_TYPE_TIMEOUT
@@ -460,7 +463,7 @@ cdef extern from "tox/tox.h":
460463
cdef Tox_Proxy_Type tox_options_get_proxy_type(const Tox_Options* self)
461464
cdef void tox_options_set_proxy_type(Tox_Options* self, Tox_Proxy_Type proxy_type)
462465
cdef const char* tox_options_get_proxy_host(const Tox_Options* self)
463-
cdef void tox_options_set_proxy_host(Tox_Options* self, const char* proxy_host)
466+
cdef bool tox_options_set_proxy_host(Tox_Options* self, const char* proxy_host)
464467
cdef uint16_t tox_options_get_proxy_port(const Tox_Options* self)
465468
cdef void tox_options_set_proxy_port(Tox_Options* self, uint16_t proxy_port)
466469
cdef uint16_t tox_options_get_start_port(const Tox_Options* self)
@@ -473,11 +476,17 @@ cdef extern from "tox/tox.h":
473476
cdef void tox_options_set_hole_punching_enabled(Tox_Options* self, bool hole_punching_enabled)
474477
cdef Tox_Savedata_Type tox_options_get_savedata_type(const Tox_Options* self)
475478
cdef void tox_options_set_savedata_type(Tox_Options* self, Tox_Savedata_Type savedata_type)
476-
cdef void tox_options_set_savedata_data(Tox_Options* self, const uint8_t* savedata_data, size_t length)
479+
cdef size_t tox_options_get_savedata_length(const Tox_Options* self)
480+
cdef const uint8_t* tox_options_get_savedata_data(const Tox_Options* self)
481+
cdef bool tox_options_set_savedata_data(Tox_Options* self, const uint8_t* savedata_data, size_t length)
482+
cdef bool tox_options_get_experimental_owned_data(const Tox_Options* self)
483+
cdef void tox_options_set_experimental_owned_data(Tox_Options* self, bool experimental_owned_data)
477484
cdef bool tox_options_get_experimental_thread_safety(const Tox_Options* self)
478485
cdef void tox_options_set_experimental_thread_safety(Tox_Options* self, bool experimental_thread_safety)
479486
cdef bool tox_options_get_experimental_groups_persistence(const Tox_Options* self)
480487
cdef void tox_options_set_experimental_groups_persistence(Tox_Options* self, bool experimental_groups_persistence)
488+
cdef bool tox_options_get_experimental_disable_dns(const Tox_Options* self)
489+
cdef void tox_options_set_experimental_disable_dns(Tox_Options* self, bool experimental_disable_dns)
481490
cdef void tox_options_default(Tox_Options* self)
482491
cdef Tox_Options* tox_options_new(Tox_Err_Options_New* error)
483492
cdef void tox_options_free(Tox_Options* tox_options)
@@ -651,7 +660,6 @@ cdef extern from "tox/tox.h":
651660
cdef Tox_Group_Number tox_group_join(Tox* self, const uint8_t* chat_id, const uint8_t* name, size_t name_length, const uint8_t* password, size_t password_length, Tox_Err_Group_Join* error)
652661
cdef bool tox_group_is_connected(const Tox* self, Tox_Group_Number group_number, Tox_Err_Group_Is_Connected* error)
653662
cdef bool tox_group_disconnect(const Tox* self, Tox_Group_Number group_number, Tox_Err_Group_Disconnect* error)
654-
cdef bool tox_group_reconnect(Tox* self, Tox_Group_Number group_number, Tox_Err_Group_Reconnect* error)
655663
cdef bool tox_group_leave(Tox* self, Tox_Group_Number group_number, const uint8_t* part_message, size_t length, Tox_Err_Group_Leave* error)
656664
cdef void tox_callback_group_topic(Tox* self, tox_group_topic_cb* callback)
657665
cdef void tox_callback_group_privacy_state(Tox* self, tox_group_privacy_state_cb* callback)

pytox/toxcore/tox.pyi

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# pytox.toxcore.tox
22
from types import TracebackType
3-
from typing import Any
43
from typing import Optional
54
from typing import TypeVar
65
import enum
@@ -89,30 +88,33 @@ class Tox_Options_Ptr:
8988
def __enter__(self: T) -> T: ...
9089
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_traceback: TracebackType | None) -> None: ...
9190
def __init__(self) -> None: ...
92-
dht_announcements_enabled: Any
93-
end_port: Any
94-
experimental_groups_persistence: Any
95-
experimental_thread_safety: Any
96-
hole_punching_enabled: Any
97-
ipv6_enabled: Any
98-
local_discovery_enabled: Any
99-
proxy_host: Any
100-
proxy_port: Any
101-
proxy_type: Any
102-
savedata_data: Any
103-
savedata_type: Any
104-
start_port: Any
105-
tcp_port: Any
106-
udp_enabled: Any
91+
dht_announcements_enabled: bool
92+
end_port: int
93+
experimental_disable_dns: bool
94+
experimental_groups_persistence: bool
95+
experimental_owned_data: bool
96+
experimental_thread_safety: bool
97+
hole_punching_enabled: bool
98+
ipv6_enabled: bool
99+
local_discovery_enabled: bool
100+
proxy_host: str
101+
proxy_port: int
102+
proxy_type: Tox_Proxy_Type
103+
savedata_data: bytes
104+
savedata_type: Tox_Savedata_Type
105+
start_port: int
106+
tcp_port: int
107+
udp_enabled: bool
107108
class Tox_Proxy_Type(enum.Enum): ...
108109
class Tox_Ptr:
109110
def __enter__(self: T) -> T: ...
110111
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_traceback: TracebackType | None) -> None: ...
111112
def __init__(self, options: Optional[Tox_Options_Ptr] = None) -> None: ...
112-
address: Any
113+
def add_tcp_relay(self, host: str, port: int, public_key: bytes) -> bool: ...
114+
address: bytes
113115
def bootstrap(self, host: str, port: int, public_key: bytes) -> bool: ...
114116
def conference_by_id(self, id: bytes) -> Tox_Conference_Number: ...
115-
conference_chatlist: Any
117+
conference_chatlist: list[Tox_Conference_Number]
116118
def conference_delete(self, conference_number: Tox_Conference_Number) -> None: ...
117119
def conference_get_id(self, conference_number: Tox_Conference_Number) -> bytes: ...
118120
def conference_get_offline_peer_count(self, conference_number: Tox_Conference_Number) -> int: ...
@@ -131,8 +133,8 @@ class Tox_Ptr:
131133
def conference_send_message(self, conference_number: Tox_Conference_Number, type_: Tox_Message_Type, message: bytes) -> None: ...
132134
def conference_set_max_offline_peers(self, conference_number: Tox_Conference_Number, max_offline: int) -> None: ...
133135
def conference_set_title(self, conference_number: Tox_Conference_Number, title: bytes) -> None: ...
134-
connection_status: Any
135-
dht_id: Any
136+
connection_status: Tox_Connection
137+
dht_id: bytes
136138
def file_control(self, friend_number: Tox_Friend_Number, file_number: Tox_File_Number, control: Tox_File_Control) -> None: ...
137139
def file_get_file_id(self, friend_number: Tox_Friend_Number, file_number: Tox_File_Number) -> bytes: ...
138140
def file_seek(self, friend_number: Tox_Friend_Number, file_number: Tox_File_Number, position: int) -> None: ...
@@ -150,7 +152,7 @@ class Tox_Ptr:
150152
def friend_get_status(self, friend_number: Tox_Friend_Number) -> Tox_User_Status: ...
151153
def friend_get_status_message(self, friend_number: Tox_Friend_Number) -> bytes: ...
152154
def friend_get_typing(self, friend_number: Tox_Friend_Number) -> bool: ...
153-
friend_list: Any
155+
friend_list: list[Tox_Friend_Number]
154156
def friend_send_lossless_packet(self, friend_number: Tox_Friend_Number, data: bytes) -> None: ...
155157
def friend_send_lossy_packet(self, friend_number: Tox_Friend_Number, data: bytes) -> None: ...
156158
def friend_send_message(self, friend_number: Tox_Friend_Number, type_: Tox_Message_Type, message: bytes) -> Tox_Friend_Message_Id: ...
@@ -171,14 +173,13 @@ class Tox_Ptr:
171173
def group_kick_peer(self, group_number: Tox_Group_Number, peer_id: Tox_Group_Peer_Number) -> None: ...
172174
def group_leave(self, group_number: Tox_Group_Number, part_message: bytes) -> None: ...
173175
def group_new(self, privacy_state: Tox_Group_Privacy_State, group_name: bytes, name: bytes) -> Tox_Group_Number: ...
174-
group_number_groups: Any
176+
group_number_groups: int
175177
def group_peer_get_connection_status(self, group_number: Tox_Group_Number, peer_id: Tox_Group_Peer_Number) -> Tox_Connection: ...
176178
def group_peer_get_name(self, group_number: Tox_Group_Number, peer_id: Tox_Group_Peer_Number) -> bytes: ...
177179
def group_peer_get_public_key(self, group_number: Tox_Group_Number, peer_id: Tox_Group_Peer_Number) -> bytes: ...
178180
def group_peer_get_role(self, group_number: Tox_Group_Number, peer_id: Tox_Group_Peer_Number) -> Tox_Group_Role: ...
179181
def group_peer_get_status(self, group_number: Tox_Group_Number, peer_id: Tox_Group_Peer_Number) -> Tox_User_Status: ...
180182
def group_peer_set_role(self, group_number: Tox_Group_Number, peer_id: Tox_Group_Peer_Number, role: Tox_Group_Role) -> None: ...
181-
def group_reconnect(self, group_number: Tox_Group_Number) -> None: ...
182183
def group_self_get_name(self, group_number: Tox_Group_Number) -> bytes: ...
183184
def group_self_get_peer_id(self, group_number: Tox_Group_Number) -> Tox_Group_Peer_Number: ...
184185
def group_self_get_public_key(self, group_number: Tox_Group_Number) -> bytes: ...
@@ -237,17 +238,17 @@ class Tox_Ptr:
237238
def handle_group_voice_state(self, group_number: Tox_Group_Number, voice_state: Tox_Group_Voice_State) -> None: ...
238239
def handle_self_connection_status(self, connection_status: Tox_Connection) -> None: ...
239240
def iterate(self) -> None: ...
240-
iteration_interval: Any
241-
name: Any
242-
nospam: Any
243-
public_key: Any
244-
savedata: Any
245-
secret_key: Any
241+
iteration_interval: int
242+
name: bytes
243+
nospam: int
244+
public_key: bytes
245+
savedata: bytes
246+
secret_key: bytes
246247
def set_typing(self, friend_number: Tox_Friend_Number, typing: bool) -> None: ...
247-
status: Any
248-
status_message: Any
249-
tcp_port: Any
250-
udp_port: Any
248+
status: Tox_User_Status
249+
status_message: bytes
250+
tcp_port: int
251+
udp_port: int
251252
class Tox_Savedata_Type(enum.Enum): ...
252253
class Tox_User_Status(enum.Enum): ...
253254
ADDRESS_SIZE: int
@@ -293,6 +294,7 @@ TOX_ERR_CONFERENCE_JOIN_FAIL_SEND: Tox_Err_Conference_Join
293294
TOX_ERR_CONFERENCE_JOIN_FRIEND_NOT_FOUND: Tox_Err_Conference_Join
294295
TOX_ERR_CONFERENCE_JOIN_INIT_FAIL: Tox_Err_Conference_Join
295296
TOX_ERR_CONFERENCE_JOIN_INVALID_LENGTH: Tox_Err_Conference_Join
297+
TOX_ERR_CONFERENCE_JOIN_NULL: Tox_Err_Conference_Join
296298
TOX_ERR_CONFERENCE_JOIN_OK: Tox_Err_Conference_Join
297299
TOX_ERR_CONFERENCE_JOIN_WRONG_TYPE: Tox_Err_Conference_Join
298300
TOX_ERR_CONFERENCE_NEW_INIT: Tox_Err_Conference_New
@@ -392,6 +394,7 @@ TOX_ERR_GROUP_INVITE_ACCEPT_EMPTY: Tox_Err_Group_Invite_Accept
392394
TOX_ERR_GROUP_INVITE_ACCEPT_FAIL_SEND: Tox_Err_Group_Invite_Accept
393395
TOX_ERR_GROUP_INVITE_ACCEPT_FRIEND_NOT_FOUND: Tox_Err_Group_Invite_Accept
394396
TOX_ERR_GROUP_INVITE_ACCEPT_INIT_FAILED: Tox_Err_Group_Invite_Accept
397+
TOX_ERR_GROUP_INVITE_ACCEPT_NULL: Tox_Err_Group_Invite_Accept
395398
TOX_ERR_GROUP_INVITE_ACCEPT_OK: Tox_Err_Group_Invite_Accept
396399
TOX_ERR_GROUP_INVITE_ACCEPT_PASSWORD: Tox_Err_Group_Invite_Accept
397400
TOX_ERR_GROUP_INVITE_ACCEPT_TOO_LONG: Tox_Err_Group_Invite_Accept

0 commit comments

Comments
 (0)