StreamReader 的问题
好吧,这就是我到目前为止所拥有的,
List<string> lines = new List<string>();
using (StreamReader r = new StreamReader(f))
{
string line;
while ((line = r.ReadLine()) != null)
{
lines.Add(line);
}
}
foreach (string s in lines)
{
NetworkStream stream = irc.GetStream();
writer.WriteLine(USER);
writer.Flush();
writer.WriteLine("NICK " + NICK);
writer.Flush();
writer.WriteLine("JOIN " + s);
writer.Flush();
string trimmedString = string.Empty;
CHANNEL = s;
}
不幸的是,当我的 IRC 虚拟人进入一个设置了密码的房间时,它会写出密码,如果我使用 #lol test
test 作为密码等命令让它更改频道,因为 CHANNEL = s;它用命令写出密码
writer.WriteLine("PRIVMSG " + CHANNEL + " :" + "Hello");
这是写出IRC的唯一方法,所以有没有办法让“CHANNEL”仅作为文本的开头并且只是#lol,这样它就不会写出密码?
我希望你理解我的问题。
Alright so here is what I have so far,
List<string> lines = new List<string>();
using (StreamReader r = new StreamReader(f))
{
string line;
while ((line = r.ReadLine()) != null)
{
lines.Add(line);
}
}
foreach (string s in lines)
{
NetworkStream stream = irc.GetStream();
writer.WriteLine(USER);
writer.Flush();
writer.WriteLine("NICK " + NICK);
writer.Flush();
writer.WriteLine("JOIN " + s);
writer.Flush();
string trimmedString = string.Empty;
CHANNEL = s;
}
Unfortunately when my IRC dummy enters a room with a password set it writes out the password, if I make it change channel with a command such as #lol test
test being the password, since CHANNEL = s; it writes out the password with the command
writer.WriteLine("PRIVMSG " + CHANNEL + " :" + "Hello");
That is the only way to write out to IRC so is there a way for the "CHANNEL" to only be the start of the text and just #lol so it doesn't write out the password?
I hope you understand my problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在空格上拆分并获取第一项:
这将导致
{ "#lol", "test" }
尽管理想情况下会事先检查:You can split on a space and take the first item:
This would result in
{ "#lol", "test" }
although ideally would check beforehand: