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

@ -147,6 +147,12 @@ class Networks(object):
except KeyError:
raise NetworksNoSuchNetworkError(shortcut)
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
# the additional parameter "network" (to request data from just one

6
mitterlib/network/networkbase.py

@ -187,6 +187,12 @@ class NetworkBase(object):
:class:`Networks` won't send requests to networks that return False to
this function."""
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):
"""Return a list of :class:`NetworkData` objects for the main

8
mitterlib/network/twitter.py

@ -143,6 +143,13 @@ class Connection(NetworkBase):
return True
else:
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):
self._options = options
@ -293,6 +300,7 @@ class Connection(NetworkBase):
high_id = 0
while response: # Not the cleanest code
# TODO: How the interfaces can interrupt this?
if page > 1:
params['page'] = page

Loading…
Cancel
Save