File: rejoin

package info (click to toggle)
epic5 2.0.1-1
  • links: PTS
  • area: main
  • in suites: buster, sid, stretch
  • size: 4,696 kB
  • ctags: 6,357
  • sloc: ansic: 69,814; makefile: 715; ruby: 227; sh: 178; perl: 13
file content (129 lines) | stat: -rw-r--r-- 2,652 bytes parent folder | download | duplicates (2)
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
if (word(2 $loadinfo()) != [pf]) { load -pf $word(1 $loadinfo()); return; };

# REJOIN: saves channels and keys FOR YOU!
#
# Saves channels and keys on:
#	 KICK
#  PART
#  DISCONNECT
#
# Does NOT save channels/keys on quit.
#
# /REJOIN with no arguments: rejoins for current window
#  -SERVER    or 
#  -AS              for all windows on current server
#  -A[LL]           for all windows
#  -F[LUSH]         flush all windows
#  -R[EMOVE] [<w>]  remove for current window or <w>.
#  -L[IST]          list recordings
#
# REJOIN is NOT server sensitive.
#
# SECURITY HAZZARD: will rejoin with saved key across
#   servers.
#
# I hope you like it! -howl
#

package REJOIN;
alias rejoin {rejoin.rejoin $*;};
alias rejoin.rejoin
{
	@ :pm = aliasctl(assign pmatch .rejoin.*);
	switch ($0)
	{
		(-f*)
		{
			fe :pm re { ^assign -$re; push :fl $after(2 . $re);};
			xecho -b Flushed rejoin for windows: $fl;
			return;
		}
		(-r*)
		{
			if ([$1] == '')
			{
				rejoin.rejoin -remove $winnum();
				return;
			};
			fe ($aliasctl(assign pmatch .rejoin.$1)) pm
			{
				^assign -$pm;
				xecho -b Removed rejoin for window: $after(2 . $pm);
			};
			return;
		}
		(-l*)
		{
			fe :pm re { xecho -b Window $after(2 . $re), rejoin:
				$.rejoin[$after(2 . $re)];};
			return;
		}
		(-as*) (-s*)
		{
			@ :sn = serverctl(from_server);
			fe :pm re 
			{
				if (windowctl(get $after(2 . $re) server) == sn) 
					{push :list $after(2 . $re);};
			};
		}
		(-a*) { fe :pm re { push :list $after(2 . $re); }; }
		(-*) {xecho -b Unknown argument: $*; return;}
		() { @ :list = winnum();}
		(*){ fe ($*) wi {push :list $windowctl(refnum $wi);};}
	};
	@ :list = remw(-1 $uniq($list));
	if (!@list)
	{
		xecho -b No rejoins specified
		return;
	};
	fe list win
	{
		if (!@.rejoin[$win]) {xecho -b No rejoins for $win; continue;};
		fe ($.rejoin[$win]) ch ke
		{
			xeval -window $win
			{
				if (chanwin($ch $windowctl(get $win server)) == -1)
				{window $win channel "$ch $ke";};
			};
		};
	};
};

fe (server_status part kick) li {
	fe ($hookctl(list hooks $li)) no {
		if (hookctl(get hook $no package) == 'REJOIN')
		{ @ hookctl(remove $no); }; 
	}; };

^on #-server_status - "% % closing"
{
	xeval -s $0
	{
		fe ($mychannels($0)) ch
		{
			push :wl ${:wi=chanwin($ch)};
			push :w[$wi] $ch $key($ch);
		};
		fe wl win {@ .rejoin[$win] = :w[$win];};
	};
};
on #-part - "*"
{
	if ([$0] == serverctl(get $serverctl(from_server) nickname))
	{
		@ .rejoin[$chanwin($1)] = [$1 $key($1)];
	};
};
on #-kick - "*"
{
	if ([$0] == serverctl(get $serverctl(from_server) nickname))
	{
		@ .rejoin[$chanwin($2)] = [$2 $key($2)];
	};
};

# howl 2010
# vim: tabstop=2 syntax=