-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NET_BGERROR_SERVEUR.tcl
executable file
·108 lines (98 loc) · 3.84 KB
/
NET_BGERROR_SERVEUR.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
###############################################################################################
#
# Name :
# NET_BGERROR_CLIENT.tcl
#
# Description :
# Send BGERROR (TCL) errors to an Eggdrops master
# Do you have a botnet of several Eggdrops?
# You want to centralize the errors of these towards a single Eggdrops, on a show?
# This script does exactly that.
#
# Envois les erreurs BGERROR (TCL) vers un master Eggdrops
# Vous avez un botnet de plusieurs Eggdrops ?
# Vous désirez centraliser les erreurs de ceux-ci vers un seul Eggdrops, sur un salon ?
# Ce script fait exactement çà.
#
# Donation :
# https://github.com/ZarTek-Creole/DONATE
#
# Auteur :
# ZarTek @ https://github.com/ZarTek-Creole
#
# Website :
# https://github.com/ZarTek-Creole/TCL_NET_BGERROR
#
# Support :
# https://github.com/ZarTek-Creole/TCL_NET_BGERROR/issues
#
# Docs :
# https://github.com/ZarTek-Creole/TCL_NET_BGERROR/wiki
#
# Thanks to :
# All donators, testers, repporters & contributors
#
###############################################################################################
# Variables de configuration pour le serveur de NET_BGERROR
# Configuration variables for NET_BGERROR server
namespace eval ::NET_BGERROR_SERVER {
set PATH_SCRIPT "[file dirname [file normalize [info script]]]/NET_BGERROR.conf"
if { [ catch {
source ${PATH_SCRIPT}
} err ] } {
putlog "[namespace current] > Error: Chargement du fichier '${PATH_SCRIPT}' > $err"
return -code error $err
}
set List_Var_Conf [list \
"debug" \
"channel" \
"botName" \
"cryptKey" \
"cryptType" \
"message_prefix" \
"message_delimiter" \
];
foreach varName [split ${List_Var_Conf}] {
if { ![info exists [namespace current]::${varName}] } {
putlog "[namespace current] > Error: La configuration ${varName} est manquante dans ${PATH_SCRIPT}"
exit
}
}
}
# Procedure to handle messages received from clients
proc ::NET_BGERROR_SERVER::handle_message { frombot fromcmd encrypted_message } {
set channel ${::NET_BGERROR_SERVER::channel}
set debug ${::NET_BGERROR_SERVER::debug}
set cryptKey ${::NET_BGERROR_SERVER::cryptKey}
set cryptType ${::NET_BGERROR_SERVER::cryptType}
set message_prefix ${::NET_BGERROR_SERVER::message_prefix}
set message_delimiter ${::NET_BGERROR_SERVER::message_delimiter}
# Check if the channel is valid
if { ![validchan ${channel}] } {
# If the channel is invalid, log an error message if the debug flag is set
if { ${debug} != 0 } {
putlog "[namespace current] > The channel '${channel}' is invalid. Cannot send messages to it."
}
return
}
# Get the encryption key to use, defaulting to "UNSHADOW" if it is not set
if {$cryptKey == ""} {
set cryptKey "UNSHADOW"
}
# Get the encryption type to use, defaulting to "cbc" if it is not set
set cryptType [expr { ${cryptType} in {"ecb" "cbc"} ? ${cryptType} : "cbc" }]
# Decrypt the message
set decrypted_message [decrypt ${cryptType}:${cryptKey} ${encrypted_message}]
if {[string length $decrypted_message] == 0} {
putlog "::NET_BGERROR_SERVER > Invalid encryption key. Could not decrypt message."
return
}
# Split the decrypted message into separate lines
foreach message_line [split $decrypted_message "\n"] {
# Send the message to the channel
putnow "PRIVMSG ${channel} :${message_prefix}${message_delimiter}${frombot}${message_delimiter}${message_line}"
}
}
# Bind the message handler to the bot
bind bot - NET_BGERROR ::NET_BGERROR_SERVER::handle_message
putlog "::NET_BGERROR_SERVER is loaded."