Results 1 to 8 of 8

Thread: Help with a script

  1. #1
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    181

    Default Help with a script

    PHP Code:
    void main()
    {
    string [stringsave_data;
    string log visit_url("lchat.php");

    string player_list;
    foreach 
    player in who_clan() {
        
    chat_clan("/whois " +player);
        if(
    log.contains_text("This player is currently away from KoL"));
        {print(
    "This player is away");}
        if(
    log.contains_text("This player is currently online"));
        {print(
    "This player is online");}
       if(
    length(player_list) > 0)
          
    player_list += ", ";
       
    player_list += player;

    here's my output:
    Code:
    PazSox (#352918), the Level 9 Seal Clubber (In Ronin)
    This player is currently online in channel clan.
    
    Listening to Events, Incoming from: saying: PazSox (#352918), the Level 9 Seal Clubber (In Ronin)This player is currently online in channel clan.
    This player is away
    This player is online
    I get this for each player currently online, regardless of away or not.

    Anyone have any suggestions?

  2. #2

    Default

    You aren't doing anything with that /whois, you're repeatedly checking the results from lchat.php. Which probably has a bunch of javascript with all the text you're checking for.

  3. #3
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    181

    Default

    So how can I go about doing what I'm trying to do?

  4. #4
    Senior Member Theraze's Avatar
    Join Date
    Mar 2010
    Posts
    8,702

    Default

    Well, what do you get when you look at the text from lchat? Once you have that, you can use split_string to break the text into segments, and then you can use a proper regexp matcher to see which users are away.

  5. #5
    Developer
    Join Date
    Aug 2009
    Posts
    2,664

    Default

    You recognize why that's not working, right? You're ending your if statements with the semicolons. You then have each print statement in a separate block that executes unconditionally.

    On top of that, you're not reloading lchat.php between iterations of the loop, which isn't even what you want in the first place -- lchat uses submitnewchat.php to send that request (and retrieve the corresponding response). And, to top it off, to prevent people from writing spammy chatbots, that URL (along with newchatmessages.php) are banned for use in scripts.

    You have a chatbotScript set, per the line "Listening to Events, Incoming from: saying: ...". If you're going to do parsing of this sort, it'll have to be in there.

  6. #6
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    181

    Default

    You recognize why that's not working, right? You're ending your if statements with the semicolons. You then have each print statement in a separate block that executes unconditionally.

    You have a chatbotScript set, per the line "Listening to Events, Incoming from: saying: ...". If you're going to do parsing of this sort, it'll have to be in there.
    Originally Posted by heeheehee View Post
    I see. I'll play around with it.

    Once I figure it out, I'll have to figure out how to remove said "away" player from the list of online players, so I can PM the list of "active" players.

  7. #7
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,263

    Default

    Once I figure it out, I'll have to figure out how to remove said "away" player from the list of online players, so I can PM the list of "active" players.
    Originally Posted by Pazleysox View Post
    I'd recommend putting them in a map with values of true and false. (True is active and false is inactive.) The comma separated list is awkward for internal purposes, so just make an output function which you send a map and have it turn that into a comma separated list to print.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  8. #8
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    181

    Default

    I'd recommend putting them in a map with values of true and false. (True is active and false is inactive.) The comma separated list is awkward for internal purposes, so just make an output function which you send a map and have it turn that into a comma separated list to print.
    Originally Posted by Bale View Post
    I've been thinking along those lines. I have codes that do parts of what I need. I just need to look at them, and try to figure out to get the pieces I need.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •