Thread

Posted on Fri Feb 17 19:48:16 2006 by plasma2002
A few function ideas
Heya grant.... ive been implementing that AIM bot with your MySpace module, and ive put in a few things that i needed, and they seem like they would be a great addition to the myspace module itself.

One thing i have is just a get_top_8() function. Easily enough it just uses get_page and get_friends_on_page to get the top 8 off the users homepage. But there was always those two 'cool new profiles' that show up, so what i did was just do an index() of the page-content to get the info of where the string 'My Friend Space' occured, which is where it starts listing your top 8.

Also, there is no immediate way to tell if you used a correct username and password when initiating the myspace class. This wouldnt be a problem if you would be using one account for all your stuff, but my bot lets people register with their myspace accounts, so i needed a way to tell if they had logged in correctly or not. I made a quick workaround that simply checks to see if i can get $myspace-my_friend_id or not. If we get a number bigger than 0, the it was a successfull login, if not, then for some reason my_friend_id equals 'L' (haha, dont know what thats all about, but hey), then that means we got a bad login name or password.
So yeah.... it would be cool if when initiating the class, it could return an error code, or set a variable, or halt, or something like that :)


myspace_stats() is another one thats pretty handy. I let people call this function by sending the phrase -stats to my bot, and on doing so, the bot logs in and reads the homepage and looks for these constants:

our $NEW_MESSAGES='<span class="redtext">[Nn]ew [Mm]essages!</span>'; our $NEW_COMMENTS='<font color="0000FF">[Nn]ew [Cc]omments!</font>'; our $NEW_PIC_COMMENTS='<font color="0000FF">[Nn]ew [Pp]icture [Cc]omments!</font>';


It then replies to the sender telling him the status of his account. I dont know if this would neccessarily be a function that would be worth implementing into the myspace class, but just sharing what im doing with it :)




post_bulletin() !!! This one should definately get put in though, lol. This is by far the most popular thing people use my bot for right now. They love the fact that they can just send a message and it will be posted to their bulletin for them. The function itself is almost a mirror image of your post_comment() function. Thats what i used as the skeleton to make it. (i think... but it might have been the send_message function, i dont know).... anyways... it jsut submits text using the submit_form function and then confirms it on the next screen. I would post code, but its kinda sloppy and doesnt keep with the standard of the class, heh.



Anyways.... just thought i would throw in some of the things im using your class for :) I know you were asking about that bot, if ya want to check out some of the commands or what all it does so far, go to the page i set up for its database access at http://schwippy.com/bot
Direct Responses: 1819 | Write a response
Posted on Sat Feb 18 07:03:19 2006 by grantg in response to 1818
Re: A few function ideas

Good ideas there. I have a Dashboard module that does the same function as myspace_stats, but I think including it in WWW::Myspace would be a good idea.

Could you post each of these methods to the bug tracking system so they don't get lost? If you could post code for each (or a patch if you've modified the module itself) I can clean up anything that needs cleaning. :)

Also, I had some ideas about the mail-handling methods if you get inspired. I think the following methods should be in the WWW::Myspace module itself:


- read_message: Passed a message ID, it returns the friend_id of the sender, the subject, and body of the message.
-reply_to: Passed a message ID and a message, it replies to the message, placing the reply message at the top of the new message. Note that this method would have to actually load the message form and "click" the "Reply" button so that myspace would properly show that the message was "Replied" to.
- inbox (or "get_messages"): Returns a list of the message IDs in the inbox.
- optional methods (or modifications): A method to return a list of message IDs, and each message's sender (friendID), status (Read, Replied, Unread, Sent(?)), and possibly subject.

I should probably add this into the bug tracking system too. :) In fact, I'll do that now.

Write a response