import { BotClient } from './BotClient' ; import { Bot , BotsState , TagFilter } from '../bots' ; import { values } from 'lodash' ; export class MemoryBotClient implements BotClient { servers : { [ server ] : BotsState ; } = { } ; async addBots ( server , added ) { let uni = this . servers [ server ] ; if ( ! uni ) { uni = this . servers [ server ] = { } ; } for ( let bot of added ) { uni [ bot . id ] = bot ; } } async clearBots ( server ) { this . servers [ server ] = { } ; } async lookupBots ( server , tags ) { let uni = this . servers [ server ] ; if ( ! uni ) { return [ ] ; } return values ( uni ) . filter ( ( b ) => tags . every ( ( t ) => b . tags [ t . tag ] === t . value ) ) ; } }