This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Make Eggdrop blind to control codes

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Make Eggdrop blind to control codes

Post by SpiKe^^ »

This post is in response to the following conversation on #egghelp @ freenode.
<AlphaTech> In the built-in logs how can I disable color? It making funky logs on my logging webpage
<SpiKe^^> not sure if there's a better way, but you could try a little proc i have used to remove all colorcodes from everything the bot sees
<SpiKe^^> but it will affect everything the bot sees, not just the logging stuff
I'm thinking this may of use to others also...

Code: Select all

catch {unbind raw - PRIVMSG *raw:irc:msg}
bind raw - PRIVMSG striprivmsg

proc striprivmsg {f k a} {
  set a [string map [list \017 ""] [stripcodes abcgru $a]]
  *raw:irc:msg $f $k $a
}

This is what BogusTrivia uses to make binds trigger on text that contains control codes.
This code is adapted from an old egghelp.org forum post @ http://forum.egghelp.org/viewtopic.php?t=12944
Please let me know if this helps, AlphaTech.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

This has been discussed before and user offered a solution here.

Code: Select all

unbind raw - PRIVMSG *raw:irc:msg
unbind raw - PRIVMSG *raw:PRIVMSG
bind raw - PRIVMSG striprivmsg
proc striprivmsg {f k a} {
   set a [stripcodes abcgru $a]
   *raw:irc:msg $f $k $a
   *raw:PRIVMSG $f $k $a
}
Once the game is over, the king and the pawn go back in the same box.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Yup, I mentioned that same prior post too.

This is a revised version of that same proc.
1. As of eggdrop 1.6.21, [stripcodes abcgru $string] does not strip the control code \017, an issue thommey is aware of.
2. For most uses, the "unbind raw - PRIVMSG *raw:PRIVMSG" is not needed.
3. This is a complete example of that proc, with the unbind in a catch, to keep it from killing the bot on rehash.

Thanks for pointing out the prior post I already did though.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Oh snap. To be honest haven't checked the topic you mentioned. /facepalm

Just remembered saw something like this before and wanted to help out and made a fool of myself in the process. :roll:
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

anyway to strip incoming messages only and not outgoing ?
User avatar
CrazyCat
Revered One
Posts: 1215
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

As said on IRC:

Code: Select all

proc striprivmsg {f k a} {
   if {$f ne "${::botnick}![getchanhost $::botnick]"} {
      set a [stripcodes abcgru $a]
   }
   *raw:irc:msg $f $k $a
   *raw:PRIVMSG $f $k $a
}
This will let the message unchanged if emetter is the eggdrop
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

oh euhm yea thanks CC i posted this before i found out i had controlstrip module loaded on znc thats why i couldnt see any color codes after unloading it all was fine.

thanks again CC much apreciated.
u
user12
Voice
Posts: 3
Joined: Thu May 19, 2022 2:32 am

Re: Make Eggdrop blind to control codes

Post by user12 »

SpiKe^^ wrote:This post is in response to the following conversation on #egghelp @ freenode.
<AlphaTech> In the built-in logs how can I disable color? It making funky logs on my logging webpage
<SpiKe^^> not sure if there's a better way, but you could try a little proc i have used to remove all colorcodes from everything the bot sees
<SpiKe^^> but it will affect everything the bot sees, not just the logging stuff
I'm thinking this may of use to others also...

Code: Select all

catch {unbind raw - PRIVMSG *raw:irc:msg}
bind raw - PRIVMSG striprivmsg

proc striprivmsg {f k a} {
  set a [string map [list \017 ""] [stripcodes abcgru $a]]
  *raw:irc:msg $f $k $a
}

This is what BogusTrivia uses to make binds trigger on text that contains control codes.
This code is adapted from an old egghelp.org forum post @ http://forum.egghelp.org/viewtopic.php?t=12944
Please let me know if this helps, AlphaTech.


that code doesn't work with utf-8 especially emojis :D :D :D
yes
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

That code has little to do with how your bot does utf-8

See these links for help with utf-8 issues with tcl/eggdrop

https://github.com/eggheads/eggdrop/issues/4

[07:42] <SergioR> it's Tcl issue, not eggdrop
[07:43] <SergioR> utf-8 extended = generic/tcl.h - #define TCL_UTF_MAX 6
[07:45] <SergioR> https://snap.servx.org/-UykzuNVHJQ

https://wiki.eggheads.org/index.php/UTF-8
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
u
user12
Voice
Posts: 3
Joined: Thu May 19, 2022 2:32 am

Ok,

Post by user12 »

Let's see if I explain myself better XD, using eggdrop with utf-8 "emojis" when using !Say 😀 the bot copies the message well using emojis, but by adding this code, it kills the emojis when using !Say 😀 sends signs
yes
Post Reply