From 37541db07ddf8342cd1087a1b67c8fbb3dc6e702 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sun, 5 Aug 2018 16:33:51 +0300 Subject: [PATCH] bans - wrapper --- toxygen/contacts/group_chat.py | 7 ++----- toxygen/wrapper/tox.py | 16 ++++++++++------ toxygen/wrapper/toxcore_enums_and_consts.py | 11 +++++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/toxygen/contacts/group_chat.py b/toxygen/contacts/group_chat.py index b38e538..e89b561 100644 --- a/toxygen/contacts/group_chat.py +++ b/toxygen/contacts/group_chat.py @@ -11,16 +11,13 @@ class GroupChat(contact.Contact, ToxSave): def __init__(self, tox, profile_manager, message_getter, number, name, status_message, widget, tox_id, is_private): super().__init__(profile_manager, message_getter, number, name, status_message, widget, tox_id) ToxSave.__init__(self, tox) + self._is_private = is_private - self._password = None + self._password = str() self._peers_limit = 512 self._peers = [] self._add_self_to_gc() - def set_topic(self, topic): - self._tox.group_set_topic(self._number, topic.encode('utf-8')) - super().set_status_message(topic) - def remove_invalid_unsent_files(self): pass diff --git a/toxygen/wrapper/tox.py b/toxygen/wrapper/tox.py index ebb6aee..0e3310d 100644 --- a/toxygen/wrapper/tox.py +++ b/toxygen/wrapper/tox.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -from ctypes import c_char_p, Structure, c_bool, byref, c_int, c_size_t, POINTER, c_uint16, c_void_p, c_uint64 -from ctypes import create_string_buffer, ArgumentError, CFUNCTYPE, c_uint32, sizeof, c_uint8 +from ctypes import * from wrapper.toxcore_enums_and_consts import * from wrapper.toxav import ToxAV from wrapper.libtox import LibToxCore @@ -109,7 +108,6 @@ class Tox: self.group_invite_cb = None self.group_custom_packet_cb = None self.group_private_message_cb = None - self.group_private_message_cb = None self.group_message_cb = None self.group_password_cb = None self.group_peer_limit_cb = None @@ -2393,7 +2391,7 @@ class Tox: result = Tox.libtoxcore.tox_group_mod_set_role(self._tox_pointer, group_number, peer_id, role, byref(error)) return result - def group_mod_remove_peer(self, group_number, peer_id, set_ban): + def group_mod_remove_peer(self, group_number, peer_id): """ Kick/ban a peer. @@ -2403,14 +2401,20 @@ class Tox: :param group_number: The group number of the group the ban is intended for. :param peer_id: The ID of the peer who will be kicked and/or added to the ban list. - :param set_ban: Set to true if a ban shall be set on the peer's IP address. :return True on success. """ error = c_int() result = Tox.libtoxcore.tox_group_mod_remove_peer(self._tox_pointer, group_number, peer_id, - set_ban, byref(error)) + byref(error)) + return result + + def group_mod_ban_peer(self, group_number, peer_id, ban_type): + + error = c_int() + result = Tox.libtoxcore.tox_group_mod_ban_peer(self._tox_pointer, group_number, peer_id, + ban_type, byref(error)) return result def group_mod_remove_ban(self, group_number, ban_id): diff --git a/toxygen/wrapper/toxcore_enums_and_consts.py b/toxygen/wrapper/toxcore_enums_and_consts.py index 4d09338..7c6478c 100644 --- a/toxygen/wrapper/toxcore_enums_and_consts.py +++ b/toxygen/wrapper/toxcore_enums_and_consts.py @@ -911,6 +911,17 @@ TOX_ERR_GROUP_BAN_QUERY = { 'TOX_ERR_GROUP_BAN_QUERY_BAD_ID': 2, } + +TOX_GROUP_BAN_TYPE = { + + 'TOX_GROUP_BAN_TYPE_IP_PORT': 0, + + 'TOX_GROUP_BAN_TYPE_PUBLIC_KEY': 1, + + 'TOX_GROUP_BAN_TYPE_NICK': 2 + +} + TOX_PUBLIC_KEY_SIZE = 32 TOX_ADDRESS_SIZE = TOX_PUBLIC_KEY_SIZE + 6