Skip to content
This repository has been archived by the owner on Oct 29, 2020. It is now read-only.

Added a new NumberOneRepo command #84

Open
wants to merge 1 commit into
base: vNext
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/functions/chat/NumberOneRepo/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": ["post"]
},
{
"type": "http",
"direction": "out",
"name": "res"
}
]
}
46 changes: 46 additions & 0 deletions src/functions/chat/NumberOneRepo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const io = require("socket.io-client");
require("dotenv").config();

const socket = io.connect(process.env.VULCANHUBURL);

module.exports = async function(context, req) {
// All chat functions will receive a payload of:
// {
// channel: string,
// tags: {
// badges?: Badges;
// color?: string;
// "display-name"?: string;
// emotes?: { [emoteid: string]: string[] };
// id?: string;
// mod?: boolean;
// turbo?: boolean;
// 'emotes-raw'?: string;
// 'badges-raw'?: string;
// "room-id"?: string;
// subscriber?: boolean;
// 'user-type'?: "" | "mod" | "global_mod" | "admin" | "staff";
// "user-id"?: string;
// "tmi-sent-ts"?: string;
// flags?: string;
// [paramater: string]: any;
// 'message-type'?: "chat" | "action" | "whisper";
// username?: string;
// bits?: string;
// },
// message: string,
// user: User
// }

const message =
"Want to contribute to the new hotness of the chatbot variety, head on over to https://github.com/MichaelJolley/number-one";

const payload = {
message,
messageType: "chat", // or 'whisper'
recipient: null // required when messageType === whisper
};

// Send a message to the Socket.io
socket.emit("newMessage", payload);
};