Skip to content

Instantly share code, notes, and snippets.

@sendbird-community
sendbird-community / index.js
Last active Feb 11, 2022
banUser function
View index.js
var apiInstance = new SendbirdPlatformSdk.GroupChannelApi();
apiInstance.apiClient.basePath = `https://api-${process.env.APP_ID}.sendbird.com`;
function banUser(channelUrl, senderId) {
var seconds = 86400;
var description = "Toxic message sent- User will be banned for 1 day";
var agentId = 0;
var opts = {
apiToken: process.env.API_TOKEN,
gcBanUserData: new SendbirdPlatformSdk.GcBanUserData(
@sendbird-community
sendbird-community / index.js
Created Feb 11, 2022
testToxicity function
View index.js
function testToxicity(message, channelUrl, senderId) {
var API_KEY = process.env.PERSPECTIVE_API_KEY;
var DISCOVERY_URL =
"https://commentanalyzer.googleapis.com/$discovery/rest?version=v1alpha1";
google
.discoverAPI(DISCOVERY_URL)
.then((client) => {
const analyzeRequest = {
comment: {
View index.js
const app = express();
const port = 3000;
app.post("/analyze_message", async (req, res) => {
const body = req.body;
const parsedBody = JSON.parse(body);
var channelUrl = parsedBody.channel.channel_url;
var message = parsedBody.payload.message;
var senderId = parsedBody.sender.user_id;
testToxicity(message, channelUrl, senderId);
@sendbird-community
sendbird-community / group_channel_view.dart
Created Jan 10, 2022
Chat Triggered Effects - Group Channel View updated build
View group_channel_view.dart
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: navigationBar(widget.groupChannel),
body: sfxStackedBody(
context,
_sfxController,
widget.groupChannel,
_messages,
), );
@sendbird-community
sendbird-community / group_channel_view.dart
Created Jan 10, 2022
Chat Triggered Effects - Group Channel View Stacked View Wrapper
View group_channel_view.dart
Widget sfxStackedBody(
BuildContext context,
SendbirdSFXController controller,
GroupChannel channel,
List<BaseMessage> messages,
) {
// Run all received messages through special effects check
controller.checkAndTriggerAll(channel, messages);
@sendbird-community
sendbird-community / group_channel_view.dart
Created Jan 10, 2022
Chat Triggered Effects - Group Channel View State
View group_channel_view.dart
final _sfxController = SendbirdSFXController([
ConfettiSFX(
metaKey: "shownConfetti",
keywords: ["congrats", "congratulations"],
]);
@sendbird-community
sendbird-community / group_channel_view.dart
Created Jan 10, 2022
Chat Triggered Effects - Group Channel Imports
View group_channel_view.dart
import 'sendbird_sfx_controller.dart';
import 'confetti_sfx.dart';
@sendbird-community
sendbird-community / sendbird_sfx_controller.dart
Created Jan 10, 2022
Chat Triggered Effects - SendbirdSFXController main functions
View sendbird_sfx_controller.dart
class SendbirdSFXController {
SendbirdSFXController(this.specialEffects);
List<SendbirdSFX> specialEffects;
Future<void> checkAndTriggerAll(
BaseChannel channel,
List<BaseMessage> messages,
) async {
for (BaseMessage message in messages) {
@sendbird-community
sendbird-community / confetti_sfx.dart
Created Jan 10, 2022
Chat Triggered Effects - ConfettiSFX overrides
View confetti_sfx.dart
@override
play() {
_confettiController.play();
}
@override
stop() {
_confettiController.stop();
}
@sendbird-community
sendbird-community / confetti_sfx.dart
Created Jan 10, 2022
Chat Triggered Effects - ConfettiSFX ui override
View confetti_sfx.dart
@override
ui() {
return Align(
alignment: Alignment.topCenter,
child: ConfettiWidget(
confettiController: _confettiController,
blastDirectionality: BlastDirectionality
.explosive,
shouldLoop: false,
colors: const [