Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
fantawttw #1
Member since Aug 2005 · 8 posts
Group memberships: Members
Show profile · Link to this post
Subject: GTalk Bot Auto Unsubscribe Problem
Hi,
I am developing a GTALK bot in vb.net and have got it auto subscribing and responding to commands, however I cannot get it to auto UNsubscribe.
I check the incomming chat for a keyword to unsubscribe the user. I then issue the command xmpp.PresenceManager.RefuseSubscriptionRequest(msg.from) however GTalk is returning the following error

<presence xmlns="jabber:client" type="error" to="xxx@gmail.com/JonJab2F3C2F99" from="xxx@gmail.com/Talk.v722F1ADDBF"><error code="400" type="modify"><jid-malformed xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Must subscribe to bare JID</text></error></presence>

I have tried to use the .bare however this returns a string and I am receiveing a .net error saying that a string cannot be converted to agsXMPP.Jid

Here is a code snippet of the code I am using
Private Sub xmpp_OnMessage(ByVal sender As Object, ByVal msg As
agsxmpp.protocol.client.Message)
If msg.Body.StartsWith(&quot;9&quot;) Then
xmpp.PresenceManager.RefuseSubscriptionRequest(msg.From)
End If
End Sub
If I add .bare to msg.from I get the .net error regarding conversion.

Do you know of a way of returning the bare jid as a jid

I have even tried cType(msg.From.bare,agsXMPP.Jid) but again this to fails.

Many Thanks in Advance.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hi,

for subscription and Roster managment you have to use always bare jids.

The RefuseSubscriptionRequest is if somebody want to subscribe to your presence, and you dont want to accept this.

Yuu have to ise the unsubscribe Method to remove the subscription.

Alex
Avatar
fantawttw #3
Member since Aug 2005 · 8 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex,
Thanks for the prompt reply. I have used the Unsubscribe method however I think it must be a quirk of GTalk because if you send the Unsubscribe it will still allow you to see the status of the bot and still allow the sending of messages. I will look a bit more into it and see if I can spot anything in the XML Debug code.

Regards
Jon
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
did you remove the rosteritem before unsubscribing from the roster?
Normally you first remove the rosteritem, and then cancel the subscription.
The scenario is described here in the RFC's
http://www.xmpp.org/specs/rfc3921.html#int-remove

Alex
Avatar
fantawttw #5
Member since Aug 2005 · 8 posts
Group memberships: Members
Show profile · Link to this post
Hi,
Many thanks I have now got it working using the following code

Dim riq As RosterIq = New RosterIq
riq.Type = IqType.Set
xmpp.RosterManager.RemoveRosterItem(New Jid(msg.From.Bare))

Regards,

Jon
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
what are you doing with the first 2 lines in your code?
I dont think you need them.

Alex
Avatar
fantawttw #7
Member since Aug 2005 · 8 posts
Group memberships: Members
Show profile · Link to this post
Your right I don't need them. I have removed them from my code and all is still working fine.

Jon
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS