字符串检测
所以我正在编写一个 php IRCbot 脚本,我想知道..如果我要实现一个字符串检测系统,我是否正在谈论带有字符串比较的无限循环?
或者有更有效的方法吗?
本质上,我正在努力完成这样的事情。
<User1> !say Hello!
<phpBot> Hello!
So I'm writing a php IRCbot script, and I'm wondering.. if I were to implement a string detection system, am I talking an infinite loop with string compare?
Or is there a more efficient way?
Essentially, I'm trying to accomplish something like this.
<User1> !say Hello!
<phpBot> Hello!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信,这就是您正在寻找的:
当然,您可以根据需要添加任意数量的 if/else,只需更改解析字符的长度即可。
This, i believe, is what you are looking for:
Of course you can add as many if/else as you need, just need to change the length of the parsed characters.
我认为使用 preg_match 解析命令比编写命令要容易得多简单解析器:
这是不区分大小写的,所以 !SAY 也可以工作。
I think using preg_match to parse the commands is much easier than even write a simple parser:
This is case insensitive so !SAY would also work.