This commit is contained in:
ingvar1995 2016-06-27 17:08:07 +03:00
parent 8b7fe560b7
commit 99007aa8fd
2 changed files with 18 additions and 6 deletions

View File

@ -9,6 +9,7 @@ class CopyableToxId(plugin_super_class.PluginSuperClass):
super(CopyableToxId, self).__init__('CopyableToxId', 'toxid', *args) super(CopyableToxId, self).__init__('CopyableToxId', 'toxid', *args)
self._data = json.loads(self.load_settings()) self._data = json.loads(self.load_settings())
self._copy = False self._copy = False
self._curr = -1
self._timer = QtCore.QTimer() self._timer = QtCore.QTimer()
self._timer.timeout.connect(lambda: self.timer()) self._timer.timeout.connect(lambda: self.timer())
self.load_translator() self.load_translator()
@ -43,7 +44,7 @@ class CopyableToxId(plugin_super_class.PluginSuperClass):
def lossless_packet(self, data, friend_number): def lossless_packet(self, data, friend_number):
if len(data): if len(data):
self._data['id'] = filter(lambda x: not x.startswith(data[:64]), self._data['id']) self._data['id'] = list(filter(lambda x: not x.startswith(data[:64]), self._data['id']))
self._data['id'].append(data) self._data['id'].append(data)
if self._copy: if self._copy:
self._timer.stop() self._timer.stop()
@ -64,7 +65,17 @@ class CopyableToxId(plugin_super_class.PluginSuperClass):
def timer(self): def timer(self):
self._copy = False self._copy = False
self.error() if self._curr + 1:
public_key = self._tox.friend_get_public_key(self._curr)
self._curr = -1
arr = list(filter(lambda x: x.startswith(public_key), self._data['id']))
if len(arr):
clipboard = QtGui.QApplication.clipboard()
clipboard.setText(arr[0])
else:
self.error()
else:
self.error()
self._timer.stop() self._timer.stop()
def friend_connected(self, friend_number): def friend_connected(self, friend_number):
@ -101,12 +112,13 @@ help: show this help""", None, QtGui.QApplication.UnicodeUTF8)
else: else:
return return
public_key = self._tox.friend_get_public_key(num) public_key = self._tox.friend_get_public_key(num)
arr = filter(lambda x: x.startswith(public_key), self._data['id']) arr = list(filter(lambda x: x.startswith(public_key), self._data['id']))
if len(arr): if self._profile.get_friend_by_number(num).status is None and len(arr):
clipboard = QtGui.QApplication.clipboard() clipboard = QtGui.QApplication.clipboard()
clipboard.setText(arr[0]) clipboard.setText(arr[0])
elif self._profile.get_friend_by_number(num).status is not None: elif self._profile.get_friend_by_number(num).status is not None:
self._copy = True self._copy = True
self._curr = num
self.send_lossless('', num) self.send_lossless('', num)
self._timer.start(2000) self._timer.start(2000)
else: else:

View File

@ -50,10 +50,10 @@ class MarqueeStatus(plugin_super_class.PluginSuperClass):
def set_status_message(self): def set_status_message(self):
message = self._profile.status_message message = self._profile.status_message
self._profile.set_status_message(message[1:] + message[0]) self._profile.set_status_message(bytes(message[1:] + message[0], 'utf-8'))
def init_status(self): def init_status(self):
self._profile.status_message = self._profile.status_message.strip() + ' ' self._profile.status_message = bytes(self._profile.status_message.strip() + ' ', 'utf-8')
def change_status(self): def change_status(self):
self.active = True self.active = True