TclApps Library Source Code
Check-in [dd7ab85b0a]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added ban/unban support and move the self-op code to topic event
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: dd7ab85b0ab89fd2289d3833658480e736de5022
User & Date: patthoyts 2008-12-13 16:33:52.000
Context
2008-12-13
19:50
Notify the irc channel when jabber users arrive and depart check-in: 3617463d57 user: patthoyts tags: trunk
16:33
Added ban/unban support and move the self-op code to topic event check-in: dd7ab85b0a user: patthoyts tags: trunk
2008-11-13
00:08
Added option to show whispered (xmpp normal) messages inline in the chat as was done before 1.442 check-in: dae1a19736 user: patthoyts tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to apps/ijbridge/ChangeLog.





1
2
3
4
5
6
7





2008-09-04  Pat Thoyts <[email protected]>

	* ijbridge.tcl: Do not let jabber users make the bot kick itself.

2008-02-25  Pat Thoyts <[email protected]>

	* ijbridge.tcl: Support recording user colors (from tkchat)
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
2008-12-13  Pat Thoyts <[email protected]>

	* ijbridge.tcl: Added ban/unban support and move the self-op code
	                off the end-of-names event.

2008-09-04  Pat Thoyts <[email protected]>

	* ijbridge.tcl: Do not let jabber users make the bot kick itself.

2008-02-25  Pat Thoyts <[email protected]>

	* ijbridge.tcl: Support recording user colors (from tkchat)
Changes to apps/ijbridge/ijbridge.tcl.
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package require irc 0.4;                # tcllib

namespace eval client {}

namespace eval ::ijbridge {

    variable version 1.1.1
    variable rcsid {$Id: ijbridge.tcl,v 1.32 2008/09/04 12:41:45 patthoyts Exp $}

    # This array MUST be set up by reading the configuration file. The
    # member names given here define the settings permitted in the 
    # config file.
    # This script will not work by default - you MUST provide suitable 
    # connection details.
    #







|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package require irc 0.4;                # tcllib

namespace eval client {}

namespace eval ::ijbridge {

    variable version 1.1.1
    variable rcsid {$Id: ijbridge.tcl,v 1.33 2008/12/13 16:33:52 patthoyts Exp $}

    # This array MUST be set up by reading the configuration file. The
    # member names given here define the settings permitted in the 
    # config file.
    # This script will not work by default - you MUST provide suitable 
    # connection details.
    #
540
541
542
543
544
545
546
547








548
549
550
551
552
553
554
                        "\n help       show this message\n\
                         names      returns a list of all IRC users\n\
                         version    returns the bridge code version\n\
                         rcsid      returns the RCS version of this file\n\
                         stats      display chatroom statistics\n\
                         last nick  how long since this user spoke\n\
                         whois nick get irc WHOIS information\n\
                         kick nick  kick irc user"








                }
                WHOIS* - whois* {
                    array set whois {nick "" caller "" realname "" url "" channels "" status "" host ""}
                    set ::client::whois(caller) $a(-from)
                    set ::client::whois(nick) [string range $a(-body) 6 end]
                    xmit $::client::whois(nick)
                    xmit "WHOIS $::client::whois(nick)"







|
>
>
>
>
>
>
>
>







540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
                        "\n help       show this message\n\
                         names      returns a list of all IRC users\n\
                         version    returns the bridge code version\n\
                         rcsid      returns the RCS version of this file\n\
                         stats      display chatroom statistics\n\
                         last nick  how long since this user spoke\n\
                         whois nick get irc WHOIS information\n\
                         kick nick  remove user from the channl\n\
                         ban nick   ban user from this channel\n\
                         unban nick remove a ban"
                    send -user $a(-from) \
                        -id $Options(Conference)/$Options(JabberUser) \
                        "NOTE: kick, ban and unban should be used rarely. Also as we only use\
                        the irc nick the user may rejoin using a modfied nick. If this occurs,\
                        contact one of the irc channel admins and they can assign a more stringent\
                        ban using the users host address"
                }
                WHOIS* - whois* {
                    array set whois {nick "" caller "" realname "" url "" channels "" status "" host ""}
                    set ::client::whois(caller) $a(-from)
                    set ::client::whois(nick) [string range $a(-body) 6 end]
                    xmit $::client::whois(nick)
                    xmit "WHOIS $::client::whois(nick)"
563
564
565
566
567
568
569
570
571
572
573



574
575


































576
577
578
579
580
581
582
                    send -user $a(-from) $::ijbridge::version
                }
                RCSID - rcsid {
                    send -user $a(-from) $::ijbridge::rcsid
                }
                KICK* - kick* {
                    log::log notice "$a(-from) $a(-body)"
                    set user [lindex $a(-body) 1]
                    if {$user eq $::client::nick} {
                        send -user $a(-from) "I cannot kick myself!!"
                    } else {



                        xmit "KICK $::client::channel $user"
                        send -user $a(-from) "Kicking $user."


































                    }
                }
                STATS - stats - STATISTICS - statistics {
                    # This is not done as a bot command as it floods irc
                    # too much and gets the bot kicked by freenode.
                    variable stats
                    set m [format {%- 30s %- 18s % 8s% 10s} \







|
|
|
|
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
                    send -user $a(-from) $::ijbridge::version
                }
                RCSID - rcsid {
                    send -user $a(-from) $::ijbridge::rcsid
                }
                KICK* - kick* {
                    log::log notice "$a(-from) $a(-body)"
                    if {[regexp {(?:\S+)\s+(\S+)(?:\s+(.*))?} [string trim $a(-body)] -> user reason]} {
                        if {$user eq $::client::nick} {
                            send -user $a(-from) "I will not kick myself!!"
                        } else {
                            if {[string length $reason] < 1} {
                                set reason "kicked by $a(-from)"
                            }
                            xmit "KICK $::client::channel ${user} :${reason}"
                            send -user $a(-from) "Kicked $user."
                        }
                    } else {
                        send -user $a(-from) "usage: KICK nick ?reason?"
                    }
                }
                "BAN*" - "ban*" {
                    log::log notice "$a(-from) $a(-body)"
                    if {[regexp {(?:\S+)\s+(\S+)(?:\s+(.*))?} [string trim $a(-body)] -> user reason]} {
                        if {$user eq $::client::nick} {
                            send -user $a(-from) "I will not ban myself!!"
                        } else {
                            if {[string length $reason] < 1} {
                                set reason "ban set by $a(-from)"
                            }
                            #xmit "CHANSERV AKICK $::client::channel ADD ${user}!*@* :${reason}"
                            xmit "MODE $::client::channel +b ${user}!*@*"
                            send -user $a(-from) "Banning $user."
                        }
                    } else {
                        send -user $a(-from) "usage: BAN nick ?reason?"
                    }
                }
                "UNBAN*" - "unban*" {
                    log::log notice "$a(-from) $a(-body)"
                    if {[regexp {(?:\S+)\s+(\S+)} [string trim $a(-body)] -> user]} {
                        if {$user eq $::client::nick} {
                            send -user $a(-from) "Kick, ban and unban cannot be used on myself."
                        } else {
                            #xmit "CHANSERV AKICK $::client::channel DEL ${user}!*@*"
                            xmit "MODE $::client::channel -b ${user}!*@*"
                            send -user $a(-from) "Removed ban for $user."
                        }
                    } else {
                        send -user $a(-from) "usage: UNBAN nick"
                    }
                }
                STATS - stats - STATISTICS - statistics {
                    # This is not done as a bot command as it floods irc
                    # too much and gets the bot kicked by freenode.
                    variable stats
                    set m [format {%- 30s %- 18s % 8s% 10s} \
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027






1028
1029
1030
1031
1032
1033
1034
        # End of NAMES list
        # Copy the new user list to the main list.
        variable users_tmp
        if {[info exists users_tmp]} {
            set ::ijbridge::IrcUserList $users_tmp
            unset users_tmp
        }
        # Ask Chanserv to op us.
        cmd-send "PRIVMSG Chanserv :op $::client::channel $::client::nick"
    }

    $cn registerevent 376 {
        # RPL_ENDOFMOTD
        variable ::ijbridge::Options
        if {[catch {
            if {[string length $Options(IrcNickPasswd)] > 0} {
                cmd-send "PRIVMSG nickserv :IDENTIFY $Options(IrcNickPasswd)"
            }
        } err]} { puts stderr $err }
    }






   
    # WHOIS handling from Jabber user 
    $cn registerevent 311 {set ::client::whois(realname) [msg];set ::client::whois(address) [additional]}
    $cn registerevent 312 {set ::client::whois(url) [msg]}
    $cn registerevent 319 {set ::client::whois(channels) [msg]}
    $cn registerevent 320 {set ::client::whois(status) [msg]}
    $cn registerevent 302 {set ::client::whois(host) [msg]}







<
<











>
>
>
>
>
>







1053
1054
1055
1056
1057
1058
1059


1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
        # End of NAMES list
        # Copy the new user list to the main list.
        variable users_tmp
        if {[info exists users_tmp]} {
            set ::ijbridge::IrcUserList $users_tmp
            unset users_tmp
        }


    }

    $cn registerevent 376 {
        # RPL_ENDOFMOTD
        variable ::ijbridge::Options
        if {[catch {
            if {[string length $Options(IrcNickPasswd)] > 0} {
                cmd-send "PRIVMSG nickserv :IDENTIFY $Options(IrcNickPasswd)"
            }
        } err]} { puts stderr $err }
    }

    $cn registerevent 333 {
        # topicinfo - a handy marker for 'we just joined a channel'
        # Ask Chanserv to op us.
        cmd-send "PRIVMSG Chanserv :op $::client::channel $::client::nick"
    } 
   
    # WHOIS handling from Jabber user 
    $cn registerevent 311 {set ::client::whois(realname) [msg];set ::client::whois(address) [additional]}
    $cn registerevent 312 {set ::client::whois(url) [msg]}
    $cn registerevent 319 {set ::client::whois(channels) [msg]}
    $cn registerevent 320 {set ::client::whois(status) [msg]}
    $cn registerevent 302 {set ::client::whois(host) [msg]}