async def run(): config = BdkConfigLoader.load_from_symphony_dir("config.yaml") async with SymphonyBdk(config) as bdk: datafeed_loop = bdk.datafeed() datafeed_loop.subscribe(RealTimeEventListenerImpl()) await datafeed_loop.start()
async def run(): # One can retrieve the stream id (aka conversation id) following the guide here: # https://docs.developers.symphony.com/building-bots-on-symphony/datafeed/overview-of-streams stream_id = "ubaSiuUsc_j-_lVQ8vhAz3___opSJdJZdA" config = BdkConfigLoader.load_from_symphony_dir("config.yaml") async with SymphonyBdk(config) as bdk: streams = bdk.streams() await streams.create_im_or_mim( [13056700579872, 13056700579891, 13056700579850]) await streams.create_room( V3RoomAttributes(name="New fancy room", description="test room")) logging.debug(await streams.get_stream(stream_id)) await streams.add_member_to_room(13056700579859, stream_id) await streams.remove_member_from_room(13056700579859, stream_id) async for m in await streams.list_all_streams_members(stream_id): logging.debug(m) stream_filter = StreamFilter(stream_types=[ StreamType(type="IM"), StreamType(type="MIM"), StreamType(type="ROOM") ], include_inactive_streams=False) async for s in await streams.list_all_streams(stream_filter): logging.debug(s)
async def run(): stream_id_1 = "lRwCZlDbxWLd2BDP-1D_8n___o0f4ZkEdA" stream_id_2 = "12lruitZ3cecVY1_SKgKB3___omJ6uHodA" config = BdkConfigLoader.load_from_symphony_dir("config.yaml") async with SymphonyBdk(config) as bdk: message_service = bdk.messages() await message_service.send_message(stream_id_1, "<messageML>Hello, World!</messageML>") with open("/path/to/attachment1", "rb") as file1, \ open("/path/to/attachment2", "rb") as file2: await message_service.blast_message( [stream_id_1, stream_id_2], "<messageML>Hello, World!</messageML>", attachment=[file1, file2] ) logging.info("Obo example:") obo_auth_session = bdk.obo(username="******") async with bdk.obo_services(obo_auth_session) as obo_services: # Message ID can be retrieved by following guide here: # https://docs.developers.symphony.com/building-bots-on-symphony/datafeed/overview-of-streams await obo_services.messages().suppress_message("URL-Safe MessageID")
async def run(): config = BdkConfigLoader.load_from_symphony_dir("config.yaml") async with SymphonyBdk(config) as bdk: signal_service = bdk.signals() logging.info('Creating new signal.') signal = await signal_service.create_signal( BaseSignal(name="Testing signal", query="HASHTAG:hashtag", visible_on_profile=False, company_wide=False)) logging.info(signal) logging.info(await signal_service.get_signal(signal.id)) logging.info('Add a subscriber to the signal.') await signal_service.subscribe_users_to_signal(signal.id, True, [13056700580913]) logging.info('Unsubscribe added user to the signal.') await signal_service.unsubscribe_users_to_signal( signal.id, [13056700580913]) logging.info("Listing all signals") async for s in await signal_service.list_all_signals(): logging.debug(s) logging.info("List all subscribers") async for s in await signal_service.list_all_subscribers(signal.id): logging.debug(s) logging.info(await signal_service.delete_signal(signal.id))
async def run(): config = BdkConfigLoader.load_from_symphony_dir("config.yaml") async with SymphonyBdk(config) as bdk: connection_service = bdk.connections() user_connection = await connection_service.list_connections( status=ConnectionStatus.ALL) logging.info(user_connection)
def test_load_from_symphony_directory(simple_config_path): tmp_config_filename = str(uuid.uuid4()) + "-config.yaml" tmp_config_path = Path.home() / ".symphony" / tmp_config_filename tmp_config_path.touch(exist_ok=True) resource_config_content = Path(simple_config_path).read_text() tmp_config_path.write_text(resource_config_content) config = BdkConfigLoader.load_from_symphony_dir(tmp_config_filename) assert config.bot.username == "youbot"
async def run(hz_client): async with SymphonyBdk( BdkConfigLoader.load_from_symphony_dir( "config_reader.yaml")) as bdk: datafeed = bdk.datafeed() datafeed.subscribe(EventListener(bdk.messages(), hz_client)) logging.debug("Starting datafeed") await datafeed.start()
async def run(): config = BdkConfigLoader.load_from_symphony_dir("config.yaml") async with SymphonyBdk(config) as bdk: auth_session = bdk.bot_session() logging.info(await auth_session.key_manager_token) logging.info(await auth_session.session_token) logging.info("Obo example:") obo_auth_session = bdk.obo(username="******") logging.info(await obo_auth_session.session_token)
async def run(): config = BdkConfigLoader.load_from_symphony_dir("config_injector.yaml") async with SymphonyBdk(config) as bdk: stream_id = await create_test_room(bdk.streams()) await send_messages(bdk.messages(), stream_id) await check_all_messages_have_been_replied_to(bdk.messages(), config.bot.username, stream_id)
async def run(): async with SymphonyBdk( BdkConfigLoader.load_from_symphony_dir("config.yaml")) as bdk: activities = bdk.activities() messages = bdk.messages() @activities.slash("/hello") async def on_hello(context: CommandContext): await messages.send_message( context.stream_id, "<messageML>Hello, World!</messageML>") await bdk.datafeed().start()
async def run(): config = BdkConfigLoader.load_from_symphony_dir("config.yaml") async with SymphonyBdk(config) as bdk: ext_app_authenticator = bdk.app_authenticator() app_auth = await ext_app_authenticator.authenticate_extension_app( "appToken") ta = app_auth.app_token ts = app_auth.symphony_token logging.debug("App token: %s, Symphony token: %s", ta, ts) logging.debug("Is token pair valid: %s", await ext_app_authenticator.is_token_pair_valid(ta, ts))
async def run(): config = BdkConfigLoader.load_from_symphony_dir("config.yaml") async with SymphonyBdk(config) as bdk: datafeed_loop = bdk.datafeed() datafeed_loop.subscribe(RealTimeEventListenerImpl()) t = asyncio.create_task(datafeed_loop.start()) # start DF loop await asyncio.sleep(10) await datafeed_loop.stop() # stop after 10s await t # wait for DF loop to finish
async def run(): config = BdkConfigLoader.load_from_symphony_dir("config.yaml") async with SymphonyBdk(config) as bdk: user_service = bdk.users() logging.info(await user_service.list_users_by_ids([12987981103610])) query = UserSearchQuery(query='bot', filters=UserSearchFilter(company='Symphony')) async for uid in await user_service.search_all_users(query, local=False): logging.debug(uid) async for i in await user_service.list_all_user_details_by_filter(user_filter=UserFilter(status="ENABLED", role="INDIVIDUAL"), max_number=100): logging.debug(i.user_attributes.display_name)
async def run(): async with SymphonyBdk(BdkConfigLoader.load_from_symphony_dir("config.yaml")) as bdk: activities = bdk.activities() messages = bdk.messages() @activities.slash("/go") async def on_hello(context: CommandContext): pick_emoji = ["cat", "dromedary_camel", "dolphin", "dog", "hamster", "goat", "panda_face", "koala", "frog", "penguin"] previous_message: V4Message = await messages.send_message(context.stream_id, "Let the show begin!") for i in range(0, len(pick_emoji)): time.sleep(1) mml = "<emoji shortcode=\"{}\" /><br/><br/>Update <b>#{}</b>".format(pick_emoji[i], (i + 1)) previous_message = await messages.update_message(previous_message.stream.stream_id, previous_message.message_id, mml) await bdk.datafeed().start()
async def run(): async with SymphonyBdk( BdkConfigLoader.load_from_symphony_dir("config.yaml")) as bdk: bdk.activities().register(SlashGifCommandActivity(bdk.messages())) bdk.activities().register(ReplyFormReplyActivity(bdk.messages())) await bdk.datafeed().start()
async def run(): async with SymphonyBdk( BdkConfigLoader.load_from_symphony_dir("config.yaml")) as bdk: bdk.activities().register(JoinRoomActivity(bdk.messages())) await bdk.datafeed().start()
from symphony.bdk.core.config.loader import BdkConfigLoader config_1 = BdkConfigLoader.load_from_file("/absolute/path/to/config.yaml") with open("/absolute/path/to/config.yaml") as config_file: config_2 = BdkConfigLoader.load_from_content(config_file.read()) config_3 = BdkConfigLoader.load_from_symphony_dir("config.yaml")