我想在文件“b”中使用文件“a”中的变量。我在网上搜索了一下,但它仍然不起作用。
所以我得到了文件bot.cs
和文件profanityFilter.cs
。
在profanityFilter.cs
我想使用incomingMessage
from bot.cs
。
机器人.cs:
class Bot
{
public static void Client_OnMessageReceived(object sender, OnMessageReceivedArgs e)
{
var incomingMessage = e.ChatMessage.Message;
//Profanity filter testing received message (need to get incoming message over to profanityFilter.cs)
profanityFilter.Filter();
Console.WriteLine($"[{TwitchInformation.BotName}]: [{e.ChatMessage.DisplayName}]:
{e.ChatMessage.Message}");
}
}
亵渎过滤器.cs:
class profanityFilter
{
public static async void Filter()
{
var client = new HttpClient();
Bot message = new Bot();
var incomingMessagesFromUser = message.Client_OnMessageReceived.IncomingMessages;
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("https://neutrinoapi-bad-word-filter.p.rapidapi.com/bad-word-filter"),
Headers =
{
{ "x-rapidapi-key", "xxx" },
{ "x-rapidapi-host", "neutrinoapi-bad-word-filter.p.rapidapi.com" },
},
Content = new FormUrlEncodedContent(new Dictionary<string, string>
{
{ "censor-character", "*" },
{ "content", incomingMessagesFromUser },
}),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
}
}
但我收到此屏幕截图中显示的错误: