123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|712|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> String problem!

Sun, 04 Jan 2009, 04:31
Afr0
Aaargh!
This is driving me nuts!
I can't figure out this one issue!

...

How would I go about finding the DisplayName parameter in an ILN command that looks like so:

ILN trid status email@addr.ess networkid displayname clientid dpobj

The problem is that DisplayName, obviously, can be of variable length and contain multiple spaces!!

So one ILN command might look like:

'ILN 5 NLN afr088@hotmail.com HELLO I ARE TEH c00lzorz!!11 454564'

While another one might look like:

'ILN 5 BSY test@msn.com TEST! 34634734'

The MSNObject parameter is optional, but I can figure out where it starts in the string because it has a 'header' of '<msnobj'.

Basically... how do I get *only* the DisplayName parameter as one single string from all this mess?!

Here's some code I've been messing with:



Edit: As you might be able to tell from this code, I am able to remove everything up to DisplayName, but I don't know how to remove what comes after it!

Edit: I don't care if you write your answer in Blitz, Python or Malbolge! Just give me some ideas... please!

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Sun, 04 Jan 2009, 05:06
Jayenkai
ILN trid status
"ILN 5 NLN"
email@addr.ess
"afr088@hotmail.com"
networkid
?
displayname
"HELLO I ARE TEH c00lzorz!!11"
clientid
454564
dpobj
?

According to here... You're actually using the topmost "ILN" message type. The "MSNP14" is the one with the other two bits of info.
Now, assuming you're only working with ILN, it's easy.
The first few bits you know.. They're structured as they should be. The last bit is the ID number, everything inbetween is the person's name.
Assume that, first..

You have "Left data", (What you can get already) "Possible Display Name" (the chunky middle bit) and "Right data" (last bit.)

What you'll have to do, is figure out what format "dpobj" should be in, and check if "Right Bit" = "A client ID or a possible dpobj".. This'll help

If it is a possible dpobj, then use Right Data as DPObj, and then take off the rightmost bit from "Possible Display Name" and assume that's the Client ID.. (should be a number!)
Next, take the leftmost bit from "Possible Display Name" and assume that's network ID.. (should be a single digit, according to the link above)
And whatever's left inside "Possible Display Name" will more than likely be the person's display name..

-=-=-
''Load, Next List!''
Sun, 04 Jan 2009, 09:10
Afr0
Hmmm, well, I did some testing and wrote this:



It doesn't work very well. First of all it absolutely requires that the ILN command contains an MSN Object (DPObject - Display Picture Object), and it doesn't seem to return the data I want in 9 out of 10 cases because the TmpStr can be apparently have way too many values (I.E it could be '567 <ms' or '8 <msnob').

Jay, I'm not working with MSNP14. I'm working with MSNP9, which has the MSNObject, but not the NetworkID. MSN Objects were first introduced in MSNP9.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Sun, 04 Jan 2009, 09:26
Jayenkai
Oh, ok.. I just googled the thing.. I haven't a clue what it is you're using

um.. <shrugs>

-=-=-
''Load, Next List!''
Sun, 04 Jan 2009, 09:47
Afr0
The MSNObject looks like:



Put that together with the ILN and you get:



-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Sun, 04 Jan 2009, 10:03
Scherererer
Why don't you work backwards: find the part that says

and then track back two spaces to get the big number. Then everything between the e-mail address and the number is that other set of words, and you're good to go.

-=-=-
YouTube Twitter
Computer Science Series: Logic (pt1) (part 2) (part 3) 2's Complement Mathematics: Basic Differential Calculus
Sun, 04 Jan 2009, 10:46
Afr0
How do I track backwards, though? I can't use string.Remove to start from the end of the string, can I?

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Sun, 04 Jan 2009, 12:01
Scherererer
I'm saying combine stuff like string.Substring(), string.IndexOf(), and string.LastIndexOf()

-=-=-
YouTube Twitter
Computer Science Series: Logic (pt1) (part 2) (part 3) 2's Complement Mathematics: Basic Differential Calculus
Sun, 04 Jan 2009, 12:27
Afr0
That's what I've been doing, and can't figure it out!! :\

Edit:

I changed Test() to this:



That's a good start. Now I just have to remove ClientID.
Then I have to meditate on wtf happens if the server decides to *not* send an <msnobj> for some God-forsaken reason.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Sun, 04 Jan 2009, 13:14
Phoenix
I'd just take the easy way out and use regular expressions. Always work perfectly when parsing text like this.

To match this: 'ILN 5 NLN afr088@hotmail.com HELLO I ARE TEH c00lzorz!!11 454564'

You could probably write two regexes (haven't tested these), and then capture the string between their first capture groups' indexes.

1. [^@]+[@a-zA-Z\.]\s(.)
2. (.)\s\d+$

These two regexes (should) match the parts outside of the name you want. So, assuming you're using C#'s standard System.Text.RegularExpressions functionality, you'd write something like this (also untested):



There's probably an easier way, but tell me if it works Don't really have access to a real computer (stupid Macintosh...) so I can't test.
Sun, 04 Jan 2009, 21:18
Afr0


I did like this. It didn't work. I also tried to search within DecodedILN. It didn't work either! But I think you're right - regular expressions are the way to go.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Mon, 05 Jan 2009, 04:56
Phoenix
Well I actually meant that you should just insert the whole string in there, not just the part after the email address. But if you can trim it down to that part then you only need the second regex. I modified your code:


Mon, 05 Jan 2009, 12:57
Afr0
Bah. Regex didn't work, and I couldn't figure out how to get any matches, even though I downloaded RegexBuddy.
Thus, I made this hackery:



I'd still appreciate help, even if it's in the form of a Regex expression that actually works!

Edit: Turns out, ILNs that don't contain an MSNObject have a trailing 0 at the end. Probably to indicate that there isn't an MSNObject.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Mon, 05 Jan 2009, 13:31
Phoenix
It does work. I tried it two seconds ago. Removed dot to make it slightly shorter, but worked otherwise as well.


Mon, 05 Jan 2009, 13:50
Afr0
Well, I'll be...! o_O
Didn't seem to work in my program!
I guess I'll have to try and see if I can make it work tommorrow.

Offtopic:



w00t! Presence changes underway!

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!