Help in creating a new console command

All resolved question will be found here. It is recommended that you browse / search through this section first and see if your question has been answered before

Moderators: Moderators, Documentation Writers

Message
Author
dilminha
Noob
Noob
Posts: 18
Joined: 13 Mar 2017, 12:01
Noob?: No

Help in creating a new console command

#1 Post by dilminha »

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: Select all

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: Select all

$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: Select all

#!/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 !

Mortimal
Developers
Developers
Posts: 389
Joined: 01 Nov 2008, 15:31
Noob?: No

Re: Help in creating a new console command

#2 Post by Mortimal »

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: Select all

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!

dilminha
Noob
Noob
Posts: 18
Joined: 13 Mar 2017, 12:01
Noob?: No

Re: Help in creating a new console command

#3 Post by dilminha »

Thanks for the help

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

This topic can be closed

Locked