10-24-2017, 07:48 +0200
AuthorPost
Mettwurst  08-11-2005, 15:12   | [EGG] How to ping a person via ctcp Homepage
(Moderator)

Avatar

Member since 04/2004
13 Posts
Location: Stuttgart/Germany
German                                                                                                                               
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
namespace eval ::pingCheck:: {
    set [namespace current](V) "0.1"

    bind pub n !ping  [namespace current]::pubPing
    bind ctcr - PING  [namespace current]::ctcrPing


    proc [namespace current]::pubPing {nick host hand chan text} {
        global [namespace current]
        if {[set victim [string tolower [lindex [split $text] 0]]] == ""} {
            set victim [string tolower $nick]
        }
        set [namespace current](replyTo:$victim) $nick
        set [namespace current](TimerID:$victim) [utimer 30 [list [namespace current]::deletePing $victim $nick]]
        putserv "PRIVMSG $victim :\001PING [clock seconds]\001"
        putserv "NOTICE $nick :\273\273 Pingrequest gesendet."
        set [namespace current](Startping:$victim) [clock clicks]
    }

    proc [namespace current]::ctcrPing {nick host hand dest key text} {
        set endTime [clock clicks]
        global [namespace current]
        set startTime [set [namespace current](Startping:[string tolower $nick])]
        if {![info exists [namespace current](Startping:[string tolower $nick])]} {
            putcmdlog "Unbekannte Pingrückgabe von $nick."
            return
        }
        set resultTime [expr {($endTime - $startTime)/1000.0}]ms
        putserv "NOTICE [set [namespace current](replyTo:[string tolower $nick])] :\273\273 Der Ping zu $nick benötigte $resultTime."
        catch {killutimer [set [namespace current](TimerID:[string tolower $nick])]}
        catch {unset [namespace current](Startping:[string tolower $nick])}
        catch {unset [namespace current](replyTo:[string tolower $nick])}
        catch {unset [namespace current](TimerID:[string tolower $nick])}
    }


    proc [namespace current]::deletePing {victim nick} {
        global [namespace current]
        catch {unset [namespace current](Startping:$victim)}
        catch {unset [namespace current](replyTo:$victim)}
        catch {unset [namespace current](TimerID:$victim)}
        putserv "NOTICE $nick :\273\273 $victim hat auch nach 30 Sekunden nicht geantwortet. Pingcheck wird abgebrochen."
    }
};#NAMESPACE END


English:                                                                                                                               
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
namespace eval ::pingCheck:: {
    set [namespace current](V) "0.1"

    bind pub n !ping  [namespace current]::pubPing
    bind ctcr - PING  [namespace current]::ctcrPing


    proc [namespace current]::pubPing {nick host hand chan text} {
        global [namespace current]
        if {[set victim [string tolower [lindex [split $text] 0]]] == ""} {
            set victim [string tolower $nick]
        }
        set [namespace current](replyTo:$victim) $nick
        set [namespace current](TimerID:$victim) [utimer 30 [list [namespace current]::deletePing $victim $nick]]
        putserv "PRIVMSG $victim :\001PING [clock seconds]\001"
        putserv "NOTICE $nick :\273\273 Pingrequest sent."
        set [namespace current](Startping:$victim) [clock clicks]
    }

    proc [namespace current]::ctcrPing {nick host hand dest key text} {
        set endTime [clock clicks]
        global [namespace current]
        set startTime [set [namespace current](Startping:[string tolower $nick])]
        if {![info exists [namespace current](Startping:[string tolower $nick])]} {
            putcmdlog "Unknown pingreply by $nick."
            return
        }
        set resultTime [expr {($endTime - $startTime)/1000.0}]ms
        putserv "NOTICE [set [namespace current](replyTo:[string tolower $nick])] :\273\273 Duration of pingrequest to $nick: $resultTime."
        catch {killutimer [set [namespace current](TimerID:[string tolower $nick])]}
        catch {unset [namespace current](Startping:[string tolower $nick])}
        catch {unset [namespace current](replyTo:[string tolower $nick])}
        catch {unset [namespace current](TimerID:[string tolower $nick])}
    }


    proc [namespace current]::deletePing {victim nick} {
        global [namespace current]
        catch {unset [namespace current](Startping:$victim)}
        catch {unset [namespace current](replyTo:$victim)}
        catch {unset [namespace current](TimerID:$victim)}
        putserv "NOTICE $nick :\273\273 $victim did not answer after 30 seconds. Pingcheck stopped."
    }
};#NAMESPACE END


SYNTAX !ping ?nick?
This post was edited 2 times, last on 08-12-2009, 21:18 by thommey
Advanced options for this topic:

Ignore this topic (Do not list this topic in the "unread topics" search. You are currently not ignoring this topic.)
Hide this topic (Hidden topics are not displayed in the topics list. This topic is currently not hidden.)
Go to forum

Unclassified NewsBoard 1.5.3-d | © 2003-4 by Yves Goergen