Openkore.com

OpenKore Forums
It is currently 23 Aug 2019, 20:02

All times are UTC - 5 hours [ DST ]





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Help in creating a new console command
PostPosted: 13 Mar 2017, 12:45 
Offline
Noob
Noob

Joined: 13 Mar 2017, 12:01
Posts: 18
Hello,

here is my problem:

- I need openkore to send a email when there's 30k of the item "Credit" in my storage.

I searched a lot and not found how openkore can get the amount of an item at storage, so my solution for this is: my macro quits after putting credit into the storage and it keeps 195 credits per time, because credit quest can be done 1 time per day, so if openkore write the amount of times that it stored credits in some txt file, for example it would look in my macro this way:

Code:
do logtxt credit.txt 195


it will write 195 on the txt file on the first time and then it will add 195 to the number which is already in the txt

and then make openkore able to read this file, something like this:

Code:
$totalcredits = readlogtxt credit.txt


then if it's around 30k send an email and then quits openkore

the "logtxt" console command will also help me logging the date and time after openkore stores credits and close, I already did a bat file than can read a date and time from a txt file and it also can run openkore on the next day after doing credits

About sending email, I found the perl code to send an email, but idk how to use it:

Code:
#!/usr/bin/perl
use strict;
use warnings;

# first, create your message
use Email::MIME;
my $message = Email::MIME->create(
  header_str => [
    From    => 'you@example.com',
    To      => 'friend@example.com',
    Subject => 'Happy birthday!',
  ],
  attributes => {
    encoding => 'quoted-printable',
    charset  => 'ISO-8859-1',
  },
  body_str => "Happy birthday to you!\n",
);

# send the message
use Email::Sender::Simple qw(sendmail);
sendmail($message);



Thanks for reading !


Top
 Profile  
 
 Post subject: Re: Help in creating a new console command
PostPosted: 13 Mar 2017, 15:21 
Offline
Developers
Developers

Joined: 01 Nov 2008, 15:31
Posts: 361
U no need to store that anywhere use automacro with storage <item> <condition> <amount> [, ...]

U need to install MIME to use it :)

Lite.pm

put to <your_bot>/src/deps/MIME/Lite.pm

use like sub in macro:

Code:
sub sendmail{
    use MIME::Lite;
    use strict;
    $msg = MIME::Lite->new(
        From     => 'me@myhost.com',
        To       => 'you@yourhost.com',
        Subject  => 'Helloooooo, nurse!',
        Data     => "How's it goin', eh?"
    );
    $msg->send;
}

macro sendThat{
    $res = sendmail()
}

_________________
Please use pin function for uploading your file contents!


Top
 Profile  
 
 Post subject: Re: Help in creating a new console command
PostPosted: 14 Mar 2017, 14:06 
Offline
Noob
Noob

Joined: 13 Mar 2017, 12:01
Posts: 18
Thanks for the help

But after working hard for 2 days I did it only using a batch file :)

This topic can be closed


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group