当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript RoomBridgeStore.getEntriesByMatrixId方法代码示例

本文整理汇总了TypeScript中matrix-appservice-bridge.RoomBridgeStore.getEntriesByMatrixId方法的典型用法代码示例。如果您正苦于以下问题:TypeScript RoomBridgeStore.getEntriesByMatrixId方法的具体用法?TypeScript RoomBridgeStore.getEntriesByMatrixId怎么用?TypeScript RoomBridgeStore.getEntriesByMatrixId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matrix-appservice-bridge.RoomBridgeStore的用法示例。


在下文中一共展示了RoomBridgeStore.getEntriesByMatrixId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: ApplyStateToChannel

    private async ApplyStateToChannel(channelsState: IChannelState) {
        const intent = this.bridge.getIntent();
        for (const channelState of channelsState.mxChannels) {
            let roomUpdated = false;
            const remoteRoom = (await this.roomStore.getEntriesByMatrixId(channelState.mxid))[0];
            if (channelState.name !== null) {
                log.verbose(`Updating channelname for ${channelState.mxid} to "${channelState.name}"`);
                await intent.setRoomName(channelState.mxid, channelState.name);
                remoteRoom.remote.set("discord_name", channelState.name);
                roomUpdated = true;
            }

            if (channelState.topic !== null) {
                log.verbose(`Updating channeltopic for ${channelState.mxid} to "${channelState.topic}"`);
                await intent.setRoomTopic(channelState.mxid, channelState.topic);
                remoteRoom.remote.set("discord_topic", channelState.topic);
                roomUpdated = true;
            }

            if (channelState.iconUrl !== null && channelState.iconId !== null) {
                log.verbose(`Updating icon_url for ${channelState.mxid} to "${channelState.iconUrl}"`);
                if (channelsState.iconMxcUrl === null) {
                    const iconMxc = await Util.UploadContentFromUrl(
                        channelState.iconUrl,
                        intent,
                        channelState.iconId,
                    );
                    channelsState.iconMxcUrl = iconMxc.mxcUrl;
                }
                await intent.setRoomAvatar(channelState.mxid, channelsState.iconMxcUrl);
                remoteRoom.remote.set("discord_iconurl", channelState.iconUrl);
                remoteRoom.remote.set("discord_iconurl_mxc", channelsState.iconMxcUrl);
                roomUpdated = true;
            }

            if (channelState.removeIcon) {
                log.verbose(`Clearing icon_url for ${channelState.mxid}`);
                await intent.setRoomAvatar(channelState.mxid, null);
                remoteRoom.remote.set("discord_iconurl", null);
                remoteRoom.remote.set("discord_iconurl_mxc", null);
                roomUpdated = true;
            }

            if (roomUpdated) {
                await this.roomStore.upsertEntry(remoteRoom);
            }
        }
    }
开发者ID:Half-Shot,项目名称:matrix-appservice-discord,代码行数:48,代码来源:channelsyncroniser.ts


注:本文中的matrix-appservice-bridge.RoomBridgeStore.getEntriesByMatrixId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。