| View previous topic :: View next topic |
| Author |
Message |
Nimos Halfop
Joined: 20 Apr 2008 Posts: 80
|
Posted: Sun Apr 20, 2008 10:04 am Post subject: AFK-Script |
|
|
Is it possible to make a scripte where Users can set theirselves afk, and when this users name is said in the Channel the bot says that the user is afk?
| Quote: | Example:
User1: !afk eating
Bot(MSG): Status set!
User2 comes into the channel
User2: Hi User1, whats up?
Bot: User1 is afk at the moment: eating
User2: back
Bot(MSG): You are no longer marked as being afk!
|
If its possible, i would be glad if someone here could script it  |
|
| Back to top |
|
 |
tueb Halfop
Joined: 04 Oct 2007 Posts: 76 Location: #quiz.de @ irc.gamesurge.net
|
Posted: Mon Apr 21, 2008 8:55 am Post subject: |
|
|
Hi,
interesting script you requested. I tried to fill it: The commands are "!afk" and "!back".
There are most likely a few bugs in it. Please contact me after testing, so I can try to fix them.
| Code: | bind pub - !afk afk_set
bind pub - !back afk_back
#bind pub - afk afk_set
#bind pub - back afk_back
bind pubm - * afk_pubm
variable afkarray
variable whoarray
proc afk_back {nick host handle channel text} {
global afkarray whoarray
if {[info exists afkarray($nick)]} {
unset afkarray($nick)
afk_notc $nick "Du bist nicht länger \"!afk\"."
if {[info exists whoarray($nick)]} {
#this needs to be changed in case more than one person has been looking for you
afk_notc $nick "$whoarray($nick) hat/haben Dich in Deiner Abwesenheit gesucht."
unset whoarray($nick)
}
} else {
afk_notc $nick "Du warst nicht \"!afk\"."
}
}
proc afk_set {nick host handle channel text} {
global afkarray whoarray
if {$text == ""} {
set text "."
} else {
set text ": \002$text\002"
}
if {![info exists afkarray($nick)]} {
set afkarray($nick) $text
} else {
set entry $afkarray($nick)
set afkarray($nick) $text
}
afk_notc $nick "Du bist auf \002away from keyboard\002 gesetzt. Grund${text}. Zurück setzt Du Dich mit \002!back\002."
}
proc afk_pubm {nick host handle channel text} {
global afkarray whoarray
if {$text=="^"||$text=="^^"||$text=="^^^"||$text=="*"} {
return
}
foreach name [array names afkarray] {
regsub -all {\(} $text "" text
regsub -all {\)} $text "" text
regsub -all {\{} $text "" text
regsub -all {\}} $text "" text
regsub -all {\[} $text "" text
regsub -all {\]} $text "" text
if {[regexp -nocase -- $text $name]} {
set afkmsg "$name ist away from keyboard"
afk_notc $nick "${afkmsg}. Grund$afkarray($name). Eine eigene away-Nachricht setzt Du Dir mit !away <text>."
regsub -all {\|} $nick {} whonick
if {[info exists whoarray($name)]} {
set who $whoarray($name)
set entry $whoarray($name)
set whoarray($name) "$who and $whonick"
} else {
set whoarray($name) $whonick
}
#break
}
}
}
proc afk_say {channel text} {
putquick "PRIVMSG $channel :$text"
}
proc afk_notc {nick text} {
putquick "NOTICE $nick :$text"
} |
_________________ #Quiz.de @ irc.GameSurge.net
JavaChat
Last edited by tueb on Mon Apr 21, 2008 3:05 pm; edited 2 times in total |
|
| Back to top |
|
 |
Nimos Halfop
Joined: 20 Apr 2008 Posts: 80
|
Posted: Mon Apr 21, 2008 10:55 am Post subject: |
|
|
hm....thanks for your work, but. . .
!afk -- Seems to work (the bot anwers with You have been...)
!back -- shows no reaction
and the nick call shows no reaction, too... |
|
| Back to top |
|
 |
tueb Halfop
Joined: 04 Oct 2007 Posts: 76 Location: #quiz.de @ irc.gamesurge.net
|
Posted: Mon Apr 21, 2008 11:19 am Post subject: |
|
|
please try the updated code above. _________________ #Quiz.de @ irc.GameSurge.net
JavaChat |
|
| Back to top |
|
 |
Nimos Halfop
Joined: 20 Apr 2008 Posts: 80
|
Posted: Mon Apr 21, 2008 11:57 am Post subject: |
|
|
wow its working now! thank you
a little error is left: in partyline appears, everytime someone talks:
[17:56] Tcl error [afk_pubm]: couldn't compile regular expression pattern: quantifier operand invalid |
|
| Back to top |
|
 |
tueb Halfop
Joined: 04 Oct 2007 Posts: 76 Location: #quiz.de @ irc.gamesurge.net
|
Posted: Mon Apr 21, 2008 12:45 pm Post subject: |
|
|
aegh, always the same problem with my scripts.
i'll contact you over icq.
PS: Changed my first thread into the newest version. _________________ #Quiz.de @ irc.GameSurge.net
JavaChat |
|
| Back to top |
|
 |
holycrap Op
Joined: 21 Jan 2008 Posts: 152
|
Posted: Sat Jul 12, 2008 4:50 am Post subject: |
|
|
It won't work if the nick is mentioned in a sentence. It only works if the nick is mentioned by itself.
Anyway to fix this?
Last edited by holycrap on Sat Jul 12, 2008 11:47 pm; edited 1 time in total |
|
| Back to top |
|
 |
strikelight Owner

Joined: 07 Oct 2002 Posts: 708
|
Posted: Sat Jul 12, 2008 12:42 pm Post subject: |
|
|
I would guess you would need to change this part of the code:
| Code: |
regsub -all {\(} $text "" text
regsub -all {\)} $text "" text
regsub -all {\{} $text "" text
regsub -all {\}} $text "" text
regsub -all {\[} $text "" text
regsub -all {\]} $text "" text
if {[regexp -nocase -- $text $name]} {
|
Change $text and text into $name and name in the regsub's.. And swap $name with $text in the regexp. |
|
| Back to top |
|
 |
holycrap Op
Joined: 21 Jan 2008 Posts: 152
|
Posted: Sun Jul 13, 2008 12:00 am Post subject: |
|
|
| Thanks strikelight for your time. But this script still has too many bugs, for example if you part the channel without setting !back, it will think that you are still away when you rejoin. It does not reset and will just keep saything the away message untill you change to that nick and set !back. Weird... |
|
| Back to top |
|
 |
tueb Halfop
Joined: 04 Oct 2007 Posts: 76 Location: #quiz.de @ irc.gamesurge.net
|
Posted: Thu Jul 31, 2008 12:11 pm Post subject: |
|
|
if you want the bot to to react on part, use "bind part"... _________________ #Quiz.de @ irc.GameSurge.net
JavaChat |
|
| Back to top |
|
 |
holycrap Op
Joined: 21 Jan 2008 Posts: 152
|
Posted: Sun Aug 10, 2008 10:22 pm Post subject: |
|
|
tueb, can you do me a favor and paste the new code on here? I don't know what "blind part" that you're talking about.
Thanks!
 |
|
| Back to top |
|
 |
Sh3ny Voice

Joined: 05 Aug 2008 Posts: 7
|
Posted: Wed Aug 13, 2008 1:24 pm Post subject: |
|
|
hi
i get this error.
| Code: | | [15:58] Tcl error [afk_pubm]: couldn't compile regular expression pattern: quantifier operand invalid |
can paste de fix code?
 |
|
| Back to top |
|
 |
|