OGame Automizer Development Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome on the OGame Automizer Development/Support Forum

If this is your first visit, be sure to check out the
http://ogameautomizer.com/doc/manual.html : A guide written by OA users with consultation of OA author (En)

http://ogameautomizer.com/doc/manual_de.html : A guide written by OA users with consultation of OA author (Benutzerschnittstellenhandbuch) (GE)

http://ogameautomizer.com/doc/scripting_manual.html : OA Scripting Manual (En)

Pages: 1 2 [3] 4 5 ... 7

Author Topic: Send E-Mail if Player send you a Message * UPDATE 3.0 * 18-7-2012  (Read 27293 times)

0 Members and 1 Guest are viewing this topic.

Zebra

  • Full Member
  • ***
  • Offline Offline
  • Posts: 212
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #30 on: June 11, 2012, 08:53:00 PM »

DH, any ideas? Seems to be a problem parsing the message contents. Esp when the messages are replies to and from.
Logged

Zebra

  • Full Member
  • ***
  • Offline Offline
  • Posts: 212
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #31 on: June 11, 2012, 09:04:46 PM »

How do we parse only the first part of the message i.e. the last response and not the previous convo in a message? That should solve this problem.
Logged

asdasd

  • Full Member
  • ***
  • Offline Offline
  • Posts: 231
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #32 on: June 11, 2012, 09:23:57 PM »

always

Script uni****.ogame.**** ---------- has been stopped, Throwable: No match available
Logged

chronos001

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #33 on: June 11, 2012, 09:46:33 PM »

I have see in reply message there is many tags for text like:
Other, Note, text, own etc...

See this:
Quote
Subject: RE:RE:bravo
Text: colpa mia, la sonda si è tritata e si è confusa ltra le spiate e  gli attacchi andati a buon fine</p><p class="info"><span class="name"><span>PLAYER</span></span> <span class="date">11.06.2012 16:02:15</span></p><p class="own">Io la sonda te l'ho mandata per farti vedere che ci stavo... se te non la caghi non è colpa mia.... ;-)</p><p class="info"><span class="name"><span>XXX</span></span> <span class="date">11.06.2012 15:47:04</span></p><p class="other">complimenti

Text TAG need more accuracy parsing for Reply messages... asap I check all... :o

@Zebra: Yes good idea... I parse only from first tag to first "</p>".... yes I think too this solve all problem...
« Last Edit: June 11, 2012, 09:50:13 PM by chronos001 »
Logged

chronos001

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #34 on: June 11, 2012, 10:05:40 PM »

OK... please try this and let me known....  ;D

Code: [Select]
pauseScriptWhenOADisabled()

// ------ SCRIPT BY CHRONOS001 ---------------------------------------------------------

//------- PARAMETER OF HTML TAG ------------------------------------------------------
// For correct use of this script you need to open an HTML File stored in in "Your_OA_Folder\Messages" with an HTML Editor or similar and search for correct TAG in your language
// Ex. for Object Parse you need to search a string like <th scope="row">Object:</th> and write the word Object: in htmlObject def
// IN ALERNATIVE YOU CAN TRY TO SIMPLE OPEN THE HTM FILE AND READ THE CORRECT WORDS IN TOP OF THE PAGE OPENED LIKE THIS:
//From: Comando della Flotta -----> Insert word:  "From:"
//To: xxxxxxx -----> Insert word:  "To:"
//Object: Rapporto di Combattimento [xxxxx] (D: 0, A: 0)  -----> Insert word:  "Object:"
//Date: 02.06.2012 10:54:18  -----> Insert word:  "Date:"

//-------------- CONFIGURATION BY USER -----------------------------------------------

// THIS IS FOR ITALIAN LANGUAGE -> Disable if ENG ENABLED

def htmlTo = "A:"
def htmlDate = "Data:"
def htmlObject = "Oggetto:"

// TRY ENABLE THIS FOR ENGLISH or Uncomment // if using OTHER LANGUAGE DECLARATION BELOW

//def htmlTo = "To:"
//def htmlDate = "Date:"
//def htmlObject = "Subject:"
// def htmlText = "note" // For the message. Not necessary to change

//------- PARAMETER OF YOUR EMAIL -----------------------------------

def mailFrom = "xxxxxxxxx@gmail.com"
def mailTo = "xxxxxxxxxx@gmail.com"
def mailUserName = "xxxxxxxxxxx@gmail.com"
def mailPassword = "xxxxxxxxxxxx"
def mailSmtp = "smtp.gmail.com"
def smtpPort = 465 // Default is 25, but ex. for gmail is 465
def enableSSL = true // true if your provider use SSL, like GMail else insert false

//------- OTHER SETUP ---- TIMING INTERVAL TO CHECK FOR NEW MESSAGE  -----------------

def interval = 10 // In Min --> Time thet Script check for new Messages
// I suggest a time between 5 and 10 minute for not usage too many cpu

//------- END CONFIGURATION BY USER ------- NOTHING BELOW IS USER CONFIGURABLE---------

//------- PARAMETER OF FILE POSITION -------------------------------------------------

// Automatically defined by code below by Devil's Hand

def dirPath = System.getProperty("user.dir")+File.separatorChar+"Messages"+File.separatorChar+getOGameAddress()
new File(System.getProperty("user.dir")+File.separatorChar+"BackupedMessages").mkdir()
new File(System.getProperty("user.dir")+File.separatorChar+"BackupedMessages"+File.separatorChar+getOGameAddress()).mkdir()
def dirBckUp = System.getProperty("user.dir")+File.separatorChar+"BackupedMessages"+File.separatorChar+getOGameAddress()
printOut "Backup message are in: " + dirBckUp

//------- PARAMETER OF FILE POSITION END ----------------------------------------------

//------- DEFINE and PARSE ARRAYS START -------------------------------------------------

def htmlText = ["note","other"] // For the Text I think is not necessary to change
def sTo = "<th scope=\"row\">" + htmlTo + "</th>"
def sDate = "<th scope=\"row\">" + htmlDate + "</th>"
def sObject = "<th scope=\"row\">" + htmlObject + "</th>"
def sText = ["<div class=\"" + htmlText[0] + "\">","<div class=\"" + htmlText[1] + "\">"]
def sFrom = '<span class="playerName">'
def FileLineRead = []
def makeText = []

def isRead = new int[5] // from, to, date, object, text

def setArrayReader = { chkLine ->
    isRead[0] = 0
    isRead[1] = 0
    isRead[2] = 0
    isRead[3] = 0
    isRead[4] = 0

  if (chkLine.contains(sFrom)){
    isRead[0] = 2
    isRead[1] = 0
    isRead[2] = 0
    isRead[3] = 0
    isRead[4] = 0
  }
  if (chkLine.contains(sTo)){
    isRead[0] = 0
    isRead[1] = 2
    isRead[2] = 0
    isRead[3] = 0
    isRead[4] = 0
  }
  if (chkLine.contains(sDate)){
    isRead[0] = 0
    isRead[1] = 0
    isRead[2] = 2
    isRead[3] = 0
    isRead[4] = 0
  }
  if (chkLine.contains(sObject)){
    isRead[0] = 0
    isRead[1] = 0
    isRead[2] = 0
    isRead[3] = 2
    isRead[4] = 0
  }
  if (chkLine.contains(sText[0]) || chkLine.contains(sText[1])){
    isRead[0] = 0
    isRead[1] = 0
    isRead[2] = 0
    isRead[3] = 0
    isRead[4] = 2
  }
}

def setOutString = { stringToParse, intFrom, intTo ->
  return stringToParse.subSequence(intFrom,intTo)
}

def isPlayer = { textLine ->
    return textLine.contains(":")
}
//------- DEFINE and PARSE ARRAYS END -------------------------------------------------

//-------------- MAIN ------------------

def i = 0
while (true){
printOut "Checking for new Player Messages..."
new File(dirPath).eachFile() { sFile ->
  i = 0
  sFile.eachLine{ line ->
    FileLineRead[i] = line
    i++
  }

  setArrayReader("")
  for (k in 0..i-1){   
    readStr = FileLineRead[k].trim()
    if (isRead[0] != 0){
      if (isPlayer(readStr)) {
        s = ~'<'
        m = s.matcher(readStr)
        m.find()
        makeText[0] = "From: " + setOutString(readStr,0,m.start()-1)
      }else{
        makeText[0] = "NOMAIL"       
        break
      }
    }

  if (isRead[1] != 0){makeText[1] = "To: " + setOutString(readStr,4,readStr.size()-5)}
  if (isRead[2] != 0){makeText[2] = "Date: " + setOutString(readStr,4,readStr.size()-5)}
  if (isRead[3] != 0){makeText[3] = "Subject: " + setOutString(readStr,4,readStr.size()-5)}
  if (isRead[4] != 0){
    s = ~'</p>'
    m = s.matcher(readStr)
    m.find()
    readStr = setOutString(readStr,17,m.start()).trim()
    makeText[4] = "Text: " + readStr.subSequence(0,readStr.size())
  }
    setArrayReader(readStr)
}

  if (makeText[0] != "NOMAIL"){
    printOut "Send Mail"
   
// ------------ START MAIL SUBROUTINE ------------------------------
 
  sendEmail(
  mailTo , mailFrom, 
 
  // Change "text in green" if you want to customize your messages. Do not change "\n" (new line)
 
  "OGame Message Waiting", // Subject:
  "Details of Message: \n" + makeText[0] + "\n" + makeText[1] + "\n" + makeText[2] + "\n" + makeText[3] + "\n" + makeText[4],          //core message
 
  // --------------DO NOT CHANGE BELOW ----------------------------
 
  mailSmtp, smtpPort,  mailUserName, mailPassword,  enableSSL 
  )
// ------------ END MAIL SUBROUTINE --------------------------------

    File srcFile = new File(dirPath + File.separatorChar + sFile.getName())
    File destFile = new File(dirBckUp + File.separatorChar + sFile.getName())
   
  destFile.withDataOutputStream { os-> 
      srcFile.withDataInputStream { is-> 
         os << is 
      } 
    }
    srcFile.delete()
  }
}
sleep (interval*1000*60)
}
Logged

asdasd

  • Full Member
  • ***
  • Offline Offline
  • Posts: 231
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #35 on: June 11, 2012, 10:09:50 PM »

new try always old bug

Script uni****.ogame.**** ---------- has been stopped, Throwable: No match available
Logged

chronos001

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #36 on: June 11, 2012, 11:30:00 PM »

ok... i need you messages to check the error... if you want you can go on messages foldet and select only the html messages from player...is the obly way for me to see your error... you can see the messages because they have in the name the subject of the message... if you trust you can zip and send me by mail... byzzzz
Logged

Zebra

  • Full Member
  • ***
  • Offline Offline
  • Posts: 212
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #37 on: June 12, 2012, 04:28:45 AM »

Ok. Mine seems to work now.

Code: [Select]
pauseScriptWhenOADisabled()

// ------ SCRIPT BY CHRONOS001 ---------------------------------------------------------

//------- PARAMETER OF HTML TAG ------------------------------------------------------
// For correct use of this script you need to open an HTML File stored in in "Your_OA_Folder\Messages" with an HTML Editor or similar and search for correct TAG in your language
// Ex. for Object Parse you need to search a string like <th scope="row">Object:</th> and write the word Object: in htmlObject def
// IN ALERNATIVE YOU CAN TRY TO SIMPLE OPEN THE HTM FILE AND READ THE CORRECT WORDS IN TOP OF THE PAGE OPENED LIKE THIS:
//From: Comando della Flotta -----> Insert word:  "From:"
//To: xxxxxxx -----> Insert word:  "To:"
//Object: Rapporto di Combattimento [xxxxx] (D: 0, A: 0)  -----> Insert word:  "Object:"
//Date: 02.06.2012 10:54:18  -----> Insert word:  "Date:"

//-------------- CONFIGURATION BY USER -----------------------------------------------

// THIS IS FOR ITALIAN LANGUAGE -> Disable if ENG ENABLED

// def htmlTo = "A:"
// def htmlDate = "Data:"
// def htmlObject = "Oggetto:"

// TRY ENABLE THIS FOR ENGLISH or Uncomment // if using OTHER LANGUAGE DECLARATION BELOW

def htmlTo = "To:"
def htmlDate = "Date:"
def htmlObject = "Subject:"

//------- PARAMETER OF YOUR EMAIL -----------------------------------

def mailFrom = "xxxxxxxxx@gmail.com"
def mailTo = "xxxxxxxxxx@gmail.com"
def mailUserName = "xxxxxxxxxxx@gmail.com"
def mailPassword = "xxxxxxxxxxxx"
def mailSmtp = "smtp.gmail.com"
def smtpPort = 465 // Default is 25, but ex. for gmail is 465
def enableSSL = true // true if your provider use SSL, like GMail else insert false

//------- OTHER SETUP ---- TIMING INTERVAL TO CHECK FOR NEW MESSAGE  -----------------

def interval = 10 // In Min --> Time thet Script check for new Messages
// I suggest a time between 5 and 10 minute for not usage too many cpu

//------- END CONFIGURATION BY USER ------- NOTHING BELOW IS USER CONFIGURABLE---------

//------- PARAMETER OF FILE POSITION -------------------------------------------------

// Automatically defined by code below by Devil's Hand

def dirPath = System.getProperty("user.dir")+File.separatorChar+"Messages"+File.separatorChar+getOGameAddress()
new File(System.getProperty("user.dir")+File.separatorChar+"BackupedMessages").mkdir()
new File(System.getProperty("user.dir")+File.separatorChar+"BackupedMessages"+File.separatorChar+getOGameAddress()).mkdir()
def dirBckUp = System.getProperty("user.dir")+File.separatorChar+"BackupedMessages"+File.separatorChar+getOGameAddress()
printOut "Backup message are in: " + dirBckUp

//------- PARAMETER OF FILE POSITION END ----------------------------------------------

//------- DEFINE and PARSE ARRAYS START -------------------------------------------------

def sTo = "<th scope=\"row\">" + htmlTo + "</th>"
def sDate = "<th scope=\"row\">" + htmlDate + "</th>"
def sObject = "<th scope=\"row\">" + htmlObject + "</th>"
def htmlText = ["note","other"] // For the Text I think is not necessary to change
def sText = ["<div class=\"" + htmlText[0] + "\">","<div class=\"" + htmlText[1] + "\">"]
def sFrom = '<span class="playerName">'
def FileLineRead = []
def makeText = []

def isRead = new int[5] // from, to, date, object, text

def setArrayReader = { chkLine ->
    isRead[0] = 0
    isRead[1] = 0
    isRead[2] = 0
    isRead[3] = 0
    isRead[4] = 0

  if (chkLine.contains(sFrom)){
    isRead[0] = 2
    isRead[1] = 0
    isRead[2] = 0
    isRead[3] = 0
    isRead[4] = 0
  }
  if (chkLine.contains(sTo)){
    isRead[0] = 0
    isRead[1] = 2
    isRead[2] = 0
    isRead[3] = 0
    isRead[4] = 0
  }
  if (chkLine.contains(sDate)){
    isRead[0] = 0
    isRead[1] = 0
    isRead[2] = 2
    isRead[3] = 0
    isRead[4] = 0
  }
  if (chkLine.contains(sObject)){
    isRead[0] = 0
    isRead[1] = 0
    isRead[2] = 0
    isRead[3] = 2
    isRead[4] = 0
  }
  if (chkLine.contains(sText[0]) || chkLine.contains(sText[1])){
    isRead[0] = 0
    isRead[1] = 0
    isRead[2] = 0
    isRead[3] = 0
    isRead[4] = 2
  }
}

def setOutString = { stringToParse, intFrom, intTo ->
  return stringToParse.subSequence(intFrom,intTo)
}

def isPlayer = { textLine ->
    return textLine.contains(":")
}
//------- DEFINE and PARSE ARRAYS END -------------------------------------------------

//-------------- MAIN ------------------

def i = 0
while (true){
printOut "Checking for new Player Messages..."
new File(dirPath).eachFile() { sFile ->
  i = 0
  sFile.eachLine{ line ->
    FileLineRead[i] = line
    i++
  }

  setArrayReader("")
  for (k in 0..i-1){   
    readStr = FileLineRead[k].trim()
    if (isRead[0] != 0){
      if (isPlayer(readStr)) {
        s = ~'<'
        m = s.matcher(readStr)
        m.find()
        makeText[0] = "From: " + setOutString(readStr,0,m.start()-1)
      }else{
        makeText[0] = "NOMAIL"       
        break
      }
    }

  if (isRead[1] != 0){makeText[1] = "To: " + setOutString(readStr,4,readStr.size()-5)}
  if (isRead[2] != 0){makeText[2] = "Date: " + setOutString(readStr,4,readStr.size()-5)}
  if (isRead[3] != 0){makeText[3] = "Subject: " + setOutString(readStr,4,readStr.size()-5)}
  if (isRead[4] != 0){
    s = ~'</p>'
    m = s.matcher(readStr)
    m.find()
    readStr = setOutString(readStr,17,m.start()).trim()
    makeText[4] = "Text: " + readStr.subSequence(0,readStr.size())
  }
    setArrayReader(readStr)
}

  if (makeText[0] != "NOMAIL"){
    printOut "Send Mail"
   
// ------------ START MAIL SUBROUTINE ------------------------------
 
  sendEmail(
  mailTo , mailFrom, 
 
  // Change "text in green" if you want to customize your messages. Do not change "\n" (new line)
 
  "OGame Message Waiting", // Subject:
  "Details of Message: \n" + makeText[0] + "\n" + makeText[1] + "\n" + makeText[2] + "\n" + makeText[3] + "\n" + makeText[4],          //core message
 
  // --------------DO NOT CHANGE BELOW ----------------------------
 
  mailSmtp, smtpPort,  mailUserName, mailPassword,  enableSSL 
  )
// ------------ END MAIL SUBROUTINE --------------------------------

    File srcFile = new File(dirPath + File.separatorChar + sFile.getName())
    File destFile = new File(dirBckUp + File.separatorChar + sFile.getName())
   
  destFile.withDataOutputStream { os-> 
      srcFile.withDataInputStream { is-> 
         os << is 
      } 
    }
    srcFile.delete()
  }
}
sleep (interval*1000*60)
}

@DH - How can we add a call to read/update new messages from ogame? OA update is slow so new messages update is now dependent on OA update.

Update: still having match errors on some. i think its still the same error. messages with long text. or messages with <br>

Update: Yeah. Confirmed. All messages with <br> in the note/other stops and creates no match error.

Update: Maybe solution to replace all <br> within def with /.
« Last Edit: June 12, 2012, 06:00:55 AM by Zebra »
Logged

chronos001

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #38 on: June 12, 2012, 08:45:25 AM »


@DH - How can we add a call to read/update new messages from ogame? OA update is slow so new messages update is now dependent on OA update.

Update: still having match errors on some. i think its still the same error. messages with long text. or messages with <br>

Update: Yeah. Confirmed. All messages with <br> in the note/other stops and creates no match error.

Update: Maybe solution to replace all <br> within def with /.

Hi, now if you check the script no more <br> was parsed, now I search for </p> for read only first part in reply message, I think BR is not the problem of "No match available". If asdasd send me html file I can see...
Now I have not this problem but I'm not in ally and I don't can see continuous reply messages...
Logged

Zebra

  • Full Member
  • ***
  • Offline Offline
  • Posts: 212
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #39 on: June 12, 2012, 08:51:18 AM »

Just open one of your messages.html from your backup folder, edit it, add a <br> inbetween the div of 'other', save, move it back to the OA messages folder. Try the script.
Logged

chronos001

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #40 on: June 12, 2012, 09:14:18 AM »

I have tried your suggstion but for me working good anyway with <BR> ... send me the file incriminated file :)
If you insert
printOut sFile.getName()
after this line
 if (isRead[3] != 0){makeText[3] = "Subject: " + setOutString(readStr,4,readStr.size()-5)}

in this way you can see the html who generate error.
Logged

chronos001

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #41 on: June 12, 2012, 01:22:30 PM »

Hi,
I have edited all parsing procedure for tag TEXT.
@Zebra: I try with your message and now it work fine
@asdasd: check now if it work, else for help you I need HTML file, zebra sended me ;) !

**** FOR ENG USER ENABLE ENG DEFINITION ****

Try and give me the feedback...
Code: [Select]
pauseScriptWhenOADisabled()

// ------ SCRIPT BY CHRONOS001 ---------------------------------------------------------

//------- PARAMETER OF HTML TAG ------------------------------------------------------
// For correct use of this script you need to open an HTML File stored in in "Your_OA_Folder\Messages" with an HTML Editor or similar and search for correct TAG in your language
// Ex. for Object Parse you need to search a string like <th scope="row">Object:</th> and write the word Object: in htmlObject def
// IN ALERNATIVE YOU CAN TRY TO SIMPLE OPEN THE HTM FILE AND READ THE CORRECT WORDS IN TOP OF THE PAGE OPENED LIKE THIS:
//From: Comando della Flotta -----> Insert word:  "From:"
//To: xxxxxxx -----> Insert word:  "To:"
//Object: Rapporto di Combattimento [xxxxx] (D: 0, A: 0)  -----> Insert word:  "Object:"
//Date: 02.06.2012 10:54:18  -----> Insert word:  "Date:"

//-------------- CONFIGURATION BY USER -----------------------------------------------

// THIS IS FOR ITALIAN LANGUAGE -> Disable if ENG ENABLED

def htmlTo = "A:"
def htmlDate = "Data:"
def htmlObject = "Oggetto:"

// TRY ENABLE THIS FOR ENGLISH or Uncomment // if using OTHER LANGUAGE DECLARATION BELOW

//def htmlTo = "To:"
//def htmlDate = "Date:"
//def htmlObject = "Subject:"

//------- PARAMETER OF YOUR EMAIL -----------------------------------

def mailFrom = "xxxxxxxx@gmail.com"
def mailTo = "xxxxxxx@gmail.com"
def mailUserName = "xxxxxx@gmail.com"
def mailPassword = "xxxxxxxx"
def mailSmtp = "smtp.gmail.com"
def smtpPort = 465 // Default is 25, but ex. for gmail is 465
def enableSSL = true // true if your provider use SSL, like GMail else insert false

//------- OTHER SETUP ---- TIMING INTERVAL TO CHECK FOR NEW MESSAGE  -----------------

def interval = 10 // In Min --> Time thet Script check for new Messages
// I suggest a time between 5 and 10 minute for not usage too many cpu

//------- END CONFIGURATION BY USER ------- NOTHING BELOW IS USER CONFIGURABLE---------

//------- PARAMETER OF FILE POSITION -------------------------------------------------

// Automatically defined by code below by Devil's Hand

def dirPath = System.getProperty("user.dir")+File.separatorChar+"Messages"+File.separatorChar+getOGameAddress()
new File(System.getProperty("user.dir")+File.separatorChar+"BackupedMessages").mkdir()
new File(System.getProperty("user.dir")+File.separatorChar+"BackupedMessages"+File.separatorChar+getOGameAddress()).mkdir()
def dirBckUp = System.getProperty("user.dir")+File.separatorChar+"BackupedMessages"+File.separatorChar+getOGameAddress()
printOut "Backup message are in: " + dirBckUp

//------- PARAMETER OF FILE POSITION END ----------------------------------------------

//------- DEFINE and PARSE ARRAYS START -------------------------------------------------

def htmlText = ["note","other","own"] // For the Text I think is not necessary to change
def sTo = "<th scope=\"row\">" + htmlTo + "</th>"
def sDate = "<th scope=\"row\">" + htmlDate + "</th>"
def sObject = "<th scope=\"row\">" + htmlObject + "</th>"
def sText = ["<div class=\"" + htmlText[0] + "\">","<div class=\"" + htmlText[1] + "\">","<div class=\"" + htmlText[2] + "\">"]
def sFrom = '<span class="playerName">'
def br = ['<br>','<p class="other">','<p class="info">','<p class="own">','<p class="note">']
def FileLineRead = []
def makeText = []

def isRead = new int[5] // from, to, date, object, text

def setArrayReader = { chkLine ->
    isRead[0] = 0
    isRead[1] = 0
    isRead[2] = 0
    isRead[3] = 0
    isRead[4] = 0

  if (chkLine.contains(sFrom)){
    isRead[0] = 2
    isRead[1] = 0
    isRead[2] = 0
    isRead[3] = 0
    isRead[4] = 0
  }
  if (chkLine.contains(sTo)){
    isRead[0] = 0
    isRead[1] = 2
    isRead[2] = 0
    isRead[3] = 0
    isRead[4] = 0
  }
  if (chkLine.contains(sDate)){
    isRead[0] = 0
    isRead[1] = 0
    isRead[2] = 2
    isRead[3] = 0
    isRead[4] = 0
  }
  if (chkLine.contains(sObject)){
    isRead[0] = 0
    isRead[1] = 0
    isRead[2] = 0
    isRead[3] = 2
    isRead[4] = 0
  }
  if (chkLine.contains(sText[0]) || chkLine.contains(sText[1]) || chkLine.contains(sText[2])){
    isRead[0] = 0
    isRead[1] = 0
    isRead[2] = 0
    isRead[3] = 0
    isRead[4] = 2
  }
}

def setOutString = { stringToParse, intFrom, intTo ->
  return stringToParse.subSequence(intFrom,intTo)
}

def isPlayer = { textLine ->
    return textLine.contains(":")
}
//------- DEFINE and PARSE ARRAYS END -------------------------------------------------

//-------------- MAIN ------------------
def boolean moreLine = false
def i = 0
def plusLine = 0

while (true){
printOut "Checking for new Player Messages..."
new File(dirPath).eachFile() { sFile ->
  i = 0
  sFile.eachLine{ line ->
    FileLineRead[i] = line
    i++
  }
  setArrayReader("")
  for (k in 0..i-1){   
    readStr = FileLineRead[k].trim()
    if (isRead[0] != 0){
      if (isPlayer(readStr)) {
        s = ~'<'
        m = s.matcher(readStr)
        m.find()
        makeText[0] = "From: " + setOutString(readStr,0,m.start()-1)
        makeText[4] = ""
      }else{
        makeText[0] = "NOMAIL"       
        break
      }
    }
  if (isRead[1] != 0){makeText[1] = "To: " + setOutString(readStr,4,readStr.size()-5)}
  if (isRead[2] != 0){makeText[2] = "Date: " + setOutString(readStr,4,readStr.size()-5)}
  if (isRead[3] != 0){makeText[3] = "Subject: " + setOutString(readStr,4,readStr.size()-5)}
  if (isRead[4] != 0){
    s = ~'</p>'
    m = s.matcher(readStr)
    makeText[4] = readStr
    plusLine = 0
    while (!m.find()){
      plusLine +=1
      readStr = FileLineRead[k+plusLine].trim()
      m = s.matcher(readStr)
      makeText[4] = makeText[4] + readStr
    }
    m = s.matcher(makeText[4])
    m.find()
    makeText[4] = setOutString(makeText[4],0,m.start()).trim()
    for (r in 0..4){
      makeText[4] = makeText[4].replaceAll(br[r],' ')
    }
  }
  setArrayReader(readStr)
 
}
  if (makeText[0] != "NOMAIL"){
    printOut "Send Mail"
// ------------ START MAIL SUBROUTINE ------------------------------
 
  sendEmail(
  mailTo , mailFrom, 
 
  // Change "text in green" if you want to customize your messages. Do not change "\n" (new line)
 
  "OGame Message Waiting", // Subject:
  "Details of Message: \n" + makeText[0] + "\n" + makeText[1] + "\n" + makeText[2] + "\n" + makeText[3] + "\nText: " + makeText[4],          //core message
 
  // --------------DO NOT CHANGE BELOW ----------------------------
 
  mailSmtp, smtpPort,  mailUserName, mailPassword,  enableSSL 
  )
// ------------ END MAIL SUBROUTINE --------------------------------

    File srcFile = new File(dirPath + File.separatorChar + sFile.getName())
    File destFile = new File(dirBckUp + File.separatorChar + sFile.getName())
   
  destFile.withDataOutputStream { os-> 
      srcFile.withDataInputStream { is-> 
         os << is 
      } 
    }
    srcFile.delete()
  }
}
sleep (interval*1000*60)
}
Logged

Zebra

  • Full Member
  • ***
  • Offline Offline
  • Posts: 212
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #42 on: June 12, 2012, 06:12:11 PM »

Bellissima. E' perfetto. Mille grazie!
 ;)

also, ive edited the sendmail section to put in 'message from and subject' to be sent as email subject.

simply replace the relevant section

Code: [Select]
// ------------ START MAIL SUBROUTINE ------------------------------
 
  sendEmail(
  mailTo , mailFrom, 
 
  // Change "text in green" if you want to customize your messages. Do not change "\n" (new line)
 
  makeText[0]+ " " + makeText[3], // Subject of email becomes subject from message

  "Details of Message: \n" + makeText[0] + "\n" + makeText[1] + "\n" + makeText[2] + "\n" + makeText[3] + "\n" + makeText[4],          //core message
 
  // --------------DO NOT CHANGE BELOW ----------------------------
 
  mailSmtp, smtpPort,  mailUserName, mailPassword,  enableSSL 
  )
// ------------ END MAIL SUBROUTINE --------------------------------
« Last Edit: June 12, 2012, 06:18:03 PM by Zebra »
Logged

chronos001

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #43 on: June 12, 2012, 06:34:13 PM »

Bellissima. E' perfetto. Mille grazie!
 ;)

also, ive edited the sendmail section to put in 'message from and subject' to be sent as email subject.

simply replace the relevant section


I have read your solution for put Subject in Subject e-mail but if anyone send you a message with Subject: "No Subject" is no good to see, at least you can add like this:

Code: [Select]
"OG Message: From " + makeText[0] + " Sbj: " + makeText[3], // Subject of email becomes subject from message
 ;)
Logged

Zebra

  • Full Member
  • ***
  • Offline Offline
  • Posts: 212
    • View Profile
Re: Send E-Mail if Player send you a Message (BETA)
« Reply #44 on: June 12, 2012, 06:37:30 PM »

Yup. Think people will edit this to suit their preferences after this.
Logged
Pages: 1 2 [3] 4 5 ... 7
 

Page created in 0.035 seconds with 20 queries.