mIRC Home    About    Download    Register    News    Help

Print Thread
#152535 02/07/06 07:21 AM
M
md5
md5
M
Hello everyone, i have a quick question to ask... is their a script out there for mIRC where it basically is a Question / Answer bot? What i am looking for is a bot that when a user PM's it a string of text it will add it to a file with a unique ID number. Than once it has been added to the waiting list, the bot controller can type a trigger that shows the recent entries in to the list from a private channel. Than if the question is good, the bot controller is able to send the question to the event channel. If the question is bad how ever, it can be deleted by a trigger to delete the ID number.

So, is there a script out there currently that does this? confused

#152536 02/07/06 07:38 AM
Joined: Aug 2004
Posts: 7,168
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,168
If there isn't, and no one else replies with something decent before I get around to it, I'll do one up for you in the morning. Probably have it in 12 to 18 hours from this post (allowing 8 hours for me to get some sleep)

#152537 02/07/06 07:46 AM
M
md5
md5
M
Many thanks if you do make a script for it.. smile

#152538 02/07/06 09:33 AM
Joined: Aug 2004
Posts: 7,168
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,168
Give this a try
Code:
 on op:text:!add*:*:{
  .auser -a op $$2 $nick
}
on op:text:!review:*:{
  var %a = 1, %b = $hget(Questions,0).item
  while %a <= %b {
    if $hget(Questions,%a).item > $hget(Questions,0).item {
      .msg $nick ID: $hget(Questions,%a).item
      .msg $nick Question: $hget(Questions,%a).data
    }
    inc %a
  }
}
on op:text:!del*:*:{
  if $hget(Questions,$$2) && ($$2 > $hget(Questions,0).item) {
    .hdel Questions $$2
  }
}
on op:text:!save*:*:{
  if $hget(Questions,$$2) && ($$2 > $hget(Questions,0).item) {
    .hinc $hget(Questions,0)
    .hadd -m Questions $hget(Questions,0) $hget(Questions,$$2).data
    .hdel Questions $$2
  }
}
on *:text:*:?:{
  .hadd -m Questions $ctime $1-
}
on *:start:{
  if !$hget(Questions) { .hmake Questions 100 }
  if $exists(Questions.hsh) { .hload Questions Questions.hsh }
}
on *:exit:{
  .hsave -o Questions Questions.hsh
}
on *:disconnect:{
  .hsave -o Questions Questions.hsh
}
 


You'll have to establish at least one person as authorized to review/save/delete by using the following command ON THE BOT'S ACCESS
Code:
 /auser -a op <nick> 

Once there is one person listed, then they can add others to the authorized list with the !add command. If they authorize someone else, then they're nick is associated with the nick of the person that was added.

I tried to keep it fairly simple, yet speedy and have the controls that you requested. If you have any questions about the script, post them and I'll do my best to explain anything you don't understand.

#152539 02/07/06 03:34 PM
Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
Nice script.
I tried using it as well, but I encountered some problems.

Adding a reviewer worked.
Then adding a question, by pm'ing the bot worked also.
Reviewing and deleting them works fine as well.

But !save doesnt work.
I try: !save 1151852833 (which is a ID of one of the questions)
And I get: * /hinc: insufficient parameters (line 23,script.mrc)
What's the purpose by the way of this command?

I also noticed that the questions are not FIFO, so when typing !review it just shows all questions, but not in order from asking. This would be nice as well imo.

Also, I dont see a way to message the reviewed question, in the actual channel. Something like !next. The bot would then message the next question, which has been reviewed. Again, FIFO would be nice here as well.

Owww, and also adding the nick of the person that asked the question, would be good I think. It doesn't have to show the nick in the actual Q&A channel, but in the review stage, it would be good to see who asked the question. For example to stop abuse.

Could you maybe expand this script a bit?
It's a handy tool I think...

Last edited by OrionsBelt; 02/07/06 03:54 PM.
#152540 02/07/06 05:12 PM
Joined: Aug 2004
Posts: 7,168
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,168
Try changing
Code:
 .hinc $hget(Questions,0) 
to
Code:
 $iif(!$hget(Questions,0),.hadd -m Questions 0 1,.hinc Questions 0 1) 

This is a counter of the questions that have been reviewed and approved. It also controls the new ID for the approved question so that the next time a !review is done, that question won't show up (unless it's been entered on or more times since the approval)

The questions should be coming out (under !review) in a FIFO format, since the ID number is based upon the $ctime value when the question was entered.

Regarding sending the questions to the channel, sorry I didn't think of that. This should do it.

Code:
 on op:text:!next:#:{
var %a = 1, %b = $hget(Questions,0)
while %a <= %b {
.timer 1 %a .msg $chan Question %a reads $gettok($hget(Questions,%a),2-,32)
inc %a
}
}
;replace the original section for storing the questions with this
on *:text:*:?:{
  .hadd -m Questions $ctime $nick $1-
}
 


I think I covered everything, and while I was at it I thought of some ways to improve the code, but they're going to take a bit more research (eg: having the code wait for !save, !del (without a number) or !next to save/delete the current question under review, before going to the next question. (!next would be used to bypass the question for further review later on)). Also checking to see if a question has already been entered (either waiting for review or saved), to prevent duplicates.

If you'd like these, I will research how to do it, and get back, however, I've got no idea as to how long it'll take as I've got other projects on the go.

Last edited by RusselB; 02/07/06 05:23 PM.
#152541 02/07/06 05:35 PM
Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
Thanks for these modifications, although I didn't get the !next thing to work yet.
It messages: =19:24:24= <@Bot> Question 1 reads
Without the actual question, that did get approved.

In any case, if you can find time for 'upgrading' the script, I would love it.
It's a nice script, that can be used for many occasions.

Just +m the channel, voice the bot, and have Q&A sessions.
Very nice imo.

I'll keep an eye on this thread, and thx for these modifications already.

#152542 02/07/06 06:30 PM
Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
I'm not trying to step on any toes, just I like trying to accomplish the things asked on these forums as a learning basis. That being said, I tried this script and (based on the feedback from Russel's attempts) came up with this:

Code:
; -----------------------------------------------------------------------------
; Vote Bot Project
; -----------------------------------------------------------------------------

;
; Table Information
alias -l q.tbl { return Questions }
alias -l q.file { return questions.hsh }

;
; Startup - Intitiation
;
on *:START: {
  if (!$hget($q.tbl)) /hmake $q.tbl 10
  if ($isFile($q.file)) /hload -b $q.tbl $q.file
  else {
    /hadd $q.tbl QID 0
    /hadd $q.tbl Ques 0
    /hsave $q.tbl -bo $q.file
  }
}

;
; Exiting - Cleanup
;
on *:EXIT: {
  if ($hget($q.tbl)) {
    /hsave -bo $q.tbl $q.file
    /hfree $q.tbl
  }
}

;
; Add Users
;
on op:TEXT:!add &amp;:*: {
  /auser op $2 $nick
  /msg $nick $2 added to the user list.
}

;
; delete question
;
on op:TEXT:!del &amp;:*: {
  if ($hget($q.tbl,$2) &amp;&amp; $regex($2,/[0-9]{10}/)) {
    /hdel $q.tbl $2
    /msg $nick Item $2 deleted.
  }
}

;
; next question
;
on op:TEXT:!next:#:{
  if ($hget($q.tbl,Ques) &lt; $hget($q.tbl,QID)) {
    /hinc -m $q.tbl Ques
    /msg $chan $hget($q.tbl,$hget($q.tbl,Ques))
  }
}

;
; repeat the last question
;
on op:TEXT:!repeat:#:{
  if ($hget($q.tbl,Ques) &lt;= $hget($q.tbl,QID)) {
    /msg $chan $hget($q.tbl,$hget($q.tbl,Ques))
  }
}

;
; review questions
;
on op:TEXT:!review:*: {
  var %reg_review = /^[0-9]{10}$/
  if ($hfind($q.tbl,%reg_review,0,r)) {
    var %win1 = $+(@__,$rand(88888,99999)), %win2 = $+(@__,$rand(88888,99999))

    /window -h %win1
    /window -h %win2

    var %q = $v1
    while (%q &gt; 0) {
      var %id = $hfind($q.tbl,%reg_review,%q,r)
      /echo %win1 %id
      /dec %q
    }

    /filter -euww %win1 %win2

    /msg $nick Review Questions:
    var %q = $line(%win2,0)
    while (%q &gt; 0) {
      var %id = $line(%win2,%q), %data = $hget($q.tbl,%id)
      /msg $nick %id $+ : %data
      /dec %q
    }

    /close -@ @__*
  }
  else /msg $nick No questions to review.
}

;
; Save Question
;
on op:TEXT:!save &amp;:*: {
  if ($hget($q.tbl,$2) &amp;&amp; $regex($2,/[0-9]{10}/)) {
    /hinc -m $q.tbl QID
    /hadd -m $q.tbl $hget($q.tbl,QID) $hget($q.tbl,$2)
    /hdel $q.tbl $2
    /msg $nick Item $2 saved.
  }
}

;
; Add Question (PM)
;
on *:TEXT:*:?:{
  if (!$hfind(%sock,$1-).data) /hadd -m $q.tbl $ctime $1-
}

;
; Menu - Nicklist (adding authorized users)
;
menu nicklist {
  Voting
  .$iif($ulist($$1,op,0),Remove User):.ruser op $$1 $me
  .$iif(!$ulist($$1,op,0),Add User):.auser op $$1 $me
}


It should do what you want, as I tried it on my own channel. wink Again, not trying to insult anyone, just I attempted it as well. I used many of Russel's setups, but added and removed a few things. Added a menu to the bot to add users via right-clicking the nicklist, but removed the 'silence' it left me after sending a command (I like confirmation the bot did what i told it to wink). Enjoy.

#152543 02/07/06 10:08 PM
Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
I tried your script KingTomato, but I get stuck with the !next or !repeat commands?
It doesn't seem to relay any saved messages to the actual Q&A channel. Can you check? Or am I doing something wrong?

Thanks for also putting effort in this grin

#152544 02/07/06 10:59 PM
Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
They do work!

I restarted the bot, and deleted the questions.hsh file.
After that it was fine.

I'm just playing a bit with this part:
Code:
on op:TEXT:!next:%botchannel:{
  if ($hget($q.tbl,Ques) &lt; $hget($q.tbl,QID)) {
    hinc -m $q.tbl Ques
    .msg $chan $hget($q.tbl,$hget($q.tbl,Ques))
  }
  else {
    var %reg_review = /^[0-9]{10}$/
    if ($hfind($q.tbl,%reg_review,0,r)) {
      .msg $chan No more approved questions ([color:blue]x[/color] new questions in approval queue).
    }
    else {
      .msg $chan No more open questions!
    }
  }
}


Basicly if all reviewed questions are done, I would like the bot to let me know. So I changed the code a bit.
But I would like to see how many questions are still in the queue. Is that possible?

<bot> No more approved questions (x new questions in approval queue).

And also, would it be possible to add the nick of the person asking the question somewhere? So that during review you can see who asked the question, but when relayed to the Q&A channel, it doesn't show the nick?

Thanks!

#152545 02/07/06 11:32 PM
Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
This should do the trick: Again, refresh the hash file, and try again.

Code:
; -----------------------------------------------------------------------------
; Vote Bot Project
; -----------------------------------------------------------------------------

;
; Table Information
alias -l q.tbl { return Questions }
alias -l q.file { return questions.hsh }

;
; Startup - Intitiation
;
on *:START: {
  if (!$hget($q.tbl)) /hmake $q.tbl 10
  if ($isFile($q.file)) /hload -b $q.tbl $q.file
  else {
    /hadd $q.tbl QID 0
    /hadd $q.tbl Ques 0
    /hsave $q.tbl -bo $q.file
  }
}

;
; Exiting - Cleanup
;
on *:EXIT: {
  if ($hget($q.tbl)) {
    /hsave -bo $q.tbl $q.file
    /hfree $q.tbl
  }
}

;
; Add Users
;
on op:TEXT:!add &amp;:*: {
  /auser op $2 $nick
  /msg $nick $2 added to the user list.
}

;
; delete question
;
on op:TEXT:!del &amp;:*: {
  if ($hget($q.tbl,$2) &amp;&amp; $regex($2,/[0-9]{10}/)) {
    /hdel $q.tbl $2
    /msg $nick Item $2 deleted.
  }
}

;
; next question
;
on op:TEXT:!next:#:{
  if ($hget($q.tbl,Ques) &lt; $hget($q.tbl,QID)) {
    /hinc -m $q.tbl Ques
    /msg $chan $gettok($hget($q.tbl,$hget($q.tbl,Ques)),2-,32)
  }
  else if ($hfind($q.tbl,/^[0-9]{10}$/,0,r)) {
    /msg $chan No more approved questions ( $+ $v1 more questions in approval queue).
  }
  else /msg $chan No more open questions!
}

;
; repeat the last question
;
on op:TEXT:!repeat:#:{
  if ($hget($q.tbl,Ques) &lt;= $hget($q.tbl,QID)) {
    /msg $chan $gettok($hget($q.tbl,$hget($q.tbl,Ques)),2-,32)
  }
}

;
; review questions
;
on op:TEXT:!review:*: {
  var %reg_review = /^[0-9]{10}$/
  if ($hfind($q.tbl,%reg_review,0,r)) {
    var %win1 = $+(@__,$rand(88888,99999)), %win2 = $+(@__,$rand(88888,99999))

    /window -h %win1
    /window -h %win2

    var %q = $v1
    while (%q &gt; 0) {
      var %id = $hfind($q.tbl,%reg_review,%q,r)
      /echo %win1 %id
      /dec %q
    }

    /filter -euww %win1 %win2

    /msg $nick Review Questions:
    var %q = $line(%win2,0)
    while (%q &gt; 0) {
      var %id = $line(%win2,%q), %data = $hget($q.tbl,%id)
      /msg $nick %id $+ : (by $gettok(%data,1,32) $+ ) $gettok(%data,2-,32)
      /dec %q
    }

    /close -@ @__*
  }
  else /msg $nick No questions to review.
}

;
; Save Question
;
on op:TEXT:!save &amp;:*: {
  if ($hget($q.tbl,$2) &amp;&amp; $regex($2,/[0-9]{10}/)) {
    /hinc -m $q.tbl QID
    /hadd -m $q.tbl $hget($q.tbl,QID) $hget($q.tbl,$2)
    /hdel $q.tbl $2
    /msg $nick Item $2 saved.
  }
}

;
; Add Question (PM)
;
on *:TEXT:*:?:{
  if (!$hfind(%sock,$1-).data) /hadd -m $q.tbl $ctime $nick $1-
}

;
; Menu - Nicklist (adding authorized users)
;
menu nicklist {
  Voting
  .$iif($ulist($$1,op,0),Remove User):.ruser op $$1 $me
  .$iif(!$ulist($$1,op,0),Add User):.auser op $$1 $me
}

#152546 03/07/06 05:37 PM
Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
Yeah, this looks like a pretty slick script to me.
It definately works fine here.

Thanks a lot RusselB and KingTomato, both of ya.
I hope this also works for MD5, but I think this covers most options.

Thx again laugh


Link Copied to Clipboard