我们正在尝试将用户信息保留在Blob存储中。我们可以编写文件,确认文件是否存在,但是当我们尝试从context
的对话框中访问文件时,找不到用户。
在我们的初始连接端点中,检查用户是否存在,如果不存在,我们创建一个:
await storage.write({
[`directline/users/${userId}`]: {
[USER_STATE_PROPERTY]: {
customData: {},
}
}
});
记录在blob存储中。我们拥有的Blob存储如下:
import {
AutoSaveStateMiddleware,
BotFrameworkAdapter,
UserState,
ConversationState
} from 'botbuilder';
import { log } from './logger';
import { BlobStorage } from 'botbuilder-azure';
import Bot from '../bot';
const storage = new BlobStorage({
containerName: BLOB_CONTAINER_NAME,
storageAccountOrConnectionString: BLOB_CONNECTION_STRING
});
const userState = new UserState(storage);
const conversationState = new ConversationState(storage);
const botInstance = new Bot(conversationState, userState);
const adapter = new BotFrameworkAdapter({
appId: APP_ID,
appPassword: APP_PASSWORD,
});
adapter.use(new AutoSaveStateMiddleware(conversationState, userState));
...
但是,当对话开始时,我们找不到当前用户:
class Bot {
private conversationState;
private userState;
private dialogState;
private dialogs;
private userProfile;
constructor(conversationState: ConversationState, userState) {
this.conversationState = conversationState;
this.userState = userState;
this.dialogState = this.conversationState.createProperty(DIALOG_STATE_PROPERTY);
this.userProfile = this.userState.createProperty(USER_STATE_PROPERTY);
this.dialogs = new DialogSet(this.dialogState);
}
public async onTurn(turnContext) {
const { type, membersAdded, recipient } = turnContext.activity;
if (type === ActivityTypes.Message || type === ActivityTypes.Event) {
const user = await this.userProfile.get(turnContext, {});
// user is always {}
}
}
答案 0 :(得分:0)
太糟糕了。 MS附加到每个ID的结尾import matplotlib.pyplot as plt
import arabic_reshaper
from bidi.algorithm import get_display
from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator
txt = '''I would love to try or hear the sample audio your app can produce. I do not want to purchase, because I've purchased so many apps that say they do something and do not deliver.
Can you please add audio samples with text you've converted? I'd love to see the end results.
Thanks!
سلام حال سلام سلام سلام حال شما چطوره است نیست
'''
word_cloud = WordCloud(font_path='arial', stopwords=STOPWORDS, background_color="white", max_font_size=50, max_words=100)
word_cloud = word_cloud.generate_from_text(get_display(arabic_reshaper.reshape(txt)))
plt.imshow(word_cloud, interpolation='bilinear')
plt.axis("off")
plt.show()
中缺少错误