On 26/04/2006, at 1:08 AM, Alexey Nezhdanov wrote:
> Hello.
> I have old question in a bit different form.
> Description:
> MSN requires users to have auth before sending messages.
> I.e. I can't just send message to some random user [EMAIL PROTECTED]
> First I should send <presence type='subscribe'
> to='[EMAIL PROTECTED]'/>,
> wait for user to authorise me and send only then.
> This works not so stable but still usable when used personally.
> Though when it comes to writing automated program this unreliability
> becomes a
> problem.
> F.e.: I need to write script that will randomly chat with thousands of
> different MSN contacts (not spim - it will be dialogs for several
> minutes
> each). To not clobber jabber's and MSN's rosters I choosed to do the
> following:
> 1) send "subscribe"
> 2) wait for "subscribed"
> 3) chat
> 4) remove item from roster
> That way appeared to be not good because of two problems:
> a) chatting with same contact lately becomes a problem - it seems that
> step
> (4) sets the user as "blocked" but step (1) not removes the block
> b) Typing notifications _from_ MSN not work. The interesting thing is
> if we
> stop script somewhere in step (3) then on next start it sees contact as
> online and TN starting to work.
>
> Question:
> If there is some recipe to achieve my task?
> I'l shortly reevaluate:
> I need the reliable (doh!) way to chat with MSN contact using TNs and
> not
> keeping this contact constantly in roster.
> --
> Respectfully
> Alexey Nezhdanov
Can you tell me if applying this patch fixes your problem please?
Whenever a user sends <presence type="subscribe"/> to a contact, it
will unblock it (if its blocked), and that contact will send you a
<presence type="subscribe"/> if the contact still has the user on their
list.
Hope that makes sense. Try it out :)
Wrt the typing notifications. They should work as soon as ordinary
messages can be exchanged.
Note that typing notifications are only exchanged after the first
message has been sent.
---
James
Index: src/legacy/glue.py
===================================================================
--- src/legacy/glue.py (revision 137)
+++ src/legacy/glue.py (working copy)
@@ -560,6 +560,12 @@
LogEvent(INFO, self.jabberID)
userHandle = jid2msn(jid)
self.session.legacycon.addContact(msn.FORWARD_LIST,
userHandle)
+
+ # Handle adding a contact that has previously been
removed
+ msnContact =
self.session.legacycon.getContacts().getContact(userHandle)
+ self.session.legacycon.remContact(msn.BLOCK_LIST, jid)
+ if msnContact.lists & msn.REVERSE_LIST:
+
self.session.legacycon.contactAddedMe(userHandle)
self.session.contactList.getContact(jid).contactGrantsAuth()
def removeContact(self, jid):