mIRC bot - copy/paste lines in 2 channels

柔情痞子 提交于 2019-12-11 04:52:21

问题


I’m a noob in mirc scripting, and I need some help.

  1. there’s 2 irc channels. let’s call then #channel1 and #channel2;
  2. There’s 2 bots. One is mine, let’s call him “mybot” (my bot is in both channels). The other bot is from a third person, let’s call him “otherBot”;

What I need is… let me make an example to better explain.

a) in #channel1 some user type:

[14:38:48] <@someuser> !user xpto

At this time, “mybot” is in both channels. he reads the command “!user*” and copy/paste it in #channel2, where the “otherBot” will recognize the command “!user*” and will paste some information about this command.

b) so, in #channel2 it will append something like:

[14:38:50] <@ mybot > !user xpto
[14:38:52] <@ otherBot > User name is xpto and he likes popatos.

Now I want that “mybot” reads the information provided by the “otherBot” and then paste it on #channel1

c) so, in #channel1:

[14:38:54] <@ mybot > User name is xpto and he likes popatos.

So far I have the fowling code in my remote:

on *:TEXT:!user*:#channel1 {
  /msg # channel2 $1-
}

on *:TEXT:User name*:#channel2 {
  if $address($nick,2) == *!*@otherBot.users.gameea {
    /msg # channel1 $1-
   }
 }

This works fine, but have a problem: if someone else ( not “mybot” ) type “!user kakaka” in #channel2, “mybot” will also copy/paste the information provided by the “otherBot” and then paste it on #channel1. And I only want that “mybot” copy/paste only the information that “mybot” ask to “otherBot”.


回答1:


A very simple (but not a particularly nice) way of doing this could be to set a global variable when someone types !user in #channel1, and check whether or not this is set in the other part which is listening on #channel2. For example:

on *:TEXT:!user *:#channel1: {
  set %repeatUser 1
  msg channel2 $1-
}

on *:TEXT:User name*:#channel2: {
  if ($address($nick,2) == *!*@otherBot.users.gameea && %repeatUser == 1) {
    unset %repeatUser
    msg #channel1 $1-
  }
}

This isn't a perfect solution, since if the bot says something else between the time it takes for the script to send '!user' to the other channel and for the bot to respond, then it will print out that reply instead of the one for your request, but this is only relevant if #channel2 is ridiculously busy, otherbot is very laggy, or it just so happens that both your bot and someone else type !user on #channel2 within a fraction of a second of eachother.



来源:https://stackoverflow.com/questions/10564789/mirc-bot-copy-paste-lines-in-2-channels

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!