Compare commits

...

23 commits

Author SHA1 Message Date
kevkevin
ebcc2e0703
fix: disabling pingHubInterval since it is causing large queries (#813) 2024-07-16 08:59:30 -05:00
github-actions[bot]
f879688d62 [ci commit] Update proto files and types 2024-04-10 16:04:41 +00:00
github-actions[bot]
92a66aa3d4 [ci commit] Lint and format code 2024-04-10 16:04:11 +00:00
Evan Feenstra
332923b13b
Merge pull request #808 from stakwork/fix/edit-tribe
update: ensured empty string app_url are saved
2024-04-10 09:02:50 -07:00
Oluwatobi Bamidele
63d82c88c3 update: ensured empty string app_url are saved 2024-04-10 15:46:35 +01:00
github-actions[bot]
3843f44199 [ci commit] Update proto files and types 2024-04-01 20:30:22 +00:00
github-actions[bot]
d190bd85f2 [ci commit] Lint and format code 2024-04-01 20:29:53 +00:00
Evan Feenstra
78cd8a0548 fix interceptTribeMsgForHiddenCmds 2024-04-01 13:28:28 -07:00
github-actions[bot]
3330338f4a [ci commit] Update proto files and types 2024-03-28 16:50:45 +00:00
github-actions[bot]
6970098eb9 [ci commit] Automatic build 2024-03-28 16:50:26 +00:00
github-actions[bot]
3dc5029c37 [ci commit] Lint and format code 2024-03-28 16:50:15 +00:00
Evan Feenstra
c0962f5f27
Merge pull request #807 from stakwork/update/kick-bot
Update/kick bot
2024-03-28 09:48:50 -07:00
Oluwatobi Bamidele
48d023e96b update: ensured install and uninstall commands entered by the admin is not visible to users 2024-03-27 21:01:24 +01:00
Oluwatobi Bamidele
f54d2f5bbb update: hide install and uninstall response 2024-03-27 20:03:03 +01:00
Oluwatobi Bamidele
57f77c5884 update: hide all commands related to kick bot 2024-03-27 19:24:47 +01:00
Oluwatobi Bamidele
50272a7d7e update: ensured help command response are hidden 2024-03-27 19:05:45 +01:00
github-actions[bot]
7bf43c4a49 [ci commit] Update proto files and types 2024-03-22 14:50:31 +00:00
github-actions[bot]
9dfaff50ff [ci commit] Lint and format code 2024-03-22 14:50:02 +00:00
Evan Feenstra
e27d93257c
Merge pull request #806 from stakwork/update/second-brain-url
Update/second brain url
2024-03-22 07:48:45 -07:00
Oluwatobi Bamidele
36d4ebf010 update: update second_brain_url on tribe server 2024-03-21 22:14:25 +01:00
Oluwatobi Bamidele
d16c1de085 feat: added second_brain_url to create tribe on tribe server 2024-03-21 22:09:23 +01:00
github-actions[bot]
ca62559eca [ci commit] Update proto files and types 2024-03-19 20:07:29 +00:00
github-actions[bot]
ee4299692e [ci commit] Lint and format code 2024-03-19 20:07:00 +00:00
19 changed files with 114 additions and 45 deletions

6
app.ts
View file

@ -5,7 +5,7 @@ import * as cors from 'cors'
import * as https from 'https'
import * as http from 'http'
import logger, { logging, sphinxLogger } from './src/utils/logger'
import { pingHubInterval, checkInvitesHubInterval } from './src/hub'
import { checkInvitesHubInterval } from './src/hub'
import { genUsersInterval } from './src/utils/proxy'
import {
setupDatabase,
@ -47,7 +47,7 @@ async function start() {
mainSetup()
// // IF NOT UNLOCK, go ahead and start this now
if (config.hub_api_url && !config.unlock) {
pingHubInterval(30000)
//pingHubInterval(30000)
genUsersInterval(60000)
}
}
@ -73,7 +73,7 @@ async function finishSetup() {
}
if (config.unlock) {
// IF UNLOCK, start this only after unlocked!
pingHubInterval(15000)
//pingHubInterval(15000)
}
leadershipBoardInterval(1800000)
setupDone()

View file

@ -168,7 +168,8 @@ function init() {
},
{ name: 'Help', value: '/kick help' },
])
.setThumbnail(botSVG);
.setThumbnail(botSVG)
.setOnlyOwner(true);
message.channel.send({ embed });
return;
}

File diff suppressed because one or more lines are too long

View file

@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.init = void 0;
exports.init = exports.adminsOnlyBot = void 0;
// import * as SphinxBot from '../../../sphinx-bot'
const Sphinx = require("sphinx-bot");
const botapi_1 = require("../controllers/botapi");
@ -79,6 +79,7 @@ const builtInBotNames = {
spam_gone: 'SpamGoneBot',
[`${ml_1.ML_PREFIX.substring(1)}`]: ml_1.ML_BOTNAME,
};
exports.adminsOnlyBot = ['kick'];
function init() {
const client = new Sphinx.Client();
client.login('_', botapi_1.finalAction);
@ -108,7 +109,8 @@ function init() {
if (existing) {
const embed = new Sphinx.MessageEmbed()
.setAuthor('MotherBot')
.setDescription(botName + ' already installed');
.setDescription(botName + ' already installed')
.setOnlyOwner(exports.adminsOnlyBot.includes(botName) || false);
return message.channel.send({ embed });
}
const msgTypes = builtInBotMsgTypes[botName] || [
@ -132,7 +134,8 @@ function init() {
const theName = builtInBotNames[botName] || 'Bot';
const embed = new Sphinx.MessageEmbed()
.setAuthor('MotherBot')
.setDescription(theName + ' has been installed!');
.setDescription(theName + ' has been installed!')
.setOnlyOwner(exports.adminsOnlyBot.includes(botName) || false);
message.channel.send({ embed });
}
else {
@ -144,7 +147,8 @@ function init() {
if (existing) {
const embed = new Sphinx.MessageEmbed()
.setAuthor('MotherBot')
.setDescription(botName + ' already installed');
.setDescription(botName + ' already installed')
.setOnlyOwner(exports.adminsOnlyBot.includes(botName) || false);
return message.channel.send({ embed });
}
// bot from tribes registry
@ -159,7 +163,8 @@ function init() {
else {
const embed = new Sphinx.MessageEmbed()
.setAuthor('MotherBot')
.setDescription('No bot with that name');
.setDescription('No bot with that name')
.setOnlyOwner(exports.adminsOnlyBot.includes(botName) || false);
message.channel.send({ embed });
}
}
@ -182,13 +187,15 @@ function init() {
yield existing2.destroy();
const embed = new Sphinx.MessageEmbed()
.setAuthor('MotherBot')
.setDescription(botName2 + ' has been removed');
.setDescription(botName2 + ' has been removed')
.setOnlyOwner(exports.adminsOnlyBot.includes(botName2) || false);
return message.channel.send({ embed });
}
else {
const embed = new Sphinx.MessageEmbed()
.setAuthor('MotherBot')
.setDescription('Cant find a bot by that name');
.setDescription('Cant find a bot by that name')
.setOnlyOwner(exports.adminsOnlyBot.includes(botName2) || false);
return message.channel.send({ embed });
}
case 'search':

File diff suppressed because one or more lines are too long

View file

@ -426,6 +426,7 @@ function editTribe(req, res) {
owner_pubkey: owner.publicKey,
pin: pin || '',
profile_filters: profile_filters || '',
second_brain_url,
});
}
catch (e) {
@ -448,9 +449,9 @@ function editTribe(req, res) {
obj.escrowMillis = escrow_millis;
if (unlisted || unlisted === false)
obj.unlisted = unlisted;
if (app_url)
if (app_url || app_url === '')
obj.appUrl = app_url;
if (feed_url)
if (feed_url || feed_url === '')
obj.feedUrl = feed_url;
if (feed_type)
obj.feedType = feed_type;
@ -468,7 +469,7 @@ function editTribe(req, res) {
obj.stakworkApiKey = stakwork_api_key;
if (stakwork_webhook)
obj.stakworkWebhook = stakwork_webhook;
if (second_brain_url)
if (second_brain_url || second_brain_url === '')
obj.secondBrainUrl = second_brain_url;
if (Object.keys(obj).length > 0) {
yield chat.update(obj);

File diff suppressed because one or more lines are too long

View file

@ -326,6 +326,7 @@ function createGroupChat(req, res) {
owner_route_hint: owner.routeHint || '',
pin: pin || '',
profile_filters: profile_filters || '',
second_brain_url: second_brain_url || '',
});
}
catch (e) {

File diff suppressed because one or more lines are too long

View file

@ -21,7 +21,7 @@ const logger_1 = require("../utils/logger");
const config_1 = require("../utils/config");
const errMsgString_1 = require("../utils/errMsgString");
const proxy_1 = require("../utils/proxy");
const ml_1 = require("../builtin/ml");
const mother_1 = require("../builtin/mother");
const intercept = require("./intercept");
const receive_1 = require("./receive");
const config = (0, config_1.loadConfig)();
@ -423,27 +423,47 @@ function compareAliases(alias1, alias2) {
});
return match;
}
function updateMessageToIsOnlyOwner(uuid, tenant) {
return __awaiter(this, void 0, void 0, function* () {
yield models_1.models.Message.update({
onlyOwner: true,
}, { where: { uuid, tenant } });
});
}
function interceptTribeMsgForHiddenCmds(msg, tenant) {
return __awaiter(this, void 0, void 0, function* () {
const hideAllCommandsBot = ['/kick', '/ml'];
try {
const content = msg.message.content;
const splitedContent = (content && content.split(' ')) || [];
if (splitedContent.length < 1)
return false;
// must be a "/" bot command
if (!splitedContent[0].startsWith('/')) {
return false;
}
if (splitedContent[0] === '/bot') {
if (mother_1.adminsOnlyBot.includes(splitedContent[2])) {
yield updateMessageToIsOnlyOwner(msg.message.uuid, tenant);
return true;
}
return false;
}
const newChat = (yield models_1.models.Chat.findOne({
where: { uuid: msg.chat.uuid },
}));
const bots = (yield models_1.models.ChatBot.findAll({
where: { tenant, chatId: newChat.id },
}));
const content = msg.message.content;
const splitedContent = (content && content.split(' ')) || [];
for (let i = 0; i < bots.length; i++) {
const bot = bots[i];
const isHidden = bot.botPrefix === splitedContent[0] &&
bot.hiddenCommands &&
JSON.parse(bot.hiddenCommands).includes(splitedContent[1]);
const isPersonal = bot.botPrefix === ml_1.ML_PREFIX;
if (isHidden || isPersonal) {
yield models_1.models.Message.update({
onlyOwner: true,
}, { where: { uuid: msg.message.uuid, tenant } });
const isDefaultHide = bot.botPrefix === splitedContent[0] &&
hideAllCommandsBot.includes(bot.botPrefix);
if (isHidden || isDefaultHide) {
yield updateMessageToIsOnlyOwner(msg.message.uuid, tenant);
return true;
}
}

File diff suppressed because one or more lines are too long

View file

@ -362,7 +362,7 @@ function getTribeOwnersChatByUUID(uuid) {
});
}
exports.getTribeOwnersChatByUUID = getTribeOwnersChatByUUID;
function declare({ uuid, name, description, tags, img, group_key, host, price_per_message, price_to_join, owner_alias, owner_pubkey, escrow_amount, escrow_millis, unlisted, is_private, app_url, feed_url, feed_type, owner_route_hint, pin, profile_filters, }) {
function declare({ uuid, name, description, tags, img, group_key, host, price_per_message, price_to_join, owner_alias, owner_pubkey, escrow_amount, escrow_millis, unlisted, is_private, app_url, feed_url, feed_type, owner_route_hint, pin, profile_filters, second_brain_url, }) {
return __awaiter(this, void 0, void 0, function* () {
try {
let protocol = 'https';
@ -391,6 +391,7 @@ function declare({ uuid, name, description, tags, img, group_key, host, price_pe
owner_route_hint: owner_route_hint || '',
pin: pin || '',
profile_filters,
second_brain_url,
}),
headers: { 'Content-Type': 'application/json' },
});
@ -406,7 +407,7 @@ function declare({ uuid, name, description, tags, img, group_key, host, price_pe
});
}
exports.declare = declare;
function edit({ uuid, host, name, description, tags, img, price_per_message, price_to_join, owner_alias, escrow_amount, escrow_millis, unlisted, is_private, app_url, feed_url, feed_type, deleted, owner_route_hint, owner_pubkey, pin, profile_filters, }) {
function edit({ uuid, host, name, description, tags, img, price_per_message, price_to_join, owner_alias, escrow_amount, escrow_millis, unlisted, is_private, app_url, feed_url, feed_type, deleted, owner_route_hint, owner_pubkey, pin, profile_filters, second_brain_url, }) {
return __awaiter(this, void 0, void 0, function* () {
try {
const token = yield genSignedTimestamp(owner_pubkey);
@ -435,6 +436,7 @@ function edit({ uuid, host, name, description, tags, img, price_per_message, pri
owner_route_hint: owner_route_hint || '',
pin: pin || '',
profile_filters,
second_brain_url: second_brain_url || '',
}),
headers: { 'Content-Type': 'application/json' },
});

File diff suppressed because one or more lines are too long

View file

@ -178,6 +178,7 @@ export function init() {
{ name: 'Help', value: '/kick help' },
])
.setThumbnail(botSVG)
.setOnlyOwner(true)
message.channel.send({ embed })
return
}

View file

@ -75,6 +75,8 @@ const builtInBotNames = {
[`${ML_PREFIX.substring(1)}`]: ML_BOTNAME,
}
export const adminsOnlyBot = ['kick']
export function init() {
const client = new Sphinx.Client()
client.login('_', finalAction)
@ -105,6 +107,7 @@ export function init() {
const embed = new Sphinx.MessageEmbed()
.setAuthor('MotherBot')
.setDescription(botName + ' already installed')
.setOnlyOwner(adminsOnlyBot.includes(botName) || false)
return message.channel.send({ embed })
}
const msgTypes = builtInBotMsgTypes[botName] || [
@ -129,6 +132,7 @@ export function init() {
const embed = new Sphinx.MessageEmbed()
.setAuthor('MotherBot')
.setDescription(theName + ' has been installed!')
.setOnlyOwner(adminsOnlyBot.includes(botName) || false)
message.channel.send({ embed })
} else {
const chat = await getTribeOwnersChatByUUID(message.channel.id)
@ -141,6 +145,7 @@ export function init() {
const embed = new Sphinx.MessageEmbed()
.setAuthor('MotherBot')
.setDescription(botName + ' already installed')
.setOnlyOwner(adminsOnlyBot.includes(botName) || false)
return message.channel.send({ embed })
}
// bot from tribes registry
@ -155,6 +160,7 @@ export function init() {
const embed = new Sphinx.MessageEmbed()
.setAuthor('MotherBot')
.setDescription('No bot with that name')
.setOnlyOwner(adminsOnlyBot.includes(botName) || false)
message.channel.send({ embed })
}
}
@ -178,11 +184,13 @@ export function init() {
const embed = new Sphinx.MessageEmbed()
.setAuthor('MotherBot')
.setDescription(botName2 + ' has been removed')
.setOnlyOwner(adminsOnlyBot.includes(botName2) || false)
return message.channel.send({ embed })
} else {
const embed = new Sphinx.MessageEmbed()
.setAuthor('MotherBot')
.setDescription('Cant find a bot by that name')
.setOnlyOwner(adminsOnlyBot.includes(botName2) || false)
return message.channel.send({ embed })
}

View file

@ -474,6 +474,7 @@ export async function editTribe(req: Req, res: Res): Promise<void | Response> {
owner_pubkey: owner.publicKey,
pin: pin || '',
profile_filters: profile_filters || '',
second_brain_url,
})
} catch (e) {
okToUpdate = false
@ -490,8 +491,8 @@ export async function editTribe(req: Req, res: Res): Promise<void | Response> {
if (escrow_amount || escrow_amount === 0) obj.escrowAmount = escrow_amount
if (escrow_millis || escrow_millis === 0) obj.escrowMillis = escrow_millis
if (unlisted || unlisted === false) obj.unlisted = unlisted
if (app_url) obj.appUrl = app_url
if (feed_url) obj.feedUrl = feed_url
if (app_url || app_url === '') obj.appUrl = app_url
if (feed_url || feed_url === '') obj.feedUrl = feed_url
if (feed_type) obj.feedType = feed_type
if (req.body.private || req.body.private === false)
obj.private = req.body.private
@ -502,7 +503,8 @@ export async function editTribe(req: Req, res: Res): Promise<void | Response> {
if (jitsi_server) obj.jitsiServer = jitsi_server
if (stakwork_api_key) obj.stakworkApiKey = stakwork_api_key
if (stakwork_webhook) obj.stakworkWebhook = stakwork_webhook
if (second_brain_url) obj.secondBrainUrl = second_brain_url
if (second_brain_url || second_brain_url === '')
obj.secondBrainUrl = second_brain_url
if (Object.keys(obj).length > 0) {
await chat.update(obj)
}

View file

@ -382,6 +382,7 @@ export async function createGroupChat(req: Req, res: Res): Promise<void> {
owner_route_hint: owner.routeHint || '',
pin: pin || '',
profile_filters: profile_filters || '',
second_brain_url: second_brain_url || '',
})
} catch (e) {
sphinxLogger.error(`=> couldnt create tribe ${e}`)

View file

@ -22,7 +22,7 @@ import { logging, sphinxLogger } from '../utils/logger'
import { loadConfig } from '../utils/config'
import { errMsgString } from '../utils/errMsgString'
import { getProxyRootPubkey, isProxy } from '../utils/proxy'
import { ML_PREFIX } from '../builtin/ml'
import { adminsOnlyBot } from '../builtin/mother'
import { Msg, MessageContent, ChatMember } from './interfaces'
import * as intercept from './intercept'
import { typesToForward, receiveCoTenantMessage } from './receive'
@ -543,11 +543,37 @@ function compareAliases(alias1: string, alias2: string): boolean {
return match
}
async function updateMessageToIsOnlyOwner(uuid: string, tenant: number) {
await models.Message.update(
{
onlyOwner: true,
},
{ where: { uuid, tenant } }
)
}
async function interceptTribeMsgForHiddenCmds(
msg: Msg,
tenant: number
): Promise<boolean> {
const hideAllCommandsBot = ['/kick', '/ml']
try {
const content = msg.message.content as string
const splitedContent = (content && content.split(' ')) || []
if (splitedContent.length < 1) return false
// must be a "/" bot command
if (!splitedContent[0].startsWith('/')) {
return false
}
if (splitedContent[0] === '/bot') {
if (adminsOnlyBot.includes(splitedContent[2])) {
await updateMessageToIsOnlyOwner(msg.message.uuid, tenant)
return true
}
return false
}
const newChat = (await models.Chat.findOne({
where: { uuid: msg.chat.uuid },
})) as ChatRecord
@ -556,8 +582,6 @@ async function interceptTribeMsgForHiddenCmds(
where: { tenant, chatId: newChat.id },
})) as ChatBotRecord[]
const content = msg.message.content as string
const splitedContent = (content && content.split(' ')) || []
for (let i = 0; i < bots.length; i++) {
const bot = bots[i]
@ -565,15 +589,11 @@ async function interceptTribeMsgForHiddenCmds(
bot.botPrefix === splitedContent[0] &&
bot.hiddenCommands &&
JSON.parse(bot.hiddenCommands).includes(splitedContent[1])
const isPersonal = bot.botPrefix === ML_PREFIX
if (isHidden || isPersonal) {
await models.Message.update(
{
onlyOwner: true,
},
{ where: { uuid: msg.message.uuid, tenant } }
)
const isDefaultHide =
bot.botPrefix === splitedContent[0] &&
hideAllCommandsBot.includes(bot.botPrefix)
if (isHidden || isDefaultHide) {
await updateMessageToIsOnlyOwner(msg.message.uuid, tenant)
return true
}
}

View file

@ -433,6 +433,7 @@ export interface TribeInterface {
owner_route_hint: string
pin: string
profile_filters?: string
second_brain_url?: string
}
export async function declare({
@ -457,6 +458,7 @@ export async function declare({
owner_route_hint,
pin,
profile_filters,
second_brain_url,
}: TribeInterface): Promise<void> {
try {
let protocol = 'https'
@ -484,6 +486,7 @@ export async function declare({
owner_route_hint: owner_route_hint || '',
pin: pin || '',
profile_filters,
second_brain_url,
}),
headers: { 'Content-Type': 'application/json' },
})
@ -519,6 +522,7 @@ export async function edit({
owner_pubkey,
pin,
profile_filters,
second_brain_url,
}: TribeInterface): Promise<void> {
try {
const token = await genSignedTimestamp(owner_pubkey)
@ -546,6 +550,7 @@ export async function edit({
owner_route_hint: owner_route_hint || '',
pin: pin || '',
profile_filters,
second_brain_url: second_brain_url || '',
}),
headers: { 'Content-Type': 'application/json' },
})