File: ctcp

package info (click to toggle)
epic5 3.0.3-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 5,328 kB
  • sloc: ansic: 75,810; makefile: 648; ruby: 227; python: 215; sh: 78; perl: 13
file content (112 lines) | stat: -rw-r--r-- 3,009 bytes parent folder | download
1
2
3
4
5
6
7
8
9
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
if (word(2 $loadinfo()) != 'pf') { load -pf $word(1 $loadinfo()); return; };

#
# Some basic CTCPs, implemented in script!
#

@ctcpctl(SET VERSION REQUEST {ctcp $0 $2 ircII $J - $CLIENT_INFORMATION});
@ctcpctl(SET VERSION DESCRIPTION shows client type, version and environment);

@ctcpctl(SET PING REQUEST {ctcp $0 $2 $3-});
alias do_ping_reply {
	if (!*3 || !*4) {return};

	@ now = utime();
	@ now_seconds = word(0 $now);
	@ now_usec = word(1 $now);
	@ then_seconds = *3;
	@ then_usec = *4;
	@ diff_sec = now_seconds - then_seconds;
	@ diff_usec = now_usec - then_usec;
	if (diff_usec < 0) {
		@diff_usec += 1000000;
		@diff_sec--;
	};
	if (diff_sec < 0) { return };

        ^push set floating_point_math;
	^set floating_point_math on;
	@ act_diff = (diff_sec * 1.0) + (diff_usec / 1000000.0);
        ^pop set floating_point_math;

	return $act_diff seconds;
};
@ctcpctl(SET PING RESPONSE {@retval = do_ping_reply($*);if (retval) {return $retval}});
@ctcpctl(SET PING DESCRIPTION returns the arguments it receives);
@ctcpctl(SET PING REPLACE_ARGS 1);

@ctcpctl(SET ECHO REQUEST {ctcp $0 $2 $3-});
@ctcpctl(SET ECHO DESCRIPTION returns the arguments it receives);

alias do_clientinfo_request {
	if (!*3) { 
		ctcp $0 $2 $ctcpctl(ACTIVE) 
	} else {
		if (ctcpctl(GET $3 ACTIVE)) {
			ctcp $0 $2 $toupper($3) $ctcpctl(GET $3 DESCRIPTION)
		}
	}
};
@ctcpctl(SET CLIENTINFO REQUEST {do_clientinfo_request $*});
@ctcpctl(SET CLIENTINFO DESCRIPTION gives information about available CTCP commands);

@ctcpctl(SET USERINFO REQUEST {ctcp $0 $2 $USER_INFORMATION});
@ctcpctl(SET USERINFO DESCRIPTION returns user settable information);

@ctcpctl(SET ERRMSG REQUEST {ctcp $0 $2 $3-});
@ctcpctl(SET ERRMSG DESCRIPTION returns error messages);

alias do_ctcp_finger_request {
	if (getenv(IRCUSER)) {
		@ user = getenv(IRCUSER)
	} { 
		@ user = before(@ $X)
	};
	@ host = after(@ $X);

	if (getenv(IRCFINGER)) {
		@ gecos = getenv(IRCFINGER)
	} elif (DEFAULT_REALNAME) {
		@ gecos = DEFAULT_REALNAME
	} else {
		@ gecos = 'Esteemed EPIC User'
	};
	@ idle = E;

	ctcp $0 $2 $gecos \($user@$host\) Idle $idle second(s);
};
@ctcpctl(SET FINGER REQUEST {do_ctcp_finger_request $*});
@ctcpctl(SET FINGER DESCRIPTION shows real name, login name and idle time of user);

@ctcpctl(SET TIME REQUEST {ctcp $0 $2 $stime($time())});
@ctcpctl(SET TIME DESCRIPTION tells you the time on the user's host);
 
@ctcpctl(SET UTC REQUEST {return $stime($3-)});
@ctcpctl(SET UTC RESPONSE {return $stime($3-)});
@ctcpctl(SET UTC DESCRIPTION substitutes the local timezone);

# Written just for zlonix. :)
alias ctcp_cloak {
	if (!*0) {
		xecho -b These CTCPs are currently cloaked: $ctcpctl(INACTIVE);
	} else {
		fe ($*) c {
			@ctcpctl(SET $c ACTIVE 0);
		};
		xecho -b These CTCPs have been cloaked: $*;
	};
};

alias ctcp_uncloak {
	if (!*0) {
		xecho -b These CTCPs are currently uncloaked: $ctcpctl(ACTIVE);
	} else {
		fe ($*) c {
			@ctcpctl(SET $0 ACTIVE 1);
		};
		xecho -b These CTCPs have been uncloaked: $*;
	};
};


#hop'2k18