File: autoop

package info (click to toggle)
ircii 4.4-3
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 4,256 kB
  • ctags: 2,797
  • sloc: ansic: 36,743; sh: 907; makefile: 483; lex: 16
file content (100 lines) | stat: -rw-r--r-- 3,112 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
# AutoOp   by Ian Frechette 12-10-92 
# Written for ircII2.2pre8 and beyond

# initial list of trusted chan ops..
# format is   nickname!username@hostname   wildcards can be used in 
# any of the three fields
# in the following list the first name would autoop anyone with the 
# nickname 'example_nick'
# the second example will autoop anyone with the username
# 'bob' coming from any machine in the .nocolorado.edu domain

eval if (op_list == []) {@ op_list = [example_nick!*@* *!bob@*.nocolorado.edu]}

# People will only be opped on the following channels..  
# wildcards are allowed and thus just * means every channel.  Use
# delchan to remove stuff from the list, addchan to add
eval if (chan_list == []) {@chan_list = [* #example]}

# Show the the people currently in the autoop list
alias showop
{
    @ ao.tmp = 0
    @ ao.name = []
    echo *** AutoOp list.  Addop nick!user@host to add.  Delop <num>  to remove
    echo *** <num> nickname!username@hostname 
    while (ao.name = word($ao.tmp $op_list)) {
        echo *** $[5]ao.tmp $ao.name
        @ao.tmp = ao.tmp + 1
    }
}

# Just like showop but works with channels.
alias showchan
{
    @ ao.tmp = 0
    @ ao.name = []
    echo *** AutoOp chan list.  Addchan #channel add.  Delchan <num>  to remove
    echo *** <num> #channel
    while (ao.name = word($ao.tmp $chan_list)) {
        echo *** $[5]ao.tmp $ao.name
        @ao.tmp = ao.tmp + 1
    }
}

# Given a number.. deletes that person from the autoop list.. 
# use SHOWOP to list.
alias delop {
    if (!rmatch($0. *1* *2* *3* *4* *5* *6* *7* *8* *9* *0*))
        { echo *** Usage: delop <number>;echo *** See showop }
        { @ op_list = notword(${[$0] + 1} $op_list) }
}
    
# Given a number.. deletes that channel from the autoop channel list.. 
# use SHOWCHAN to list.
alias delchan {
    if (!rmatch($0. *1* *2* *3* *4* *5* *6* *7* *8* *9* *0*))
        { echo *** Usage: delchan <number>;echo *** See showchan }
        { @ chan_list = notword(${[$0] + 1} $chan_list) }
}

# Add an autochanop to the list.
alias addop {
    if ([$0])
    { @ op_list = op_list ## [ $0] }
    { echo *** Usage addop nick!username@host;echo *** wildcards are allowed }
}

# Add an autochanop channel to the list.
alias addchan {
    if ([$0])
    { @ chan_list = chan_list ## [ $0] }
    { echo *** Usage addchan #channel;echo *** wildcards are allowed }
}

# the actual ON that does the work
on #-join 666 * {
    if (rmatch($1 $chan_list))
    {
	if (rmatch($0!$userhost() $op_list) && ischanop($N $1))
	    { timer ${10 + rand(10)} if \(!ischanop\($0 $1\)\) \{//mode $1 +o $0 \} }
    }
}

# The perfect complement to the $word() function.  
# $notword(index words)  returns words minus the indexed word. 
# the special handling of nw.sep is to deal with the cases when 
# the index points to the first or last word.
alias notword {
    if ([$0] > 0)
    {
    if (([$0] > 1) && ([$0] < rmatch($~ $1-)))
        { @ nw.sep = [ ] }
        { @ nw.sep = [] }
        
    @ function_return = [$(1-${[$0]-1})] ## [$nw.sep] ## [$(${[$0]+1}-)]
    }
    {
        @ function_return = [$1-]
    }
}