├── .gitignore
├── .dockerignore
├── .github
└── FUNDING.yml
├── Dockerfile
├── bot
├── helpers
│ ├── bindMethods.js
│ ├── ticker.js
│ ├── tasker.js
│ └── office.js
├── office-simulator.js
└── data
│ └── actions.js
├── index.js
├── package.json
├── license.md
└── readme.md
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/.dockerignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | npm-debug.log
3 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [tholman]
2 | custom: ['https://ko-fi.com/tholman', 'https://www.buymeacoffee.com/tholman']
3 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:10
2 | WORKDIR /usr/src/app
3 |
4 | COPY package*.json ./
5 |
6 | RUN npm install
7 |
8 | COPY . .
9 |
10 | CMD [ "node", "index.js" ]
11 |
--------------------------------------------------------------------------------
/bot/helpers/bindMethods.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Because scoping is hard
3 | */
4 |
5 | function bindMethods(context, methodNames) {
6 | methodNames.map(function (methodName) {
7 | context[methodName] = context[methodName].bind(context);
8 | });
9 | }
10 |
11 | module.exports = bindMethods;
12 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Office Simulator Slack Bot!
3 | * - Don't forget to clean your forks after using them!
4 | */
5 |
6 | const name = process.env.BOT_NAME || "Office Simulator";
7 | const token = process.env.SLACK_TOKEN || "THIS-NEEDS-CHANGING";
8 | const channel = process.env.CHANNEL || "general";
9 |
10 | var OfficeSimulator = require("./bot/office-simulator");
11 | var officeSimulator = new OfficeSimulator({
12 | token: token,
13 | channel: channel,
14 | name: name
15 | });
16 |
--------------------------------------------------------------------------------
/bot/helpers/ticker.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Keeping track of time!
3 | */
4 |
5 | var bindMethods = require("./bindMethods");
6 |
7 | class ticker {
8 | constructor(params) {
9 | this.intervalTime = params.interval;
10 | this.callback = params.callback;
11 | this.interval = null;
12 |
13 | bindMethods(this, ["callCallback"]);
14 |
15 | this.init();
16 | }
17 |
18 | init() {
19 | this.interval = setInterval(this.callCallback, this.intervalTime);
20 | }
21 |
22 | callCallback() {
23 | this.callback(new Date());
24 | }
25 | }
26 |
27 | module.exports = ticker;
28 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "office-simulator",
3 | "version": "1.0.0",
4 | "description": "Completely accurate simulator of office life.",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "node index.js"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/tholman/office-simulator.git"
13 | },
14 | "keywords": [
15 | "office",
16 | "simulator",
17 | "bot",
18 | "slack"
19 | ],
20 | "author": "Tim Holman",
21 | "license": "MIT",
22 | "bugs": {
23 | "url": "https://github.com/tholman/office-simulator/issues"
24 | },
25 | "homepage": "https://github.com/tholman/office-simulator#readme",
26 | "dependencies": {
27 | "slackbots": "^1.2.0"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/license.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Tim Holman (http://tholman.com)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/bot/helpers/tasker.js:
--------------------------------------------------------------------------------
1 | /**
2 | * What actions and when!
3 | */
4 |
5 | var bindMethods = require("./bindMethods");
6 |
7 | class tasker {
8 | constructor(data) {
9 | this.data = data;
10 | }
11 |
12 | getRandomAction() {
13 | var totalActions = this.data.actions.length;
14 |
15 | var action = Object.assign(
16 | {},
17 | this.data.actions[Math.floor(Math.random() * totalActions)]
18 | ); // Clone
19 | action.message = this.addVariantsToAction(action.message);
20 |
21 | return action;
22 | }
23 |
24 | getReaction(action) {
25 | return this.data.reactions[action];
26 | }
27 |
28 | addVariantsToAction(action) {
29 | var parsedAction = [];
30 | var splitAction = action.split("%");
31 |
32 | for (var i = 0; i < splitAction.length; i++) {
33 | if (this.data.variants[splitAction[i]]) {
34 | var variants = this.data.variants[splitAction[i]];
35 | parsedAction.push(
36 | variants[Math.floor(Math.random() * variants.length)]
37 | );
38 | } else {
39 | parsedAction.push(splitAction[i]);
40 | }
41 | }
42 |
43 | return parsedAction.join("");
44 | }
45 | }
46 |
47 | module.exports = tasker;
48 |
--------------------------------------------------------------------------------
/bot/office-simulator.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Bot Manager
3 | */
4 |
5 | var SlackBot = require("slackbots");
6 |
7 | var Ticker = require("./helpers/ticker");
8 | var Office = require("./helpers/office");
9 |
10 | var bindMethods = require("./helpers/bindMethods");
11 |
12 | class officeSimulator {
13 | // New Manager
14 | constructor(params) {
15 | this.token = params.token;
16 | this.name = params.name;
17 | this.channel = params.channel;
18 |
19 | // Off while in the plane
20 | this.bot = new SlackBot({
21 | token: this.token,
22 | name: this.name
23 | });
24 |
25 | bindMethods(this, ["init", "onTick"]);
26 |
27 | this.bot.on("start", this.init);
28 | }
29 |
30 | // Initial Announcement
31 | // Set up memory and timings
32 | init() {
33 | this.announce(
34 | "Hi, and welcome to Office Simulator. Remember there's no I in Team."
35 | );
36 |
37 | this.ticker = new Ticker({
38 | interval: 420000, // Check a tick every 7 minutes
39 | callback: this.onTick
40 | });
41 |
42 | this.office = new Office({
43 | floors: 3,
44 | hours: {
45 | open: 10, // 10
46 | close: 18 // til 6
47 | },
48 | objects: {}
49 | });
50 | }
51 |
52 | onTick(date) {
53 | // If there are announcements to be made, announce them!
54 | var announcement = this.office.getAnnouncement(date);
55 | if (!announcement) {
56 | return;
57 | }
58 |
59 | this.announce(announcement.item.message);
60 | }
61 |
62 | // Speak!
63 | announce(announcement) {
64 | this.bot.postMessageToChannel(this.channel, announcement, {
65 | icon_emoji: ":chart_with_downwards_trend:"
66 | });
67 | }
68 | }
69 |
70 | module.exports = officeSimulator;
71 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Office Simulator Slackbot
2 | Office slack messages are the passive agressive post-its of the modern world. Do you miss the office life? You won't any more with this realistic office slack simulator.
3 |
4 | ## In action
5 | We have spared no expense, simulating the most realistic office messages, so you are never really at ease!
6 |
7 |
8 |
9 |
10 |
11 |
12 | **This is serious stuff**
13 | - Complete Realism
14 | - 100% vetted passive agression!
15 | - And of course, it REMEMBERS!
16 |
17 |
18 |
19 | *... 5 days later:*
20 |
21 |
22 |
23 | **Lets see that again!**
24 |
25 |
26 |
27 | *... 8 days later:*
28 |
29 |
30 |
31 | ## Installation
32 |
33 | 1. Firstly, you will need to create a new "bot" integration, in your slack [settings](http://my.slack.com/services/new/bot). Type a username `Office Simulator` and click "Add Bot Integration".
34 |
35 | 2. Once the bot is created, you will be shown an `API token` ... copy this, we'll need it later.
36 |
37 | 3. Next, clone this project, or download it as a [ZIP](https://github.com/tholman/office-simulator/archive/master.zip) and extract it.
38 |
39 | 4. Open up `index.js` in the root directory, and add replace `SLACK_API_TOKEN` with your slack token. You can also change the channel from `general` to one of your other channels, if you wish.
40 |
41 | 5. Finally, run `npm install` and `npm start` in the project, and you should see the initial team building message.
42 |
43 | ## Something to add?
44 |
45 | Please, add new messages for the slackbot, etc, to the `/data/actions.js` file... you can use the `%modifier%` to add custom random alterations, as well as the `reaction` key, to add custom reactions.
46 |
47 | Submit a PR, and I'll check it out!
48 |
49 | ## Note
50 |
51 | Office simulator only posts once or twice a day, so if it doesn't seem to be constantly going, its due to painstakingly accurate realism.
52 |
53 | ## License
54 |
55 | The MIT License
56 |
57 | Copyright (c) 2020 Tim Holman - http://tholman.com
58 |
--------------------------------------------------------------------------------
/bot/helpers/office.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Keeping track of time!
3 | */
4 |
5 | var bindMethods = require("./bindMethods");
6 | var actionData = require("../data/actions");
7 | var Tasker = require("./tasker");
8 |
9 | class office {
10 | constructor(params) {
11 | this.floors = params.floors;
12 | this.objects = params.objects;
13 | this.hours = params.hours;
14 | this.shedule = [];
15 | this.tasker = new Tasker(actionData);
16 |
17 | this.init();
18 | }
19 |
20 | init() {
21 | // Shedule an initial item
22 | this.sheduleItem(new Date(), this.tasker.getRandomAction());
23 | }
24 |
25 | sheduleItem(date, item) {
26 | this.shedule.push({ date: date, item: item });
27 | }
28 |
29 | sheduleReaction(announcement) {
30 | var futureDate = this.getRandomTimeInOfficeHours();
31 |
32 | // Any future date further than 2 days ahead
33 | futureDate.setDate(
34 | futureDate.getDate() + Math.floor(Math.random() * 10) + 2
35 | );
36 | futureDate = this.getNonWeekendDate(futureDate);
37 |
38 | this.sheduleItem(futureDate, announcement);
39 | }
40 |
41 | getAnnouncement(date) {
42 | for (var i = 0; i < this.shedule.length; i++) {
43 | var announcement = this.shedule[i];
44 |
45 | // If announcement is past due time, announce it
46 |
47 | console.log(date, announcement.date, announcement.date < date);
48 | if (announcement.date < date) {
49 | // Remove it from the TO BE shedule
50 | this.shedule.splice(i, 1);
51 |
52 | // If there are no actions sheduled, shedule another
53 | if (this.shedule.length === 0) {
54 | this.sheduleItem(
55 | this.getRandomTimeInOfficeHours(),
56 | this.tasker.getRandomAction()
57 | );
58 | }
59 |
60 | // If it has a "reaction", shedule the reaction
61 | if (announcement.item.reaction) {
62 | this.sheduleReaction(
63 | this.tasker.getReaction(announcement.item.reaction)
64 | );
65 | }
66 |
67 | // Announce the current item!
68 | return announcement;
69 | }
70 | }
71 | }
72 |
73 | // Return random time tomorrow
74 | getRandomTimeInOfficeHours() {
75 | var date = new Date();
76 |
77 | // Tomorrow (but not weekend)
78 | date.setDate(date.getDate() + 1);
79 | date = this.getNonWeekendDate(date);
80 |
81 | // Random hour between opening and closing;
82 | date.setHours(
83 | Math.floor(Math.random() * (this.hours.close - this.hours.open + 1)) +
84 | this.hours.open
85 | );
86 |
87 | // Random Minute
88 | date.setMinutes(Math.floor(Math.random() * 59));
89 |
90 | return date;
91 | }
92 |
93 | getNonWeekendDate(date) {
94 | if (date.getDay() < 1) {
95 | date.setDate(date.getDate() + 1);
96 | } else if (date.getDay() > 5) {
97 | date.setDate(date.getDate() + 3);
98 | }
99 |
100 | return date;
101 | }
102 | }
103 |
104 | module.exports = office;
105 |
--------------------------------------------------------------------------------
/bot/data/actions.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Actions
3 | * - Json object of what the bot can say, and proceeding actions
4 | */
5 |
6 | var variants = {
7 | days: ["today", "tomorrow", "on Monday", "on Tuesday", "on Wednesday", "on Thursday", "on Friday"],
8 | eatingItems: ["forks", "spoons", "mugs", "cups"],
9 | rooms: ["kitchen", "bathroom", "phone booth"],
10 | stationary: ["stapler", "hole punch", "glue pot"],
11 | websites: ["Facebook", "YouTube", "Reddit"],
12 | foodItems: ["yogurt", "raisins", "tomatoes", "eggs"],
13 | passiveAggressiveOpeners: [""],
14 | passiveAggresiveClosers: ["", "", "", "", "I'll be keeping my eye out.", "We're all on the same team here.", "I'm not your mother.", "Creatives! This is about you!"], // Seeded with more "ignores";
15 | printerCodes: ["030f", "030g", "b-01", "b-03", "6830_1", "6830_2", "6830_3"]
16 | }
17 |
18 | // Not all actions have an equal or opposite reaction
19 | var actions = [
20 |
21 | {
22 | message: "Remember, we have clients in the office %days% so everyone be quiet near the meeting rooms."
23 | },
24 |
25 | {
26 | message: "Whoever made the mess in the %rooms%, learn to clean up after yourself!"
27 | },
28 |
29 | {
30 | message: "Hey all, don't forget to wash your %eatingItems% after you eat!"
31 | },
32 |
33 | {
34 | message: "Just a little reminder, all food left in the fridge without a name on it will be thrown away at the end of the day."
35 | },
36 |
37 | {
38 | message: "Everyone will recieve a lunch survey in their inbox today, please fill it out %days%! Feel free to suggest options as well.",
39 | reaction: "lunch-survey"
40 | },
41 |
42 | {
43 | message: "Remember! I don't want to name names but if you're borrowing the office %stationary%, please RETURN it to its correct position."
44 | },
45 |
46 | {
47 | message: "%websites% is NOT allowed in the office, we don't want to have to block it, but we will if it continues being a problem."
48 | },
49 |
50 | {
51 | message: "I'll be going to the stationary store later, if anyone needs anything?"
52 | },
53 |
54 | {
55 | message: "Everyone, remember to fill out your timesheets before the end of the month.",
56 | reaction: "timesheets"
57 | },
58 |
59 | {
60 | message: "Whoever left the open yogurt in the fridge, please remove it.",
61 | reaction: "yogurt"
62 | },
63 |
64 | {
65 | message: "Someone's been overwatering the plants again, please leave it to facilities to water them."
66 | },
67 |
68 | {
69 | message: "Please make sure you keep your workspace clean and professional, remember we have clients visiting soon!"
70 | },
71 |
72 | {
73 | message: "You do NOT need to turn the toaster off at the wall, this is the third time this week! %passiveAggresiveClosers%"
74 | },
75 |
76 | {
77 | message: "The %printerCodes% printer on the first floor is out of ink, we've ordered some more, but don't expect it in until next Wednesday."
78 | },
79 |
80 | {
81 | message: "Reminder: We have no problem with listening to music while you work, BUT, you must use headphones... otherwise the noise is distracting to others trying to work."
82 | },
83 |
84 | {
85 | message: "This is the third time this year we've had to buy new %eatingItems% for the office... please don't take these home, they're for everyone."
86 | },
87 |
88 | {
89 | message: "Remember, (@)channeling everyone is against our corporate policy, no matter how dire."
90 | },
91 |
92 | {
93 | message: "Don't forget, it's casual day tomorrow... this doesn't mean jeans and a t shirt, please still dress smart."
94 | },
95 |
96 | {
97 | message: "Don't forget to log your sick days into the system, tracking these IS important."
98 | },
99 |
100 | {
101 | message: "Yes, we are aware of the current paper shortage, and have ordered more. Please do your photocopies on the first floor, until new supplies arrive.",
102 | reaction: "paper-shortage"
103 | },
104 |
105 | {
106 | message: "Seems like it's time everyone read over our office email policy again, especially regarding personal emails."
107 | },
108 |
109 | {
110 | message: "Don't forget the ergonomics lunch and learn later today!"
111 | },
112 |
113 | {
114 | message: "Everyone, please remember to pick up your packages from the package room, it's beginning to look like a pig sty in there."
115 | },
116 | {
117 | message: "Don't forget to check all recipients on an email BEFORE hitting send on a reply/reply all! If you need cold medicine or scissors, check the supply room first."
118 | },
119 | {
120 | message: "Please DO NOT use the staple feature on the %printerCodes% printer. This breaks it. A manual stapler has been provided.",
121 | reaction: "printer-stapler"
122 | }
123 | ]
124 |
125 | var reactions = {
126 | "lunch-survey": {
127 | message: "Well, it looks like only a few of you filled out that lunch survey, so, for better or for worse, it will be the same lunch this week as last."
128 | },
129 | "yogurt": {
130 | message: "Well, looks like no one removed the yogurt, and now we are growing all sorts of moulds in the fridge. Great."
131 | },
132 | "paper-shortage": {
133 | message: "Ok, we have new paper again. This should get us through the month."
134 | },
135 | "timesheets": {
136 | message: "Seriously, no one has put in a single timesheet. Come on people!"
137 | },
138 | "printer-stapler": {
139 | message: "Was a warning not posted? The printer is no longer working due to someone trying to use the staple feature. Expect it to be fixed %days%"
140 | },
141 | };
142 |
143 | module.exports = {variants: variants, actions: actions, reactions: reactions};
144 |
--------------------------------------------------------------------------------