aus dem Amt / nach Stunden AutoReply

Howto's zu OTRS Themen. Keine neuen Topics mit Fragen in diesem Forum!
Post Reply
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

aus dem Amt / nach Stunden AutoReply

Post by crythias »

Hallo, alle.
Originalmeldung (in Englisch): viewtopic.php?f=60&t=18347

"Wie kann ich meine autoresponse nach Stunden, und wenn wir an den Feiertagen geschlossen sind?"

Zuerst müssen Sie die aus dem Amt / nach Stunden / Feiertag Auto Reaktion im Admin-Panel erstellen. Stellen Sie sicher, es ist der Typ (Auto Reply) Sie benötigen. Auto Reply / new ticket ist es nicht.

Dann brauchen Sie diese - außer in bin/my.AutoResponseQueue.pl:

Code: Select all

#!/usr/bin/perl -w
# --
# bin/my.AutoResponseQueue.pl - Assign AutoResponse to Queue from CLI
# modified from OTRS code.
# --
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU AFFERO General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# or see http://www.gnu.org/licenses/agpl.txt.
# --

use strict;
use warnings;

use File::Basename;
use FindBin qw($RealBin);
use lib dirname($RealBin);
use lib dirname($RealBin) . '/Kernel/cpan-lib';
use lib dirname($RealBin) . '/Custom';


use Getopt::Std;
use Kernel::Config;
use Kernel::System::Encode;
use Kernel::System::Time;
use Kernel::System::DB;
use Kernel::System::Log;
use Kernel::System::Queue;
use Kernel::System::AutoResponse;
use Kernel::System::Main;

# get options
my %Opts = ();
getopts( 'hq:r:', \%Opts );
if ( $Opts{h} ) {
    print
        "my.AutoResponseQueue.pl - assigns autoresponse to a queue \n";
    print
        "usage: my.AutoResponseQueue.pl -r <AUTORESPONSE> -q <QUEUE>\n";
        print "example: my.AutoResponseQueue.pl -r 1 -q Raw\n";
        print "You will need to look for the ID from Action=AdminAutoResponse;Subaction=Change;ID=x\n";
    exit 1;
}
if ( !$Opts{r} ) {
    print STDERR "ERROR: Need -r <AUTORESPONSE> (as a number)\n";
    exit 1;
}
if ( !$Opts{q} ) {
    print STDERR "ERROR: Need -q <QUEUE> (as a word/phrase, like 'Raw')\n";
    exit 1;
}

# create common objects
my %CommonObject = ();
$CommonObject{ConfigObject} = Kernel::Config->new(%CommonObject);
$CommonObject{EncodeObject} = Kernel::System::Encode->new(%CommonObject);
$CommonObject{LogObject}    = Kernel::System::Log->new(
    LogPrefix => 'MY-my.AutoresponseQueue.pl',
    %CommonObject,
);
$CommonObject{MainObject}             = Kernel::System::Main->new(%CommonObject);
$CommonObject{DBObject}               = Kernel::System::DB->new(%CommonObject);
$CommonObject{QueueObject}            = Kernel::System::Queue->new(%CommonObject);
$CommonObject{AutoResponseObject} = Kernel::System::AutoResponse->new(%CommonObject);

# check queue
my $QueueID = $CommonObject{QueueObject}->QueueLookup( Queue => $Opts{q} );
if ( !$QueueID ) {
    print STDERR "ERROR: Queue not found for $Opts{q}\n";
    exit 1;
}

# check response
my %AutoResponseData
    = $CommonObject{AutoResponseObject}->AutoResponseGet( ID => $Opts{r} );
if ( !%AutoResponseData ) {
    print STDERR "ERROR: Found no Auto Response for $Opts{r}\n";
    exit 1;
}

my @AutoResponseIDs = ($Opts{r});
# set queue standard response
if (
    !$CommonObject{AutoResponseObject}->AutoResponseQueue(
        AutoResponseIDs => \@AutoResponseIDs,
        QueueID    => $QueueID,
        UserID     => 1,
    )
    )
{
    print STDERR "ERROR: Can't set AutoResponse!\n";
    exit 1;
}
else {
    print "Added AutoResponse '$Opts{r}' to Queue '$Opts{q}'.\n";
    exit 0;
}
 
Dann brauchen Sie einen cron-Job ... kleben Sie es in otrs/var/cron/offhours
und führen otrs.Cron.sh restart

Code: Select all

#every mon-fri at 6:00p after hours
#min hr date month dayOfWeek (5 is after hours response)
0 18 * * mon-fri $HOME/bin/my.AutoResponseQueue.pl -r 5 -q Raw >> /dev/null
#every mon-fri at 7:00a normal (1 is normal autoresponse)
0 7 * * mon-fri $HOME/bin/my.AutoResponseQueue.pl -r 1 -q Raw >> /dev/null
#Christmas (6 is a holiday autoresponse) If the holiday runs on a m-f, you should probably want to make sure it still says holiday and not "open" or "after hours"
0 0 25 12 * $HOME/bin/my.AutoResponseQueue.pl -r 6 -q Raw >> /dev/null
0 7 25 12 * $HOME/bin/my.AutoResponseQueue.pl -r 6 -q Raw >> /dev/null
0 18 25 12 * $HOME/bin/my.AutoResponseQueue.pl -r 6 -q Raw >> /dev/null
BITTE BITTE Testen Sie vor vorausgesetzt, es wird für Sie arbeiten.
Es können Fehler. Es kann auch nicht funktionieren. Bitte nicht mir die Schuld. Stellen Sie Fragen in den normalen Foren.
Die Zahlen 1,5,6 sind Beispiele. Ihre Umsetzung kann variieren.
Raw ist ein Beispiel Queue. Ihre Queue Name kann variieren. Versuchen Sie, diese in Befehlszeile, bevor Sie cron es zu versuchen.

Ich gebe die Erlaubnis, Moderatoren für Grammatik und zusätzliche Übersetzung zu bearbeiten. Ich spreche kein Deutsch. Dies wurde durch Google Translate übersetzt.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Post Reply