Commit 647f44df authored by Farid Neshat's avatar Farid Neshat

Initial commit

parents
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
/node_modules
/pip
/tmp
hubot-goodmorning
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value>
<option name="RIGHT_MARGIN" value="80" />
<MarkdownNavigatorCodeStyleSettings>
<option name="WRAP_ON_TYPING" value="1" />
<option name="DISABLE_WRAP_IN_SOFT_WRAP" value="false" />
<option name="FORMAT_WITH_SOFT_WRAP" value="1" />
<option name="RIGHT_MARGIN" value="72" />
</MarkdownNavigatorCodeStyleSettings>
<codeStyleSettings language="JavaScript">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
</value>
</option>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</component>
</project>
\ No newline at end of file
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<option name="RIGHT_MARGIN" value="80" />
<MarkdownNavigatorCodeStyleSettings>
<option name="WRAP_ON_TYPING" value="1" />
<option name="DISABLE_WRAP_IN_SOFT_WRAP" value="false" />
<option name="FORMAT_WITH_SOFT_WRAP" value="1" />
<option name="RIGHT_MARGIN" value="72" />
</MarkdownNavigatorCodeStyleSettings>
<codeStyleSettings language="JavaScript">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
</component>
\ No newline at end of file
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/aws-list.py" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="mocha-DefinitelyTyped" level="application" />
<orderEntry type="library" name="sinon-chai-DefinitelyTyped" level="application" />
<orderEntry type="library" name="chai-DefinitelyTyped" level="application" />
<orderEntry type="library" name="sinon-DefinitelyTyped" level="application" />
<orderEntry type="library" name="node-DefinitelyTyped" level="application" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="JSNonStrictModeUsed" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="PROJECT" libraries="{chai-DefinitelyTyped, mocha-DefinitelyTyped, node-DefinitelyTyped, sinon-DefinitelyTyped, sinon-chai-DefinitelyTyped}" />
<includedPredefinedLibrary name="Node.js Core" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownProjectSettings">
<PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="false" showSelectionInPreview="true">
<PanelProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
</PanelProvider>
</PreviewSettings>
<ParserSettings gitHubSyntaxChange="false">
<PegdownExtensions>
<option name="ABBREVIATIONS" value="false" />
<option name="ANCHORLINKS" value="true" />
<option name="ASIDE" value="false" />
<option name="ATXHEADERSPACE" value="true" />
<option name="AUTOLINKS" value="true" />
<option name="DEFINITIONS" value="false" />
<option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
<option name="FENCED_CODE_BLOCKS" value="true" />
<option name="FOOTNOTES" value="false" />
<option name="HARDWRAPS" value="false" />
<option name="HTML_DEEP_PARSER" value="false" />
<option name="INSERTED" value="false" />
<option name="QUOTES" value="false" />
<option name="RELAXEDHRULES" value="true" />
<option name="SMARTS" value="false" />
<option name="STRIKETHROUGH" value="true" />
<option name="SUBSCRIPT" value="false" />
<option name="SUPERSCRIPT" value="false" />
<option name="SUPPRESS_HTML_BLOCKS" value="false" />
<option name="SUPPRESS_INLINE_HTML" value="false" />
<option name="TABLES" value="true" />
<option name="TASKLISTITEMS" value="true" />
<option name="TOC" value="false" />
<option name="WIKILINKS" value="true" />
</PegdownExtensions>
<ParserOptions>
<option name="COMMONMARK_LISTS" value="true" />
<option name="DUMMY" value="false" />
<option name="EMOJI_SHORTCUTS" value="true" />
<option name="FLEXMARK_FRONT_MATTER" value="false" />
<option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
<option name="GFM_TABLE_RENDERING" value="true" />
<option name="GITBOOK_URL_ENCODING" value="false" />
<option name="GITHUB_EMOJI_URL" value="false" />
<option name="GITHUB_LISTS" value="false" />
<option name="GITHUB_WIKI_LINKS" value="true" />
<option name="JEKYLL_FRONT_MATTER" value="false" />
<option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
</ParserOptions>
</ParserSettings>
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true">
<GeneratorProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
</GeneratorProvider>
<headerTop />
<headerBottom />
<bodyTop />
<bodyBottom />
</HtmlSettings>
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssTextEnabled="false" isDynamicPageWidth="true">
<StylesheetProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
</StylesheetProvider>
<ScriptProviders />
<cssText />
</CssSettings>
<HtmlExportSettings updateOnSave="false" parentDir="$ProjectFileDir$" targetDir="$ProjectFileDir$" cssDir="" scriptDir="" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetExt="" useTargetExt="false" noCssNoScripts="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" />
<LinkMapSettings>
<textMaps />
</LinkMapSettings>
</component>
</project>
\ No newline at end of file
<component name="MarkdownNavigator.ProfileManager">
<settings default="" pdf-export="" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/hubot-goodmorning.iml" filepath="$PROJECT_DIR$/.idea/hubot-goodmorning.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectTasksOptions" suppressed-tasks="Babel" />
</project>
\ No newline at end of file
This diff is collapsed.
The MIT License (MIT)
Copyright (c) 2017 Olindata BV
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# hubot-human-goodmorning
A hubot scripts that says goodmorning once day sometime randomly after somebody else has
said it. It'll wait maximum one hour.
## Installation
In hubot project repo, run:
`npm install hubot-human-goodmorning --save`
Then add **hubot-human-goodmorning** to your `external-scripts.json`:
```json
[
"hubot-human-goodmorning"
]
```
## Configuration
You can limit the responses to one room/channel by setting `MORNING_ROOM_ID`
## Sample Interaction
```
user1>> Good morning
...
sometime later
...
hubot>> Morning people
```
## NPM Module
https://www.npmjs.com/package/hubot-human-goodmorning
## License
The MIT License (MIT)
Copyright (c) 2017 Olindata BV
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
const fs = require('fs');
const path = require('path');
module.exports = function(robot, scripts) {
const scriptsPath = path.resolve(__dirname, 'src');
if (fs.existsSync(scriptsPath)) {
for (let script of fs.readdirSync(scriptsPath).sort()) {
if (scripts != null && !scripts.includes('*')) {
if (scripts.includes(script)) {
robot.loadFile(scriptsPath, script);
}
} else {
robot.loadFile(scriptsPath, script);
}
}
}
};
{
"name": "hubot-human-goodmorning",
"version": "0.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"just-random": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/just-random/-/just-random-2.0.0.tgz",
"integrity": "sha1-VPgcLOJUWKHhvjSRphFG1Rxw4O4="
}
}
}
{
"name": "hubot-human-goodmorning",
"description": "A hubot scripts that says goodmorning only once and after somebody else has said it",
"version": "0.0.0",
"author": "Farid Nouri Neshat <Farid@Olindata.com>",
"license": "MIT",
"keywords": [
"hubot",
"hubot-scripts",
"goodmorning",
"good-morning",
"morning"
],
"repository": {
"type": "git",
"url": "https://gitlab.olindata.com/olindata/hubot-human-goodmorning.git"
},
"bugs": {
"url": "https://gitlab.olindata.com/olindata/hubot-human-goodmorning/issues"
},
"dependencies": {
"just-random": "^2.0.0"
},
"peerDependencies": {
"hubot": "2.x"
},
"devDependencies": {},
"main": "index.js",
"scripts": {}
}
#!/bin/bash
# Make sure everything is development forever
export NODE_ENV=development
# Load environment specific environment variables
if [ -f .env ]; then
source .env
fi
if [ -f .env.${NODE_ENV} ]; then
source .env.${NODE_ENV}
fi
npm install
# Make sure coffee and mocha are on the path
export PATH="node_modules/.bin:$PATH"
\ No newline at end of file
!/bin/bash
# bootstrap environment
source script/bootstrap
mocha
// Description
// A hubot scripts that says goodmorning only once and after somebody else has said it
//
// Configuration:
//
// MORNING_ROOM_ID
//
// Commands
//
// Notes:
//
// Author:
// Farid Nouri Neshat <Farid@Olindata.com>
'use strict';
const ONE_HOUR = 1000 * 60 * 60; const ONE_DAY = ONE_HOUR * 24; const random = require('just-random');
const mornings = [
'marnin',
'morning',
'morning',
'morning',
'morning',
'morning',
'morning',
'moin',
];
const place = [
'AWS',
'cloud',
'home',
'the VPC',
'EC2',
'office'
];
const endings = ['', '', '.', '.', '!', '!', '...', '...', '!!!'];
const smileys = ['', '', '', '', '', ' :D', ' :)'];
const isLikely = (p = 0.1) => Math.random() < p;
const isMorning = () => {
const hour = new Date().getHours();
return hour < 11 && hour > 6;
};
module.exports = function (robot) {
let lastTime = null;
robot.hear(/morning|moin/i, res => {
if (process.env.MORNING_ROOM_ID) {
if (res.message.room !== process.env.MORNING_ROOM_ID) {
return;
}
}
const day = Date.now() / ONE_DAY;
if (day > lastTime && isMorning()) {
setTimeout(() => {
let message = random(mornings);
if (isLikely()) {
message += ' people';
}
if (isLikely()) {
if (isLikely()) {
message += '. I\'m';
}
message += ' working from ' + random(place);
if (isLikely()) {
message += ' today';
}
}
if (isLikely()) {
message += '. Ready for your commands';
}
message += random(endings) + random(smileys);
res.send(message);
}, Math.random() * ONE_HOUR);
lastTime = day;
}
});
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment