- added "Discord" WebHook support, closed #547

This commit is contained in:
Mark Friedrich
2017-12-20 17:36:58 +01:00
parent 2cc12f0b61
commit 17bc619425
20 changed files with 383 additions and 54 deletions

View File

@@ -207,6 +207,11 @@ class Map extends Controller\AccessController {
'status' => (bool)Config::getPathfinderData('slack.status')
];
// Slack integration status -------------------------------------------------------------------------------
$return->discord = [
'status' => (bool)Config::getPathfinderData('discord.status')
];
$f3->set(self::CACHE_KEY_INIT, $return, $expireTimeCache );
}

View File

@@ -431,6 +431,7 @@ class System extends Controller\AccessController {
$rallyData['pokeDesktop'] = $rallyData['pokeDesktop'] === '1';
$rallyData['pokeMail'] = $rallyData['pokeMail'] === '1';
$rallyData['pokeSlack'] = $rallyData['pokeSlack'] === '1';
$rallyData['pokeDiscord'] = $rallyData['pokeDiscord'] === '1';
$rallyData['message'] = trim($rallyData['message']);
$system->sendRallyPoke($rallyData, $activeCharacter);

View File

@@ -806,6 +806,14 @@ class Setup extends Controller {
$label = '<i class="fa fa-fw fa-slack"></i> Rally point poke Slack';
$tooltip = 'If "enabled", map admins can set a Slack channel for rally point pokes.';
break;
case 'send_history_discord_enabled':
$label = '<i class="fa fa-fw fa-microphone"></i> History log Discord';
$tooltip = 'If "enabled", map admins can set a Discord channel were map logs get piped to.';
break;
case 'send_rally_discord_enabled':
$label = '<i class="fa fa-fw fa-microphone"></i> Rally point poke Discord';
$tooltip = 'If "enabled", map admins can set a Discord channel for rally point pokes.';
break;
case 'send_rally_mail_enabled':
$label = '<i class="fa fa-fw fa-envelope"></i> Rally point poke Email';
$tooltip = 'If "enabled", rally point pokes can be send by Email (SMTP config + recipient address required).';

View File

@@ -36,6 +36,8 @@ class Monolog extends \Prefab {
'mail' => 'Monolog\Handler\SwiftMailerHandler',
'slackMap' => 'lib\logging\handler\SlackMapWebhookHandler',
'slackRally' => 'lib\logging\handler\SlackRallyWebhookHandler',
'discordMap' => 'lib\logging\handler\SlackMapWebhookHandler', // use Slack handler for Discord
'discordRally' => 'lib\logging\handler\SlackRallyWebhookHandler', // use Slack handler for Discord
'zmq' => 'lib\logging\handler\ZMQHandler'
];

View File

@@ -250,6 +250,8 @@ abstract class AbstractLog implements LogInterface {
break;
case 'slackMap':
case 'slackRally':
case 'discordMap':
case 'discordRally':
$params = $this->getHandlerParamsSlack($handlerKey);
break;
default:

View File

@@ -25,6 +25,7 @@ class MapModel extends AbstractMapTrackingModel {
const DATA_CACHE_KEY_CHARACTER = 'CHARACTERS';
const ERROR_SLACK_CHANNEL = 'Invalid #Slack channel column [%s]';
const ERROR_DISCORD_CHANNEL = 'Invalid #Discord channel column [%s]';
protected $fieldConf = [
'active' => [
@@ -133,6 +134,24 @@ class MapModel extends AbstractMapTrackingModel {
'default' => '',
'activity-log' => true
],
'discordUsername' => [
'type' => Schema::DT_VARCHAR128,
'nullable' => false,
'default' => '',
'activity-log' => true
],
'discordWebHookURLRally' => [
'type' => Schema::DT_VARCHAR256,
'nullable' => false,
'default' => '',
'validate' => true
],
'discordWebHookURLHistory' => [
'type' => Schema::DT_VARCHAR256,
'nullable' => false,
'default' => '',
'validate' => true
],
'systems' => [
'has-many' => ['Model\SystemModel', 'mapId']
],
@@ -191,59 +210,65 @@ class MapModel extends AbstractMapTrackingModel {
if(is_null($mapDataAll)){
// no cached map data found
$mapData = (object) [];
$mapData->id = $this->id;
$mapData->name = $this->name;
$mapData->icon = $this->icon;
$mapData->deleteExpiredConnections = $this->deleteExpiredConnections;
$mapData->deleteEolConnections = $this->deleteEolConnections;
$mapData->persistentAliases = $this->persistentAliases;
$mapData = (object) [];
$mapData->id = $this->id;
$mapData->name = $this->name;
$mapData->icon = $this->icon;
$mapData->deleteExpiredConnections = $this->deleteExpiredConnections;
$mapData->deleteEolConnections = $this->deleteEolConnections;
$mapData->persistentAliases = $this->persistentAliases;
// map scope
$mapData->scope = (object) [];
$mapData->scope->id = $this->scopeId->id;
$mapData->scope->name = $this->scopeId->name;
$mapData->scope->label = $this->scopeId->label;
$mapData->scope = (object) [];
$mapData->scope->id = $this->scopeId->id;
$mapData->scope->name = $this->scopeId->name;
$mapData->scope->label = $this->scopeId->label;
// map type
$mapData->type = (object) [];
$mapData->type->id = $this->typeId->id;
$mapData->type->name = $this->typeId->name;
$mapData->type->classTab = $this->typeId->classTab;
$mapData->type = (object) [];
$mapData->type->id = $this->typeId->id;
$mapData->type->name = $this->typeId->name;
$mapData->type->classTab = $this->typeId->classTab;
// map logging
$mapData->logging = (object) [];
$mapData->logging->activity = $this->isActivityLogEnabled();
$mapData->logging->history = $this->isHistoryLogEnabled();
$mapData->logging = (object) [];
$mapData->logging->activity = $this->isActivityLogEnabled();
$mapData->logging->history = $this->isHistoryLogEnabled();
// map Slack logging
$mapData->logging->slackHistory = $this->isSlackChannelEnabled('slackChannelHistory');
$mapData->logging->slackRally = $this->isSlackChannelEnabled('slackChannelRally');
$mapData->logging->slackWebHookURL = $this->slackWebHookURL;
$mapData->logging->slackUsername = $this->slackUsername;
$mapData->logging->slackIcon = $this->slackIcon;
$mapData->logging->slackChannelHistory = $this->slackChannelHistory;
$mapData->logging->slackChannelRally = $this->slackChannelRally;
$mapData->logging->slackHistory = $this->isSlackChannelEnabled('slackChannelHistory');
$mapData->logging->slackRally = $this->isSlackChannelEnabled('slackChannelRally');
$mapData->logging->slackWebHookURL = $this->slackWebHookURL;
$mapData->logging->slackUsername = $this->slackUsername;
$mapData->logging->slackIcon = $this->slackIcon;
$mapData->logging->slackChannelHistory = $this->slackChannelHistory;
$mapData->logging->slackChannelRally = $this->slackChannelRally;
// map Discord logging
$mapData->logging->discordRally = $this->isDiscordChannelEnabled('discordWebHookURLRally');
$mapData->logging->discordUsername = $this->discordUsername;
$mapData->logging->discordWebHookURLRally = $this->discordWebHookURLRally;
$mapData->logging->discordWebHookURLHistory = $this->discordWebHookURLHistory;
// map mail logging
$mapData->logging->mailRally = $this->isMailSendEnabled('RALLY_SET');
$mapData->logging->mailRally = $this->isMailSendEnabled('RALLY_SET');
// map access
$mapData->access = (object) [];
$mapData->access->character = [];
$mapData->access->corporation = [];
$mapData->access->alliance = [];
$mapData->access = (object) [];
$mapData->access->character = [];
$mapData->access->corporation = [];
$mapData->access->alliance = [];
$mapData->created = (object) [];
$mapData->created->created = strtotime($this->created);
$mapData->created = (object) [];
$mapData->created->created = strtotime($this->created);
if(is_object($this->createdCharacterId)){
$mapData->created->character = $this->createdCharacterId->getData();
$mapData->created->character = $this->createdCharacterId->getData();
}
$mapData->updated = (object) [];
$mapData->updated->updated = strtotime($this->updated);
$mapData->updated = (object) [];
$mapData->updated->updated = strtotime($this->updated);
if(is_object($this->updatedCharacterId)){
$mapData->updated->character = $this->updatedCharacterId->getData();
$mapData->updated->character = $this->updatedCharacterId->getData();
}
// get access object data ---------------------------------------------------------------------------------
@@ -315,11 +340,50 @@ class MapModel extends AbstractMapTrackingModel {
* @throws \Exception\ValidationException
*/
protected function validate_slackWebHookURL(string $key, string $val): bool {
return $this->validate_WebHookURL($key, $val, 'slack');
}
/**
* validate Discord History WebHook URL
* @param string $key
* @param string $val
* @return bool
* @throws \Exception\ValidationException
*/
protected function validate_discordWebHookURLHistory(string $key, string $val): bool {
return $this->validate_WebHookURL($key, $val, 'discord');
}
/**
* validate Discord Rally WebHook URL
* @param string $key
* @param string $val
* @return bool
* @throws \Exception\ValidationException
*/
protected function validate_discordWebHookURLRally(string $key, string $val): bool {
return $this->validate_WebHookURL($key, $val, 'discord');
}
/**
* validate Slack/Discord WebHook URL
* @param string $key
* @param string $val
* @param string $type
* @return bool
* @throws \Exception\ValidationException
*/
protected function validate_WebHookURL(string $key, string $val, string $type): bool {
$valid = true;
if( !empty($val) ){
$hosts = [
'slack' => 'hooks.slack.com',
'discord' => 'discordapp.com'
];
if(
!\Audit::instance()->url($val) ||
parse_url($val, PHP_URL_HOST) !== 'hooks.slack.com'
parse_url($val, PHP_URL_HOST) !== $hosts[$type]
){
$valid = false;
$this->throwValidationException($key);
@@ -873,6 +937,13 @@ class MapModel extends AbstractMapTrackingModel {
$log->addHandlerGroup('slackMap');
}
// send map history to Discord channel ------------------------------------------------------------------------
$discordChannelKey = 'discordWebHookURLHistory';
if($this->isDiscordChannelEnabled($discordChannelKey)){
$log->addHandler('discordMap', null, $this->getDiscordWebHookConfig($discordChannelKey));
$log->addHandlerGroup('discordMap');
}
// update map activity ----------------------------------------------------------------------------------------
$log->logActivity($this->isActivityLogEnabled());
@@ -959,6 +1030,34 @@ class MapModel extends AbstractMapTrackingModel {
return $enabled;
}
/**
* check if "Discord WebHook" is enabled for this map type
* @param string $channel
* @return bool
* @throws PathfinderException
*/
public function isDiscordChannelEnabled(string $channel): bool {
$enabled = false;
// check global Slack status
if((bool)Config::getPathfinderData('discord.status')){
// check global map default config for this channel
switch($channel){
case 'discordWebHookURLHistory': $defaultMapConfigKey = 'send_history_discord_enabled'; break;
case 'discordWebHookURLRally': $defaultMapConfigKey = 'send_rally_discord_enabled'; break;
default: throw new PathfinderException(sprintf(self::ERROR_DISCORD_CHANNEL, $channel));
}
if((bool) Config::getMapsDefaultConfig($this->typeId->name)[$defaultMapConfigKey]){
$config = $this->getDiscordWebHookConfig($channel);
if($config->slackWebHookURL){
$enabled = true;
}
}
}
return $enabled;
}
/**
* check if "E-Mail" Log is enabled for this map
* @param string $type
@@ -1018,6 +1117,20 @@ class MapModel extends AbstractMapTrackingModel {
return $config;
}
/**
* get Config for Discord WebHook cURL calls
* @param string $channel
* @return \stdClass
*/
public function getDiscordWebHookConfig(string $channel = ''): \stdClass {
$config = (object) [];
$config->slackUsername = $this->discordUsername;
if($channel && $this->exists($channel)){
$config->slackWebHookURL = $this->$channel . '/slack';
}
return $config;
}
/**
* get Config for SMTP connection and recipient address
* @param string $type

View File

@@ -565,6 +565,7 @@ class SystemModel extends AbstractMapTrackingModel {
/**
* send rally point poke to various "APIs"
* -> send to a Slack channel
* -> send to a Discord channel
* -> send to an Email
* @param array $rallyData
* @param CharacterModel $characterModel
@@ -585,6 +586,17 @@ class SystemModel extends AbstractMapTrackingModel {
$log->addHandler('slackRally', null, $this->getMap()->getSlackWebHookConfig($slackChannelKey));
}
// Discord poke ---------------------------------------------------------------------------
$discordChannelKey = 'discordWebHookURLRally';
if(
$rallyData['pokeDiscord'] === true &&
$this->getMap()->isDiscordChannelEnabled($discordChannelKey)
){
$isValidLog = true;
$log->addHandler('discordRally', null, $this->getMap()->getDiscordWebHookConfig($discordChannelKey));
}
// Mail poke ------------------------------------------------------------------------------
$mailAddressKey = 'RALLY_SET';
if(

View File

@@ -36,6 +36,11 @@ ALLIANCE =
; Global Slack API status, check PATHFINDER.MAP section for individual control (0=disabled, 1=enabled)
STATUS = 1
; Slack API integration ===========================================================================
[PATHFINDER.DISCORD]
; Global Discord API status, check PATHFINDER.MAP section for individual control (0=disabled, 1=enabled)
STATUS = 1
; View ============================================================================================
[PATHFINDER.VIEW]
; static page templates
@@ -82,6 +87,8 @@ LOG_ACTIVITY_ENABLED = 1
LOG_HISTORY_ENABLED = 1
SEND_HISTORY_SLACK_ENABLED = 0
SEND_RALLY_SLACK_ENABLED = 1
SEND_HISTORY_DISCORD_ENABLED = 0
SEND_RALLY_DISCORD_ENABLED = 1
SEND_RALLY_Mail_ENABLED = 0
[PATHFINDER.MAP.CORPORATION]
@@ -93,6 +100,8 @@ LOG_ACTIVITY_ENABLED = 1
LOG_HISTORY_ENABLED = 1
SEND_HISTORY_SLACK_ENABLED = 1
SEND_RALLY_SLACK_ENABLED = 1
SEND_HISTORY_DISCORD_ENABLED = 1
SEND_RALLY_DISCORD_ENABLED = 1
SEND_RALLY_Mail_ENABLED = 0
[PATHFINDER.MAP.ALLIANCE]
@@ -104,6 +113,8 @@ LOG_ACTIVITY_ENABLED = 0
LOG_HISTORY_ENABLED = 1
SEND_HISTORY_SLACK_ENABLED = 1
SEND_RALLY_SLACK_ENABLED = 1
SEND_HISTORY_DISCORD_ENABLED = 1
SEND_RALLY_DISCORD_ENABLED = 1
SEND_RALLY_Mail_ENABLED = 0
; Route search ====================================================================================

View File

@@ -24,6 +24,7 @@ define([
dialogRallyPokeDesktopId: 'pf-rally-dialog-poke-desktop', // id for "desktop" poke checkbox
dialogRallyPokeSlackId: 'pf-rally-dialog-poke-slack', // id for "Slack" poke checkbox
dialogRallyPokeDiscordId: 'pf-rally-dialog-poke-discord', // id for "Discord" poke checkbox
dialogRallyPokeMailId: 'pf-rally-dialog-poke-mail', // id for "mail" poke checkbox
dialogRallyMessageId: 'pf-rally-dialog-message', // id for "message" textarea
@@ -88,11 +89,13 @@ define([
dialogRallyPokeDesktopId: config.dialogRallyPokeDesktopId,
dialogRallyPokeSlackId: config.dialogRallyPokeSlackId,
dialogRallyPokeDiscordId: config.dialogRallyPokeDiscordId,
dialogRallyPokeMailId: config.dialogRallyPokeMailId,
dialogRallyMessageId: config.dialogRallyMessageId ,
desktopRallyEnabled: true,
slackRallyEnabled: Boolean(Util.getObjVal(mapData, 'config.logging.slackRally')),
discordRallyEnabled: Boolean(Util.getObjVal(mapData, 'config.logging.discordRally')),
mailRallyEnabled: Boolean(Util.getObjVal(mapData, 'config.logging.mailRally')),
dialogRallyMessageDefault: config.dialogRallyMessageDefault,
@@ -132,6 +135,8 @@ define([
}
});
rallyDialog.initTooltips();
// after modal is shown ==================================================================================
rallyDialog.on('shown.bs.modal', function(e){
// set event for checkboxes

View File

@@ -69,6 +69,7 @@ define([
Init.routes = initData.routes;
Init.url = initData.url;
Init.slack = initData.slack;
Init.discord = initData.discord;
Init.routeSearch = initData.routeSearch;
Init.programMode = initData.programMode;

View File

@@ -33,6 +33,10 @@ define([
slackChannelHistoryId: 'pf-map-dialog-slack-channel-history', // id for Slack channel "history"
slackChannelRallyId: 'pf-map-dialog-slack-channel-rally', // id for Slack channel "rally"
discordUsernameId: 'pf-map-dialog-discord-username', // id for Discord "username"
discordWebHookURLRallyId: 'pf-map-dialog-discord-url-rally', // id for Discord "rally" webHookUrl
discordWebHookURLHistoryId: 'pf-map-dialog-discord-url-history', // id for Discord "history" webHookUrl
characterSelectId: 'pf-map-dialog-character-select', // id for "character" select
corporationSelectId: 'pf-map-dialog-corporation-select', // id for "corporation" select
allianceSelectId: 'pf-map-dialog-alliance-select', // id for "alliance" select
@@ -133,6 +137,14 @@ define([
let slackRallyEnabled = false;
let slackSectionShow = false;
let discordUsername = '';
let discordWebHookURLRally = '';
let discordWebHookURLHistory = '';
let discordEnabled = false;
let discordRallyEnabled = false;
let discordHistoryEnabled = false;
let discordSectionShow = false;
if(mapData !== false){
// set current map information
contentEditMap.find('input[name="id"]').val( mapData.config.id );
@@ -162,6 +174,14 @@ define([
slackRallyEnabled = slackEnabled && Boolean(Util.getObjVal(Init.mapTypes, mapData.config.type.name + '.defaultConfig.send_rally_slack_enabled'));
slackSectionShow = (slackEnabled && slackWebHookURL.length > 0);
discordUsername = Util.getObjVal(mapData, 'config.logging.discordUsername');
discordWebHookURLRally = Util.getObjVal(mapData, 'config.logging.discordWebHookURLRally');
discordWebHookURLHistory = Util.getObjVal(mapData, 'config.logging.discordWebHookURLHistory');
discordEnabled = Boolean(Util.getObjVal(Init, 'discord.status'));
discordRallyEnabled = discordEnabled && Boolean(Util.getObjVal(Init.mapTypes, mapData.config.type.name + '.defaultConfig.send_rally_discord_enabled'));
discordHistoryEnabled = discordEnabled && Boolean(Util.getObjVal(Init.mapTypes, mapData.config.type.name + '.defaultConfig.send_history_discord_enabled'));
discordSectionShow = (discordEnabled && (discordWebHookURLRally.length > 0 || discordWebHookURLHistory.length > 0));
// remove "#" from Slack channels
slackChannelHistory = slackChannelHistory.indexOf('#') === 0 ? slackChannelHistory.substr(1) : slackChannelHistory;
slackChannelRally = slackChannelRally.indexOf('#') === 0 ? slackChannelRally.substr(1) : slackChannelRally;
@@ -221,6 +241,17 @@ define([
slackRallyEnabled: slackRallyEnabled,
slackSectionShow: slackSectionShow,
discordUsernameId: config.discordUsernameId,
discordWebHookURLRallyId: config.discordWebHookURLRallyId,
discordWebHookURLHistoryId: config.discordWebHookURLHistoryId,
discordUsername: discordUsername,
discordWebHookURLRally: discordWebHookURLRally,
discordWebHookURLHistory: discordWebHookURLHistory,
discordEnabled: discordEnabled,
discordRallyEnabled: discordRallyEnabled,
discordHistoryEnabled: discordHistoryEnabled,
discordSectionShow: discordSectionShow,
characterSelectId: config.characterSelectId,
corporationSelectId: config.corporationSelectId,
allianceSelectId: config.allianceSelectId,

View File

@@ -24,6 +24,7 @@ define([
dialogRallyPokeDesktopId: 'pf-rally-dialog-poke-desktop', // id for "desktop" poke checkbox
dialogRallyPokeSlackId: 'pf-rally-dialog-poke-slack', // id for "Slack" poke checkbox
dialogRallyPokeDiscordId: 'pf-rally-dialog-poke-discord', // id for "Discord" poke checkbox
dialogRallyPokeMailId: 'pf-rally-dialog-poke-mail', // id for "mail" poke checkbox
dialogRallyMessageId: 'pf-rally-dialog-message', // id for "message" textarea
@@ -88,11 +89,13 @@ define([
dialogRallyPokeDesktopId: config.dialogRallyPokeDesktopId,
dialogRallyPokeSlackId: config.dialogRallyPokeSlackId,
dialogRallyPokeDiscordId: config.dialogRallyPokeDiscordId,
dialogRallyPokeMailId: config.dialogRallyPokeMailId,
dialogRallyMessageId: config.dialogRallyMessageId ,
desktopRallyEnabled: true,
slackRallyEnabled: Boolean(Util.getObjVal(mapData, 'config.logging.slackRally')),
discordRallyEnabled: Boolean(Util.getObjVal(mapData, 'config.logging.discordRally')),
mailRallyEnabled: Boolean(Util.getObjVal(mapData, 'config.logging.mailRally')),
dialogRallyMessageDefault: config.dialogRallyMessageDefault,
@@ -132,6 +135,8 @@ define([
}
});
rallyDialog.initTooltips();
// after modal is shown ==================================================================================
rallyDialog.on('shown.bs.modal', function(e){
// set event for checkboxes

View File

@@ -69,6 +69,7 @@ define([
Init.routes = initData.routes;
Init.url = initData.url;
Init.slack = initData.slack;
Init.discord = initData.discord;
Init.routeSearch = initData.routeSearch;
Init.programMode = initData.programMode;

View File

@@ -33,6 +33,10 @@ define([
slackChannelHistoryId: 'pf-map-dialog-slack-channel-history', // id for Slack channel "history"
slackChannelRallyId: 'pf-map-dialog-slack-channel-rally', // id for Slack channel "rally"
discordUsernameId: 'pf-map-dialog-discord-username', // id for Discord "username"
discordWebHookURLRallyId: 'pf-map-dialog-discord-url-rally', // id for Discord "rally" webHookUrl
discordWebHookURLHistoryId: 'pf-map-dialog-discord-url-history', // id for Discord "history" webHookUrl
characterSelectId: 'pf-map-dialog-character-select', // id for "character" select
corporationSelectId: 'pf-map-dialog-corporation-select', // id for "corporation" select
allianceSelectId: 'pf-map-dialog-alliance-select', // id for "alliance" select
@@ -133,6 +137,14 @@ define([
let slackRallyEnabled = false;
let slackSectionShow = false;
let discordUsername = '';
let discordWebHookURLRally = '';
let discordWebHookURLHistory = '';
let discordEnabled = false;
let discordRallyEnabled = false;
let discordHistoryEnabled = false;
let discordSectionShow = false;
if(mapData !== false){
// set current map information
contentEditMap.find('input[name="id"]').val( mapData.config.id );
@@ -162,6 +174,14 @@ define([
slackRallyEnabled = slackEnabled && Boolean(Util.getObjVal(Init.mapTypes, mapData.config.type.name + '.defaultConfig.send_rally_slack_enabled'));
slackSectionShow = (slackEnabled && slackWebHookURL.length > 0);
discordUsername = Util.getObjVal(mapData, 'config.logging.discordUsername');
discordWebHookURLRally = Util.getObjVal(mapData, 'config.logging.discordWebHookURLRally');
discordWebHookURLHistory = Util.getObjVal(mapData, 'config.logging.discordWebHookURLHistory');
discordEnabled = Boolean(Util.getObjVal(Init, 'discord.status'));
discordRallyEnabled = discordEnabled && Boolean(Util.getObjVal(Init.mapTypes, mapData.config.type.name + '.defaultConfig.send_rally_discord_enabled'));
discordHistoryEnabled = discordEnabled && Boolean(Util.getObjVal(Init.mapTypes, mapData.config.type.name + '.defaultConfig.send_history_discord_enabled'));
discordSectionShow = (discordEnabled && (discordWebHookURLRally.length > 0 || discordWebHookURLHistory.length > 0));
// remove "#" from Slack channels
slackChannelHistory = slackChannelHistory.indexOf('#') === 0 ? slackChannelHistory.substr(1) : slackChannelHistory;
slackChannelRally = slackChannelRally.indexOf('#') === 0 ? slackChannelRally.substr(1) : slackChannelRally;
@@ -221,6 +241,17 @@ define([
slackRallyEnabled: slackRallyEnabled,
slackSectionShow: slackSectionShow,
discordUsernameId: config.discordUsernameId,
discordWebHookURLRallyId: config.discordWebHookURLRallyId,
discordWebHookURLHistoryId: config.discordWebHookURLHistoryId,
discordUsername: discordUsername,
discordWebHookURLRally: discordWebHookURLRally,
discordWebHookURLHistory: discordWebHookURLHistory,
discordEnabled: discordEnabled,
discordRallyEnabled: discordRallyEnabled,
discordHistoryEnabled: discordHistoryEnabled,
discordSectionShow: discordSectionShow,
characterSelectId: config.characterSelectId,
corporationSelectId: config.corporationSelectId,
allianceSelectId: config.allianceSelectId,

View File

@@ -111,15 +111,15 @@
{{! Slack notification --------------------------------------------- }}
<h4 class="pf-dynamic-area {{^slackSectionShow}}collapsed{{/slackSectionShow}}" data-toggle="collapse" data-target="#pf-map-dialog-slack-section"><i class="fa fa-slack"></i> Slack notifications <small class="txt-color txt-color-warning">[BETA]</small></h4>
<h4 class="pf-dynamic-area {{^slackSectionShow}}collapsed{{/slackSectionShow}}" data-toggle="collapse" data-target="#pf-map-dialog-slack-section"><i class="fa fa-slack"></i>&nbsp;&nbsp;Slack notifications</h4>
<div id="pf-map-dialog-slack-section" class="collapse {{#slackSectionShow}}in{{/slackSectionShow}}">
<fieldset {{^slackEnabled}}disabled{{/slackEnabled}}>
<div class="row ">
<div class="col-xs-12 col-sm-12 col-md-6">
<div class="form-group">
<label for="{{slackWebHookURLId}}" class="col-sm-3 col-md-4 control-label">WebHookURL
<i class="fa fa-fw fa-question-circle pf-help-light" title="Insert your WebHook URL from the configuration page for 'Incoming WebHooks'"></i>
<label for="{{slackWebHookURLId}}" class="col-sm-3 col-md-4 control-label">WebHook
<i class="fa fa-fw fa-question-circle pf-help-light" title="Copy a WebHook URL from Slack configuration page for 'Incoming WebHooks'"></i>
</label>
<div class="col-sm-9 col-md-8">
<div class="input-group">
@@ -176,7 +176,7 @@
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<label for="{{slackChannelRallyId}}" class="col-sm-6 col-md-4 control-label">Channel 'rally point'
<i class="fa fa-fw fa-question-circle pf-help-light" title="Send new 'Rally point' notifications to a Slack channel."></i>
<i class="fa fa-fw fa-question-circle pf-help-light" title="Send new 'Rally point' notifications to a Slack channel"></i>
</label>
<div class="col-sm-6 col-md-8">
<div class="input-icon-left" {{^slackRallyEnabled}}title="Globally disabled for this map type"{{/slackRallyEnabled}}>
@@ -209,12 +209,83 @@
{{^slackEnabled}}
<div class="pf-dialog-info-container alert alert-info" style="display: block; opacity: 1; transform: translateY(0px);">
<span class="txt-color txt-color-information">Info</span>
<small>Slack API is disabled for your map type '{{ mapData.config.type.name }}'</small>
<small>Slack WebHooks are disabled for your map type '{{ mapData.config.type.name }}'</small>
</div>
{{/slackEnabled}}
</div>
{{! Discord notification --------------------------------------------- }}
<h4 class="pf-dynamic-area {{^discordSectionShow}}collapsed{{/discordSectionShow}}" data-toggle="collapse" data-target="#pf-map-dialog-discord-section"><i class="fa fa-microphone"></i>&nbsp;&nbsp;Discord notifications <small class="txt-color txt-color-warning">[BETA]</small></h4>
<div id="pf-map-dialog-discord-section" class="collapse {{#discordSectionShow}}in{{/discordSectionShow}}">
<fieldset {{^discordEnabled}}disabled{{/discordEnabled}}>
<div class="row ">
<div class="col-xs-12 col-sm-12 col-md-6">
<div class="form-group">
<label for="{{discordWebHookURLRallyId}}" class="col-sm-3 col-md-4 control-label">WebHook 'rally point'
<i class="fa fa-fw fa-question-circle pf-help-light" title="Copy a WebHook URL from Discord channel configuration page"></i>
</label>
<div class="col-sm-9 col-md-8">
<div class="input-group" {{^discordRallyEnabled}}title="Globally disabled for this map type"{{/discordRallyEnabled}}>
<input name="discordWebHookURLRally" type="url" class="form-control" id="{{discordWebHookURLRallyId}}" value="{{discordWebHookURLRally}}" placeholder="https://discordapp.com/api/webhooks/XXXYYYZZZ" data-type-error="No valid URL" pattern="^https://discordapp.com/.*" data-pattern-error="Wrong domain. https://discordapp.com/)" {{^discordRallyEnabled}}disabled{{/discordRallyEnabled}}>
<div class="input-group-btn">
<a class="btn btn-default" href="//support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks" target="_blank">
add… <i class="fa fa-fw fa-external-link "></i>
</a>
</div>
</div>
<div class="note help-block with-errors"></div>
</div>
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="form-group">
<label for="{{discordUsernameId}}" class="col-sm-6 col-md-4 control-label">Name
<i class="fa fa-fw fa-question-circle pf-help-light" title="Set a 'username' for your Discord bot"></i>
</label>
<div class="col-sm-6 col-md-8">
<input name="discordUsername" type="text" class="form-control" id="{{discordUsernameId}}" value="{{discordUsername}}" placeholder="Pathfinder bot" data-error="Please set a bot name">
<div class="note help-block with-errors"></div>
</div>
</div>
</div>
{{! group some columns -> Otherwise error msg would break the layout }}
<div class="clearfix"></div>
<div class="col-xs-12 col-sm-12 col-md-6">
<div class="form-group">
<label for="{{discordWebHookURLHistoryId}}" class="col-sm-3 col-md-4 control-label">WebHook 'map changes'
<i class="fa fa-fw fa-question-circle pf-help-light" title="Copy a WebHook URL from Discord channel configuration page"></i>
</label>
<div class="col-sm-9 col-md-8">
<div class="input-group" {{^discordHistoryEnabled}}title="Globally disabled for this map type"{{/discordHistoryEnabled}}>
<input name="discordWebHookURLHistory" type="url" class="form-control" id="{{discordWebHookURLHistoryId}}" value="{{discordWebHookURLHistory}}" placeholder="https://discordapp.com/api/webhooks/XXXYYYZZZ" data-type-error="No valid URL" pattern="^https://discordapp.com/.*" data-pattern-error="Wrong domain. https://discordapp.com/)" {{^discordHistoryEnabled}}disabled{{/discordHistoryEnabled}}>
<div class="input-group-btn">
<a class="btn btn-default" href="//support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks" target="_blank">
add… <i class="fa fa-fw fa-external-link "></i>
</a>
</div>
</div>
<div class="note help-block with-errors"></div>
</div>
</div>
</div>
</div>
</fieldset>
{{^discordEnabled}}
<div class="pf-dialog-info-container alert alert-info" style="display: block; opacity: 1; transform: translateY(0px);">
<span class="txt-color txt-color-information">Info</span>
<small>Discord WebHooks are disabled for your map type '{{ mapData.config.type.name }}'</small>
</div>
{{/discordEnabled}}
</div>
<h4 class="pf-dynamic-area">Share settings</h4>
<div class="row">

View File

@@ -72,7 +72,7 @@
<div class="col-xs-12">
<div class="well well-sm">
<div class="row">
<div class="col-xs-6 col-sm-2 col-md-2">Map settings:</div>
<div class="col-xs-6 col-sm-2 col-md-2">Map config:</div>
<div class="col-xs-6 col-sm-10 col-md-10 text-right">
Save map changes to logfile&nbsp;
{{#logHistoryEnabled}}

View File

@@ -193,9 +193,10 @@
<em>Slack</em> and Email pokes require a valid map configuration (map settings dialog) before they can be used.
</p>
<ul class="list-unstyled" style=" margin-left: 10px;">
<li>Desktop poke -<small> (send OS browser popup messages)</small></li>
<li>Slack poke -<small> (send poke message to a <em>Slack</em> channel)</small></li>
<li>Email poke -<small> (send a mail with your poke message)</small></li>
<li><i class="fa fa-volume-up fa-fw"></i> Desktop poke -<small> (send OS browser popup messages)</small></li>
<li><i class="fa fa-slack fa-fw"></i> Slack poke -<small> (send poke message to a <em>Slack</em> channel)</small></li>
<li><i class="fa fa-microphone fa-fw"></i> Discord poke -<small> (send poke message to a <em>Discord</em> channel)</small></li>
<li><i class="fa fa-envelope fa-fw"></i> Email poke -<small> (send a mail with your poke message)</small></li>
</ul>
<h4 id="pf-manual-scrollspy-anchor-system-waypoint"><i class="fa fa-flag-checkered fa-fw"></i> Waypoints</h4>
<p>

View File

@@ -129,7 +129,7 @@
<div class="col-xs-12">
<div class="well well-sm">
<div class="row">
<div class="col-xs-6 col-sm-2 col-md-2">Map settings:</div>
<div class="col-xs-6 col-sm-2 col-md-2">Map config:</div>
<div class="col-xs-6 col-sm-10 col-md-10 text-right">
Store user statistics&nbsp;
{{#logActivityEnabled}}

View File

@@ -16,6 +16,13 @@
</label>
</div>
<div class="checkbox {{#discordRallyEnabled}}checkbox-primary{{/discordRallyEnabled}}">
<input id="{{dialogRallyPokeDiscordId}}" name="pokeDiscord" value="1" type="checkbox" {{#discordRallyEnabled}}checked=""{{/discordRallyEnabled}}{{^discordRallyEnabled}}disabled{{/discordRallyEnabled}}>
<label for="{{dialogRallyPokeDiscordId}}">Discord poke
<i class="fa fa-fw fa-question-circle pf-help-light" title="Send Discord message to a public channel"></i>
</label>
</div>
<div class="checkbox {{#mailRallyEnabled}}checkbox-primary{{/mailRallyEnabled}}">
<input id="{{dialogRallyPokeMailId}}" name="pokeMail" value="1" type="checkbox" {{#mailRallyEnabled}}checked=""{{/mailRallyEnabled}}{{^mailRallyEnabled}}disabled{{/mailRallyEnabled}}>
<label for="{{dialogRallyPokeMailId}}">Mail poke
@@ -43,9 +50,9 @@
<div class="col-xs-12">
<div class="well well-sm">
<div class="row">
<div class="col-xs-6 col-sm-2">Map settings:</div>
<div class="col-xs-6 col-sm-4 text-right">
<i class="fa fa-fw fa-volume-up"></i> Desktop poke&nbsp;
<div class="col-xs-6 col-sm-4">Map config:</div>
<div class="col-xs-6 col-sm-2 text-right" title="Desktop poke">
<i class="fa fa-fw fa-volume-up"></i>&nbsp;
{{#desktopRallyEnabled}}
<kbd class="txt-color txt-color-success">enabled</kbd>
{{/desktopRallyEnabled}}
@@ -53,8 +60,8 @@
<kbd>disabled</kbd>
{{/desktopRallyEnabled}}
</div>
<div class="col-xs-6 col-sm-3 text-right">
</i> Slack poke&nbsp;
<div class="col-xs-6 col-sm-2 text-right" title="Slack poke">
<i class="fa fa-fw fa-slack"></i>
{{#slackRallyEnabled}}
<kbd class="txt-color txt-color-success">enabled</kbd>
{{/slackRallyEnabled}}
@@ -62,8 +69,17 @@
<kbd>disabled</kbd>
{{/slackRallyEnabled}}
</div>
<div class="col-xs-6 col-sm-3 text-right">
<i class="fa fa-fw fa-envelope"></i> Mail poke&nbsp;
<div class="col-xs-6 col-sm-2 text-right" title="Discord poke">
<i class="fa fa-fw fa-microphone"></i>&nbsp;
{{#discordRallyEnabled}}
<kbd class="txt-color txt-color-success">enabled</kbd>
{{/discordRallyEnabled}}
{{^discordRallyEnabled}}
<kbd>disabled</kbd>
{{/discordRallyEnabled}}
</div>
<div class="col-xs-6 col-sm-2 text-right" title="Mail poke">
<i class="fa fa-fw fa-envelope"></i>&nbsp;
{{#mailRallyEnabled}}
<kbd class="txt-color txt-color-success">enabled</kbd>
{{/mailRallyEnabled}}

View File

@@ -324,6 +324,19 @@
</check>
</td>
</tr>
<tr>
<td><i class="fa fa-fw fa-microphone"></i> Discord</td>
<td class="text-right col-md-2">
<check if="{{ @PATHFINDER.DISCORD.STATUS }}">
<true>
<kbd class="txt-color txt-color-success">enabled</kbd>
</true>
<false>
<kbd class="txt-color txt-color-warning">disabled</kbd>
</false>
</check>
</td>
</tr>
</tbody>
</table>
</div>