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


TypeScript RoomBridgeStore.removeEntriesByMatrixRoomId方法代码示例

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


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

示例1: handleChannelDeletionForRoom

    private async handleChannelDeletionForRoom(
        channel: Discord.TextChannel,
        roomId: string,
        entry: Entry): Promise<void> {
        log.info(`Deleting ${channel.id} from ${roomId}.`);
        const intent = await this.bridge.getIntent();
        const options = this.config.channel.deleteOptions;
        const plumbed = entry.remote.get("plumbed");

        this.roomStore.upsertEntry(entry);
        if (options.ghostsLeave) {
            for (const member of channel.members.array()) {
                try {
                    const mIntent = await this.bot.GetIntentFromDiscordMember(member);
                    mIntent.leave(roomId);
                    log.info(`${member.id} left ${roomId}.`);
                } catch (e) {
                    log.warn(`Failed to make ${member.id} leave `);
                }
            }
        }
        if (options.namePrefix) {
            try {
                const name = await intent.getClient().getStateEvent(roomId, "m.room.name");
                name.name = options.namePrefix + name.name;
                await intent.getClient().setRoomName(roomId, name.name);
            } catch (e) {
                log.error(`Failed to set name of room ${roomId} ${e}`);
            }
        }
        if (options.topicPrefix) {
            try {
                const topic = await intent.getClient().getStateEvent(roomId, "m.room.topic");
                topic.topic = options.topicPrefix + topic.topic;
                await intent.getClient().setRoomTopic(roomId, topic.topic);
            } catch (e) {
                log.error(`Failed to set topic of room ${roomId} ${e}`);
            }
        }

        if (plumbed !== true) {
            if (options.unsetRoomAlias) {
                try {
                    const alias = `#_${entry.remote.roomId}:${this.config.bridge.domain}`;
                    const canonicalAlias = await intent.getClient().getStateEvent(roomId, "m.room.canonical_alias");
                    if (canonicalAlias.alias === alias) {
                        await intent.getClient().sendStateEvent(roomId, "m.room.canonical_alias", {});
                    }
                    await intent.getClient().deleteAlias(alias);
                } catch (e) {
                    log.error(`Couldn't remove alias of ${roomId} ${e}`);
                }
            }

            if (options.unlistFromDirectory) {
                try {
                    await intent.getClient().setRoomDirectoryVisibility(roomId, "private");
                } catch (e) {
                    log.error(`Couldn't remove ${roomId} from room directory ${e}`);
                }

            }

            if (options.setInviteOnly) {
                try {
                    await intent.getClient().sendStateEvent(roomId, "m.room.join_rules", {join_role: "invite"});
                } catch (e) {
                    log.error(`Couldn't set ${roomId} to private ${e}`);
                }
            }

            if (options.disableMessaging) {
                try {
                    const state = await intent.getClient().getStateEvent(roomId, "m.room.power_levels");
                    state.events_default = POWER_LEVEL_MESSAGE_TALK;
                    await intent.getClient().sendStateEvent(roomId, "m.room.power_levels", state);
                } catch (e) {
                    log.error(`Couldn't disable messaging for ${roomId} ${e}`);
                }
            }
        }
        // Unlist

        // Remove entry
        await this.roomStore.removeEntriesByMatrixRoomId(roomId);
    }
开发者ID:Half-Shot,项目名称:matrix-appservice-discord,代码行数:86,代码来源:channelsyncroniser.ts


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