Shows a notification when someone is onlyne or offline
This commit is contained in:
parent
2d60e2b461
commit
c747be2743
@ -17,8 +17,6 @@ class worker(threading.Thread):
|
|||||||
if event.type == VkEventType.MESSAGE_NEW:
|
if event.type == VkEventType.MESSAGE_NEW:
|
||||||
pub.sendMessage("order-sent-message", obj=event)
|
pub.sendMessage("order-sent-message", obj=event)
|
||||||
elif event.type == VkEventType.USER_ONLINE:
|
elif event.type == VkEventType.USER_ONLINE:
|
||||||
print "User online"
|
pub.sendMessage("user-online", event=event)
|
||||||
print event.user_id
|
|
||||||
elif event.type == VkEventType.USER_OFFLINE:
|
elif event.type == VkEventType.USER_OFFLINE:
|
||||||
print "User offline"
|
pub.sendMessage("user-offline", event=event)
|
||||||
print event.user_id
|
|
@ -135,6 +135,8 @@ class Controller(object):
|
|||||||
pub.subscribe(self.chat_from_id, "new-chat")
|
pub.subscribe(self.chat_from_id, "new-chat")
|
||||||
pub.subscribe(self.authorisation_failed, "authorisation-failed")
|
pub.subscribe(self.authorisation_failed, "authorisation-failed")
|
||||||
pub.subscribe(self.user_profile, "user-profile")
|
pub.subscribe(self.user_profile, "user-profile")
|
||||||
|
pub.subscribe(self.user_online, "user-online")
|
||||||
|
pub.subscribe(self.user_offline, "user-offline")
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.CLOSE_EVENT, self.exit)
|
widgetUtils.connect_event(self.window, widgetUtils.CLOSE_EVENT, self.exit)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.update_buffer, menuitem=self.window.update_buffer)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.update_buffer, menuitem=self.window.update_buffer)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_for_updates, menuitem=self.window.check_for_updates)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_for_updates, menuitem=self.window.check_for_updates)
|
||||||
@ -172,6 +174,8 @@ class Controller(object):
|
|||||||
pub.unsubscribe(self.play_audios, "play-audios")
|
pub.unsubscribe(self.play_audios, "play-audios")
|
||||||
pub.unsubscribe(self.view_post, "open-post")
|
pub.unsubscribe(self.view_post, "open-post")
|
||||||
pub.unsubscribe(self.update_status_bar, "update-status-bar")
|
pub.unsubscribe(self.update_status_bar, "update-status-bar")
|
||||||
|
pub.unsubscribe(self.user_online, "user-online")
|
||||||
|
pub.unsubscribe(self.user_offline, "user-offline")
|
||||||
|
|
||||||
def authorisation_failed(self):
|
def authorisation_failed(self):
|
||||||
commonMessages.bad_authorisation()
|
commonMessages.bad_authorisation()
|
||||||
@ -369,6 +373,16 @@ class Controller(object):
|
|||||||
if setfocus: buffer.tab.text.SetFocus()
|
if setfocus: buffer.tab.text.SetFocus()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def user_online(self, event):
|
||||||
|
user_name = self.session.get_user_name(event.user_id, "nom")
|
||||||
|
msg = _(u"{0} is online.").format(user_name,)
|
||||||
|
self.window.notify(_("Socializer"), msg)
|
||||||
|
|
||||||
|
def user_offline(self, event):
|
||||||
|
user_name = self.session.get_user_name(event.user_id, "nom")
|
||||||
|
msg = _(u"{0} is offline.").format(user_name,)
|
||||||
|
self.window.notify(_("Socializer"), msg)
|
||||||
|
|
||||||
def get_chat(self, obj=None):
|
def get_chat(self, obj=None):
|
||||||
""" Searches or creates a chat buffer with the id of the user that is sending or receiving a message.
|
""" Searches or creates a chat buffer with the id of the user that is sending or receiving a message.
|
||||||
obj vk_api.longpoll.EventType: an event wich defines some data from the vk's long poll server."""
|
obj vk_api.longpoll.EventType: an event wich defines some data from the vk's long poll server."""
|
||||||
|
Loading…
Reference in New Issue
Block a user