```sh ./a.sh
#!/bin/bash
# Help message function
show_help() {
echo "Usage: $0 [directory] [output_file]"
echo
echo "Aggregates code files into a single markdown file with code blocks"
echo
echo "Arguments:"
echo " directory Directory to scan for code files (default: current directory)"
echo " output_file Output file name (default: aggregated_code.md)"
echo
echo "Example:"
echo " $0 ./my_project output.md"
}
# Default values
dir="${1:-.}"
output_file="${2:-aggregated_code.md}"
# Show help if requested
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
show_help
exit 0
fi
# Check if directory exists
if [ ! -d "$dir" ]; then
echo "Error: Directory '$dir' not found!"
exit 1
fi
# Clear or create output file
> "$output_file"
# Find and process files
find "$dir" -type f \( -name "*.py" -o -name "*.js" -o -name "*.ts" -o -name "*.jsx" -o -name "*.tsx" -o -name "*.html" -o -name "*.css" -o -name "*.java" -o -name "*.cpp" -o -name "*.c" -o -name "*.sh" \) | while read -r file; do
# Get the file extension
ext="${file##*.}"
# Add the markdown code block header
echo -e "\`\`\`$ext $file" >> "$output_file"
# Add the file content
cat "$file" >> "$output_file"
# Add the closing code block
echo -e "\`\`\`\n" >> "$output_file"
done
echo "Files have been aggregated into $output_file"```
```html ./public/index.html
{title} | General Bots
```
```js ./src/players/GBUrlPlayer.js
/*****************************************************************************\
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
| |
| General Bots Copyright (c) pragmatismo.cloud. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.cloud. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React, { Component } from "react";
class GBUrlPlayer extends Component {
constructor() {
super();
this.state = {
src: ""
};
}
play(url) {
this.setState({ src: url });
}
stop() {
this.setState({ src: "" });
}
render() {
return (
);
}
}
export default GBUrlPlayer;```
```js ./src/players/GBImagePlayer.js
/*****************************************************************************\
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
| |
| General Bots Copyright (c) pragmatismo.cloud. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.cloud. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React, { Component } from 'react';
class GBImagePlayer extends Component {
constructor() {
super();
this.state = {};
}
play(url) {
this.playerImage.src = url;
}
stop() {
this.playerImage.src = '';
}
render() {
return (
);
}
}
export default GBImagePlayer;
```
```js ./src/players/GBBulletPlayer.js
/*****************************************************************************\
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
| |
| General Bots Copyright (c) pragmatismo.cloud. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.cloud. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React, { Component } from "react";
class RenderItem extends Component {
send(item) {
setTimeout(()=>{
window.botConnection
.postActivity({
type: "event",
name: "answerEvent",
data: item.questionId,
locale: "en-us",
textFormat: "plain",
timestamp: new Date().toISOString(),
from: window.user
})
},400);
}
render() {
return (
);
}
}
export default GBBulletPlayer;
```
```js ./src/players/GBLoginPlayer.js
/*****************************************************************************\
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
| |
| General Bots Copyright (c) pragmatismo.cloud. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.cloud. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React from "react";
import { UserAgentApplication } from "msal";
class GBLoginPlayer extends React.Component {
constructor() {
super();
this.state = {
login: {}
};
}
doLogin() {
let authority =
"https://login.microsoftonline.com/" +
this.state.login.authenticatorTenant;
let graphScopes = ["Directory.AccessAsUser.All"];
let userAgentApplication = new UserAgentApplication(
this.state.login.authenticatorClientId,
authority,
function (errorDesc, token, error) {
if (error) {
this.setState({ login: error});
}
})
userAgentApplication.loginRedirect(graphScopes);
}
play(data) {
this.setState({ login: data });
}
stop() {
this.setState({ login: [] });
}
render() {
return ;
}
}
export default GBLoginPlayer;
```
```js ./src/players/GBVideoPlayer.js
/*****************************************************************************\
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
| |
| General Bots Copyright (c) pragmatismo.cloud. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.cloud. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React, { Component } from "react";
class GBVideoPlayer extends Component {
constructor() {
super();
this.state = {
src: ""
};
}
play(url) {
this.setState({ src: url });
this.refs.video.play();
}
stop() {
this.setState({ src: "" });
}
render() {
return (
);
}
}
export default GBVideoPlayer;
```
```js ./src/players/GBMultiUrlPlayer.js
/*****************************************************************************\
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
| |
| General Bots Copyright (c) pragmatismo.cloud. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.cloud. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React, { Component } from 'react';
class RenderItem extends Component {
send(item) {
setTimeout(() => {
window.botConnection.postActivity({
type: 'event',
name: 'answerEvent',
data: item.questionId,
locale: 'en-us',
textFormat: 'plain',
timestamp: new Date().toISOString(),
from: window.user
});
}, 400);
}
render() {
return (
);
}
}
export default GBMultiUrlPlayer;
```
```js ./src/players/GBMarkdownPlayer.js
/*****************************************************************************\
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
| |
| General Bots Copyright (c) pragmatismo.cloud. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.cloud. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React, { Component } from "react";
class GBMarkdownPlayer extends Component {
send(value) {
setTimeout(() => {
window.botConnection
.postActivity({
type: "event",
name: "quality",
data: value,
locale: "en-us",
textFormat: "plain",
timestamp: new Date().toISOString(),
from: { id: "webUser", name: "You" }
})
}, 400);
}
sendAnswer(text) {
setTimeout(() => {
window.botConnection
.postActivity({
type: "event",
name: "answerEvent",
data: text,
locale: "en-us",
textFormat: "plain",
timestamp: new Date().toISOString(),
from: window.user
})
}, 400);
}
constructor() {
super();
this.state = {
content: "",
prevId: 0,
nextId: 0
};
}
play(data) {
this.setState({ content: data.content, prevId: data.prevId, nextId: data.nextId });
}
stop() {
this.setState({ content: "" });
}
createMarkup() {
return { __html: this.state.content };
}
clickYes() {
this.send(1);
}
clickNo() {
this.send(0);
}
render() {
var quality =
(this.quality = i)}>Is the answer OK?
|
;
var next = "", prev = "";
if (this.state.content === "") {
quality = "";
}
if (this.state.prevId) {
prev =
}
if (this.state.nextId) {
next =
}
return (
(this.playerText = i)} className="media-player">
{prev}{next}
{quality}
);
}
}
export default GBMarkdownPlayer;
```
```js ./src/components/SidebarMenu.js
/*****************************************************************************\
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
| |
| General Bots Copyright (c) pragmatismo.cloud. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.cloud. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React from "react";
class SideBarMenu extends React.Component {
send(command) {
window.botConnection
.postActivity({
type: "event",
name: command,
locale: "en-us",
textFormat: "plain",
timestamp: new Date().toISOString()
});
}
render() {
return (
);
}
}
export default SideBarMenu;
```
```js ./src/components/Footer.js
/*****************************************************************************\
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
| |
| General Bots Copyright (c) pragmatismo.cloud. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.cloud. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React from "react"
const footer = () => (
// );
// }
// }
```
```js ./src/components/NavBar.js
/*****************************************************************************\
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
| |
| General Bots Copyright (c) pragmatismo.cloud. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.cloud. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React, {PropTypes as T} from "react"
const navBar = ({ onChange, onSearch }) => (
);
export default navBar```
```js ./src/components/SEO.js
/*****************************************************************************\
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
| |
| General Bots Copyright (c) pragmatismo.cloud. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.cloud. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React from "react"
import { SuperSEO } from 'react-super-seo';
class SEO extends React.Component {
render() {
let output = "";
if (this.props.instance) {
output = (
);
} else {
output = ;
}
return output;
}
}
export default SEO```
```js ./src/components/ChatPane.js
/*****************************************************************************\
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
| |
| General Bots Copyright (c) pragmatismo.cloud. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.cloud. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React from "react";
import { Chat } from "botframework-webchat";
class ChatPane extends React.Component {
render() {
return (
{ this.chat = chat; }}
botConnection={this.props.botConnection}
user={{ id: "webUser@gb", name: "You" }}
bot={{ id: "bot@gb", name: "Bot" }}
/>
);
}
}
export default ChatPane;
```
```js ./src/index.js
/*****************************************************************************\
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
| |
| General Bots Copyright (c) pragmatismo.cloud. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.cloud. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React from "react";
import ReactDOM from "react-dom";
import GBUIApp from "./GBUIApp";
ReactDOM.render(
,
document.getElementById("root")
);
```
```js ./src/GBUIApp.js
/*****************************************************************************\
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
| |
| General Bots Copyright (c) pragmatismo.cloud. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.cloud. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React from 'react';
import GBMarkdownPlayer from './players/GBMarkdownPlayer.js';
import GBImagePlayer from './players/GBImagePlayer.js';
import GBVideoPlayer from './players/GBVideoPlayer.js';
import GBUrlPlayer from './players/GBUrlPlayer.js';
import GBMultiUrlPlayer from './players/GBMultiUrlPlayer.js';
import GBLoginPlayer from './players/GBLoginPlayer.js';
import GBBulletPlayer from './players/GBBulletPlayer.js';
import SidebarMenu from './components/SidebarMenu.js';
import SEO from './components/SEO.js';
import GBCss from './components/GBCss.js';
import { DirectLine } from 'botframework-directlinejs';
import { ConnectionStatus } from 'botframework-directlinejs';
import ReactWebChat from 'botframework-webchat';
import { UserAgentApplication } from 'msal';
import StaticContent from '@midudev/react-static-content';
class GBUIApp extends React.Component {
constructor() {
super();
this.state = {
line: null,
token: null,
instanceClient: null
};
window.user = this.getUser();
}
generateRandomId(length) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
const array = new Uint32Array(length);
window.crypto.getRandomValues(array);
for (let i = 0; i < length; i++) {
result += characters.charAt(array[i] % characters.length);
}
return result;
}
sendToken(token) {
setTimeout(() => {
window.line
.postActivity({
type: 'event',
name: 'updateToken',
data: token,
locale: 'en-us',
textFormat: 'plain',
timestamp: new Date().toISOString(),
from: this.getUser()
})
.subscribe(() => {
window.userAgentApplication.logout();
});
}, 400);
}
send(command) {
window.line.postActivity({
type: 'event',
name: command,
locale: 'en-us',
textFormat: 'plain',
timestamp: new Date().toISOString(),
from: this.getUser()
});
}
getUser() {
return { id: window.userId, name: 'You' };
}
postMessage(value) {
window.line.postActivity({
type: 'message',
text: value,
from: this.getUser()
});
}
configureChat() {
var botId = window.location.href.split('/')[3];
if (botId.indexOf('#') !== -1) {
botId = botId.split('#')[0];
}
if (!botId || botId === '') {
botId = '[default]';
}
fetch('/instances/' + botId)
.then(res => res.json())
.then(
result => {
this.setupBotConnection(result);
},
error => {
this.setState({
isLoaded: false,
err: error
});
}
);
}
authenticate() {
if (this.state.instanceClient.authenticatorClientId === null) {
return;
}
let _this_ = this;
let authority = 'https://login.microsoftonline.com/' + this.state.instanceClient.authenticatorTenant;
let graphScopes = ['Directory.AccessAsUser.All'];
let userAgentApplication = new UserAgentApplication(
this.state.instanceClient.authenticatorClientId,
authority,
function (errorDesc, token, error) {
if (error) {
_this_.sendToken(error);
}
}
);
window.userAgentApplication = userAgentApplication;
if (
!userAgentApplication.isCallback(window.location.hash) &&
window.parent === window &&
!window.opener &&
userAgentApplication.getUser
) {
var user = userAgentApplication.getUser();
if (user) {
userAgentApplication.acquireTokenSilent(graphScopes).then(
function (accessToken) {
_this_.sendToken(accessToken);
},
function (error) {
_this_.sendToken(error);
}
);
}
}
}
setupBotConnection(instanceClient) {
let _this_ = this;
window['botchatDebug'] = true;
window.userId = this.generateRandomId(16);
_this_.setState({ token: instanceClient.webchatToken });
const line = instanceClient.webchatToken
? new DirectLine({
userId:window.userId,
userIdOnStartConversation: window.userId,
token: instanceClient.webchatToken
})
: new DirectLine({
domain: instanceClient.domain,
userId:window.userId,
userIdOnStartConversation: window.userId,
secret: null,
token: null,
webSocket: false // defaults to true
});
line.setUserId(window.userId);
_this_.setState({ line: line });
line.connectionStatus$.subscribe(connectionStatus => {
if (connectionStatus === ConnectionStatus.Online) {
_this_.setState({ instanceClient: instanceClient });
window['botConnection'] = line;
}
});
window.line = line;
line.activity$
.filter(activity => activity.type === 'event' && activity.name === 'loadInstance')
.subscribe(() => {
_this_.send('startGB');
_this_.authenticate();
});
line.activity$
.filter(activity => activity.type === 'event' && activity.name === 'stop')
.subscribe(() => {
if (_this_.player) {
_this_.player.stop();
}
});
line.activity$
.filter(activity => activity.type === 'event' && activity.name === 'play')
.subscribe(activity => {
_this_.setState({ playerType: activity.value.playerType });
_this_.player.play(activity.value.data);
});
}
componentDidMount() {
this.configureChat();
}
webSpeechPonyfillFactory = 0;
render() {
let playerComponent = '';
if (this.state.playerType) {
switch (this.state.playerType) {
case 'markdown':
playerComponent = (
{
this.player = player;
}}
/>
);
break;
case 'bullet':
playerComponent = (
{
this.player = player;
}}
/>
);
break;
case 'video':
playerComponent = (
{
this.player = player;
}}
/>
);
break;
case 'url':
playerComponent = (
{
this.player = player;
}}
/>
);
break;
case 'multiurl':
playerComponent = (
{
this.player = player;
}}
/>
);
break;
case 'image':
playerComponent = (
{
this.player = player;
}}
/>
);
break;
/* case 'pbi':
playerComponent = (
{
this.player = player;
}}
/>
);
break; */
case 'login':
playerComponent = (
{
this.player = player;
}}
/>
);
break;
default:
playerComponent =
GBERROR: Unknow player type specified on message from server.
;
break;
}
}
let chat = ;
let gbCss = ;
let seo = ;
let sideBar = ;
if (this.state.line) {
chat = (
{
this.chat = chat;
}}
userID= {window.userId}
locale={'en-us'}
directLine={this.state.line}
/>
);
if (this.state.instanceClient) {
let color1 = this.state.instanceClient.color1;
gbCss = ;
seo = ;
document.body.style.setProperty('background-color', this.state.instanceClient.color2, 'important');
sideBar = (
{
if (node) {
node.style.setProperty('background-color', this.state.instanceClient.color1, 'important');
}
}}
>