Advertisement
ereinion

Parsing the clan log

Dec 11th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void stash_info(buffer ClanLog) {
  2.     string the_date; string the_time; string player_name; string player_id; string action; string amount; string item_handled;
  3.    
  4.     int start_of_stash_activity = index_of(ClanLog, "Stash Activity") + 55;
  5.     int end_of_stash_activity = index_of(ClanLog, "Miscellaneous:", start_of_stash_activity);
  6.    
  7.     string stash_activity = substring(ClanLog, start_of_stash_activity, end_of_stash_activity);
  8.    
  9.     string pattern = ">(\\d{2}/\\d{2}/\\d{2}), (\\d{2}:\\d{2}[AaPp][Mm]): <a class=nounder href='showplayer\\.php\\?who=[\\d]+'>([a-zA-Z0-9\\-\\_\\ ]+) \\(#(\\d+)\\)<\\/a> (added|took|contributed) (\\d+) (.+?)\\.<br";
  10.     matcher m_stash_put = create_matcher(pattern, stash_activity);
  11.    
  12.     print_html("<font color=0000FF>Build matcher</font>");
  13.     int i = 0;
  14.     while(i < 5)//test only 5 iterations
  15.     {
  16.         print_html("<font color=0000FF>Find</font>");
  17.         if (m_stash_put.find()) {
  18.             i=i+1;
  19.             the_date = m_stash_put.group(1);
  20.             the_time = m_stash_put.group(2);
  21.             player_name = m_stash_put.group(3);
  22.             player_id = m_stash_put.group(4);
  23.             action = m_stash_put.group(5);
  24.             amount = m_stash_put.group(6);
  25.             item_handled = m_stash_put.group(7);
  26.  
  27.             print_html("<font color=008000>" + player_name + " (#" + player_id + ") " + action + " " + amount + " " + item_handled + " on " + the_date + " at " + the_time + ".</font>");
  28.             print_html("<font color=008000>" + m_stash_put.group(0) + "</font>");
  29.         }
  30.     }
  31. }
  32.  
  33. void whitelist_info(buffer ClanLog) {
  34.     string the_date; string the_time; string player_name; string player_id; string action;
  35.    
  36.     int start_of_comings_and_goings = index_of(ClanLog, "Comings and Goings") + 60;
  37.     int end_of_comings_and_goings = index_of(ClanLog, "Stash Activity", start_of_comings_and_goings);
  38.    
  39.     string comings_and_goings = substring(ClanLog, start_of_comings_and_goings, end_of_comings_and_goings);
  40.    
  41.     string pattern = ">(\\d{2}/\\d{2}/\\d{2}), (\\d{2}:\\d{2}[AaPp][Mm]): ([a-zA-Z0-9\\-\\_\\ ]+) \\(#(\\d+)\\) (joined another clan|was accepted into the clan)";
  42.     matcher m_stash_put = create_matcher(pattern, comings_and_goings);
  43.    
  44.     print_html("<font color=0000FF>Build matcher</font>");
  45.     int i = 0;
  46.     while(i < 5)//test only 5 iterations
  47.     {
  48.         print_html("<font color=0000FF>Find</font>");
  49.         if (m_stash_put.find()) {
  50.             player_name = m_stash_put.group(3);
  51.             if (player_name != "Easyfax" && player_name != "CheeseFax") {
  52.                 i=i+1;
  53.                 the_date = m_stash_put.group(1);
  54.                 the_time = m_stash_put.group(2);
  55.                 player_id = m_stash_put.group(4);
  56.                 action = m_stash_put.group(5);
  57.                
  58.                 if (action.contains_text("accepted")) {
  59.                     print_html("<font color=008000>" + player_name + " (#" + player_id + ") joined the clan.</font>");
  60.                 } else if (action.contains_text("joined")) {
  61.                     print_html("<font color=008000>" + player_name + " (#" + player_id + ") left the clan.</font>");
  62.                 } else {
  63.                     print_html("<font color=FF0000>" + action + "</font>");
  64.                 }
  65.                 print_html("<font color=008000>" + m_stash_put.group(0) + "</font>");
  66.             }
  67.         }
  68.     }
  69. }
  70.  
  71. void main() {
  72.     buffer ClanLog = visit_url("clan_log.php");
  73.    
  74.     whitelist_info(ClanLog);
  75.     #stash_info(ClanLog);
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement