本文整理汇总了TypeScript中matrix-appservice-bridge.RoomBridgeStore.getEntriesByRemoteRoomData方法的典型用法代码示例。如果您正苦于以下问题:TypeScript RoomBridgeStore.getEntriesByRemoteRoomData方法的具体用法?TypeScript RoomBridgeStore.getEntriesByRemoteRoomData怎么用?TypeScript RoomBridgeStore.getEntriesByRemoteRoomData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matrix-appservice-bridge.RoomBridgeStore
的用法示例。
在下文中一共展示了RoomBridgeStore.getEntriesByRemoteRoomData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: GetRoomIdsFromChannel
public async GetRoomIdsFromChannel(channel: Discord.Channel): Promise<string[]> {
if (!this.roomStore) {
this.roomStore = this.bridge.getRoomStore();
}
const rooms = await this.roomStore.getEntriesByRemoteRoomData({
discord_channel: channel.id,
});
if (rooms.length === 0) {
log.verbose(`Couldn't find room(s) for channel ${channel.id}.`);
return Promise.reject("Room(s) not found.");
}
return rooms.map((room) => room.matrix.getId() as string);
}
示例2: GetChannelUpdateState
public async GetChannelUpdateState(channel: Discord.TextChannel, forceUpdate = false): Promise<IChannelState> {
log.verbose(`State update request for ${channel.id}`);
const channelState: IChannelState = Object.assign({}, DEFAULT_CHANNEL_STATE, {
id: channel.id,
mxChannels: [],
});
if (!this.roomStore) {
this.roomStore = this.bridge.getRoomStore();
}
const remoteRooms = await this.roomStore.getEntriesByRemoteRoomData({discord_channel: channel.id});
if (remoteRooms.length === 0) {
log.verbose(`Could not find any channels in room store.`);
return channelState;
}
const patternMap = {
guild: channel.guild.name,
name: "#" + channel.name,
};
let name: string = this.config.channel.namePattern;
for (const p of Object.keys(patternMap)) {
name = name.replace(new RegExp(":" + p, "g"), patternMap[p]);
}
const topic = channel.topic;
const icon = channel.guild.icon;
let iconUrl: string | null = null;
if (icon) {
iconUrl = `https://cdn.discordapp.com/icons/${channel.guild.id}/${icon}.png`;
}
remoteRooms.forEach((remoteRoom) => {
const mxid = remoteRoom.matrix.getId();
const singleChannelState: ISingleChannelState = Object.assign({}, DEFAULT_SINGLECHANNEL_STATE, {
mxid,
});
const oldName = remoteRoom.remote.get("discord_name");
if (remoteRoom.remote.get("update_name") && (forceUpdate || oldName !== name)) {
log.verbose(`Channel ${mxid} name should be updated`);
singleChannelState.name = name;
}
const oldTopic = remoteRoom.remote.get("discord_topic");
if (remoteRoom.remote.get("update_topic") && (forceUpdate || oldTopic !== topic)) {
log.verbose(`Channel ${mxid} topic should be updated`);
singleChannelState.topic = topic;
}
const oldIconUrl = remoteRoom.remote.get("discord_iconurl");
// no force on icon update as we don't want to duplicate ALL the icons
if (remoteRoom.remote.get("update_icon") && oldIconUrl !== iconUrl) {
log.verbose(`Channel ${mxid} icon should be updated`);
if (iconUrl !== null) {
singleChannelState.iconUrl = iconUrl;
singleChannelState.iconId = icon;
} else {
singleChannelState.removeIcon = oldIconUrl !== null;
}
}
channelState.mxChannels.push(singleChannelState);
});
return channelState;
}