-
Notifications
You must be signed in to change notification settings - Fork 11
/
users.tcl
executable file
·130 lines (106 loc) · 3.9 KB
/
users.tcl
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
130
#
# MPOS eggdrop users
#
# Copyright: 2014, iAmShorty
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
######################################################################
########## nothing to edit below this line ##########
########## use config.tcl for setting options ##########
######################################################################
#
# check if user is already in userfile
#
proc check_mpos_user {username hostmask} {
global debug sqlite_userfile
sqlite3 registeredusers $sqlite_userfile
if {$debug eq "1"} { putlog "running proc [dict get [info frame 0] proc]" }
set registereduser [string tolower $username]
set registeredhostmask [string tolower $hostmask]
if {[llength [registeredusers eval {SELECT ircnick,hostmask FROM users WHERE hostmask=$registeredhostmask}]] == 0} {
set userhasrights "false"
if {$debug eq "1"} { putlog "user not in database" }
} else {
set userhasrights "true"
if {$debug eq "1"} { putlog "user in database" }
}
registeredusers close
return $userhasrights
}
#
# add user to userfile
#
proc user_add {nick uhost hand chan arg} {
global debug sqlite_userfile
sqlite3 registeredusers $sqlite_userfile
if {$debug eq "1"} { putlog "running proc [dict get [info frame 0] proc]" }
if {[check_userrights $nick] eq "false"} {
if {$debug eq "1"} { putlog "$nick tried to add $arg to userfile" }
return
}
if {$arg eq ""} {
if {$debug eq "1"} { putlog "no user to add" }
return
}
set arg [string trim [charfilter $arg]]
set hostmask "$arg!*[getchanhost $arg $chan]"
if {$debug eq "1"} { putlog "Hostmask is: [string tolower $hostmask]"}
if {[llength [registeredusers eval {SELECT ircnick,hostmask FROM users WHERE hostmask=$hostmask}]] == 0} {
if {$debug eq "1"} { putlog "adding user" }
putquick "PRIVMSG $nick :user $arg added"
registeredusers eval {INSERT INTO users (ircnick,hostmask) VALUES ($arg,$hostmask)}
} else {
if {$debug eq "1"} { putlog "updating user" }
putquick "PRIVMSG $nick :user $arg updated"
registeredusers eval {UPDATE users SET hostmask=$hostmask WHERE ircnick=$arg}
}
registeredusers close
}
#
# delete user from userfile
#
proc user_del {nick uhost hand chan arg} {
global debug sqlite_userfile
sqlite3 registeredusers $sqlite_userfile
if {$debug eq "1"} { putlog "running proc [dict get [info frame 0] proc]" }
if {[check_userrights $nick] eq "false"} {
if {$debug eq "1"} { putlog "$nick tried to delete $arg from users" }
return
}
set arg [string trim [charfilter $arg]]
set hostmask "$arg!*[getchanhost $arg $chan]"
if {[llength [registeredusers eval {SELECT hostmask FROM users WHERE ircnick=$arg}]] == 0} {
puthelp "PRIVMSG $chan :\002$arg\002 is not in the database."
} {
registeredusers eval {DELETE FROM users WHERE ircnick=$arg}
puthelp "PRIVMSG $chan :\002$arg\002 deleted."
}
registeredusers close
}
#
# request from users to add them to userfiles
#
proc user_request {nick uhost hand chan arg} {
global debug scriptpath registereduserfile notificationadmins
if {$debug eq "1"} { putlog "running proc [dict get [info frame 0] proc]" }
if {$arg eq ""} {
if {$debug eq "1"} { putlog "no user to add" }
return
}
foreach admins $notificationadmins {
putquick "NOTICE $admins :$nick requested adding user $arg to userfile"
}
putquick "NOTICE $nick: your request will be processed shortly, please be patient"
}
putlog "===>> Mining-Pool-Users - Version $scriptversion loaded"