Browse Source

We now can detect if a message belongs to the logged user

master
Julio Biason 15 years ago
parent
commit
32378533bc
  1. 6
      mitterlib/network/__init__.py
  2. 6
      mitterlib/network/networkbase.py
  3. 8
      mitterlib/network/twitter.py

6
mitterlib/network/__init__.py

@ -148,6 +148,12 @@ class Networks(object):
raise NetworksNoSuchNetworkError(shortcut) raise NetworksNoSuchNetworkError(shortcut)
return name return name
def is_self(self, message):
"""Return True if the message belongs to the logged user."""
if self.networks[message.network].username() == message.username:
return True
return False
# This is basically a copy of all methods available in NetworkBase, with # This is basically a copy of all methods available in NetworkBase, with
# the additional parameter "network" (to request data from just one # the additional parameter "network" (to request data from just one
# source) # source)

6
mitterlib/network/networkbase.py

@ -188,6 +188,12 @@ class NetworkBase(object):
this function.""" this function."""
return False return False
def username(self):
"""Return the username of the logged user. This is used by the
interfaces to check if the message belongs to the logged user or
someone else."""
return ''
def messages(self): def messages(self):
"""Return a list of :class:`NetworkData` objects for the main """Return a list of :class:`NetworkData` objects for the main
"timeline" (the default list presented to the user.)""" "timeline" (the default list presented to the user.)"""

8
mitterlib/network/twitter.py

@ -144,6 +144,13 @@ class Connection(NetworkBase):
else: else:
return False return False
def username(self):
"""Return the username of the logged user on Twitter."""
username = self._options[self.NAMESPACE]['username']
if not username:
return ''
return username
def __init__(self, options): def __init__(self, options):
self._options = options self._options = options
@ -293,6 +300,7 @@ class Connection(NetworkBase):
high_id = 0 high_id = 0
while response: # Not the cleanest code while response: # Not the cleanest code
# TODO: How the interfaces can interrupt this?
if page > 1: if page > 1:
params['page'] = page params['page'] = page

Loading…
Cancel
Save