-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace ESLint configuration with neostandard; update lint script and…
… clean up code formatting
- Loading branch information
Showing
9 changed files
with
4,040 additions
and
6,490 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
// @ts-check | ||
|
||
import { ActivityHandler, MessageFactory, MsalTokenProvider } from '@microsoft/agents-bot-hosting' | ||
import { default as pjson } from '../node_modules/@microsoft/agents-bot-hosting/package.json' with { type: "json" } | ||
import { ActivityHandler, MessageFactory } from '@microsoft/agents-bot-hosting' | ||
import pjson from '@microsoft/agents-bot-hosting/package.json' | ||
|
||
export class EchoBot extends ActivityHandler { | ||
constructor() { | ||
super() | ||
this.onMessage(async (context, next) => { | ||
const text = context.activity.text | ||
const replyText = `Echo: ${ text }` | ||
await context.sendActivity(MessageFactory.text(replyText, replyText)) | ||
if (text?.includes('version')) { | ||
await context.sendActivity(MessageFactory.text('Running on version ' + pjson.version, 'Running on version ' + pjson.version)) | ||
} | ||
await next() | ||
}); | ||
constructor () { | ||
super() | ||
this.onMessage(async (context, next) => { | ||
const text = context.activity.text | ||
const replyText = `Echo: ${text}` | ||
await context.sendActivity(MessageFactory.text(replyText, replyText)) | ||
if (text?.includes('version')) { | ||
await context.sendActivity(MessageFactory.text('Running on version ' + pjson.version, 'Running on version ' + pjson.version)) | ||
} | ||
await next() | ||
}) | ||
|
||
this.onMembersAdded(async (context, next) => { | ||
const welcomeText = `Hello from echo bot, running on version ${ pjson.version }` | ||
const membersAdded = context.activity.membersAdded | ||
if (membersAdded) { | ||
for (let cnt = 0; cnt < membersAdded.length; ++cnt) { | ||
if (membersAdded[cnt].id !== context.activity.recipient?.id) { | ||
await context.sendActivity(MessageFactory.text(welcomeText, welcomeText)) | ||
} | ||
} | ||
} | ||
await next() | ||
}) | ||
} | ||
this.onMembersAdded(async (context, next) => { | ||
const welcomeText = `Hello from echo bot, running on version ${pjson.version}` | ||
const membersAdded = context.activity.membersAdded | ||
if (membersAdded) { | ||
for (let cnt = 0; cnt < membersAdded.length; ++cnt) { | ||
if (membersAdded[cnt].id !== context.activity.recipient?.id) { | ||
await context.sendActivity(MessageFactory.text(welcomeText, welcomeText)) | ||
} | ||
} | ||
} | ||
await next() | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
// @ts-check | ||
import express, { json } from 'express'; | ||
import express, { json } from 'express' | ||
|
||
import { CloudAdapter, loadAuthConfigFromEnv, authorizeJWT } from '@microsoft/agents-bot-hosting'; | ||
import { CloudAdapter, loadAuthConfigFromEnv, authorizeJWT } from '@microsoft/agents-bot-hosting' | ||
|
||
import { EchoBot } from './bot.js'; | ||
import { default as pjson } from '../node_modules/@microsoft/agents-bot-hosting/package.json' with { type: "json" } | ||
import { EchoBot } from './bot.js' | ||
import pjson from '@microsoft/agents-bot-hosting/package.json' | ||
|
||
const config = loadAuthConfigFromEnv() | ||
const adapter = new CloudAdapter(config); | ||
const adapter = new CloudAdapter(config) | ||
const myBot = new EchoBot() | ||
|
||
|
||
const server = express() | ||
server.use(express.static('public')) | ||
server.use(authorizeJWT(config)) | ||
|
||
server.use(json()) | ||
server.post('/api/messages', | ||
async (req, res) => { | ||
await adapter.process(req, res, (context) => myBot.run(context)); | ||
} | ||
async (req, res) => { | ||
await adapter.process(req, res, (context) => myBot.run(context)) | ||
} | ||
) | ||
|
||
const port = process.env.PORT || 3978 | ||
|
||
server.listen(port, () => { | ||
console.log(`\n echo bot, running on sdk version ${ pjson.version } lisenting on ${ port } for bot ${ process.env.clientId }`); | ||
}) | ||
console.log(`\n echo bot, running on sdk version ${pjson.version} lisenting on ${port} for bot ${process.env.clientId}`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import neostandard from 'neostandard' | ||
|
||
export default neostandard({ ts: true, ignores: ['node_modules', '**/dist/**'] }) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.