INIT=0 CONFIG=".krylon_config"; #[ -f $CONFIG ] && rm $CONFIG [ -f $CONFIG ] && INIT=1 MEMORY="" kset() { if [[ -z $1 ]] || [[ -z $2 ]]; then echo "error: no variable or value to kset()"; exit; fi echo "$1 = $2" >> $CONFIG } kwrite() { if [[ -z $1 ]]; then echo "error: no value to kwrite()"; exit; fi echo "$1" >> $CONFIG } kblank() { echo "" >> $CONFIG } kprompt() { if [[ -z $1 ]] || [[ -z $2 ]] || [[ -z $3 ]] || [[ -z $4 ]] || [[ -z $5 ]] || [[ -z $6 ]]; then echo "error: no variable, prompt, help, enforcement, type or memory passed to kprompt()"; exit; fi local INIVAR=$1; local PROMPT=$2; local HALPLZ=$3; local ENFORCE=$4; local TYPE=$5; local MEMORIZE=$6; unset REPLY; while [[ -z "${REPLY}" ]] || [[ $ENFORCE -eq 1 ]]; do echo -en "$HALPLZ\n$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n "[y/n]: " read; if [[ $ENFORCE -eq 1 ]] && [[ $TYPE -eq 0 ]]; then while ! [[ -z $ENFORCE ]]; do if ([ ${REPLY} == "y" ] || [ ${REPLY} == "Y" ]); then return 0 elif ([ ${REPLY} == "n" ] || [ ${REPLY} == "N" ]); then return 9 else echo -n "$HALPLZ\n$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n "[y/n]: " read; fi; done; elif [[ $TYPE -eq 1 ]]; then while true; do [[ ${REPLY} =~ ^-?[0-9]+$ ]] if ! [ $? -eq 0 ]; then echo -n "$HALPLZ\n$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n "[y/n]: " read; else return ${REPLY} fi done; fi; done; if [ $MEMORIZE -eq 1 ]; then MEMORY=${REPLY} fi; [ $TYPE -eq 1 ] && return ${REPLY} || kset "$INIVAR" "${REPLY}" return 0; } if [ $INIT -eq 0 ]; then kwrite "[bot]" kprompt "nick" "bot ircnick" "bot's nickname to use on the network. e.g. here!*@*" 0 0 1 BOTNICK=$(python -c "import random; print(''.join(random.sample('$MEMORY',len('$MEMORY'))))"); kprompt "username" "bot username" "bot's username to use on the network. e.g. *!here@*" 0 0 1 USERNAME=$(python -c "import random; print(''.join(random.sample('$MEMORY',len('$MEMORY'))))"); kprompt "realname" "bot realname" "bot's realname that shows if someone. /whois bot." 0 0 0 kprompt "host" "irc address" "the ip/hostname of the irc server this bot will connect to." 0 0 0 kprompt "port" "irc port" "the port number of the irc server this bot will connect to." 0 0 0 kprompt "channel" "irc channel" "the channel the bot(s) will join upon connection." 0 0 1 CHANNEL=$MEMORY; kwrite "version=1" kprompt "ssl" "use ssl?" "is the connect to this irc server using secure socket layers?" 1 0 0 [ $? -eq 0 ] && (kset "ssl" "true"; kset "ssl_verify" "cert_none") || (kset "ssl" "false") kprompt "bots" "how many helper bots?[0-255]" "how many bots will connect to the ircserver?" 0 1 0 BOTCOUNT=$?; kblank kwrite "includes =" kwrite " irc3.plugins.command" kwrite " irc3.plugins.asynchronious" kwrite " irc3.plugins.storage" kwrite " irc3.plugins.uptime" kwrite " irc3.plugins.ctcp" kwrite " irc3.plugins.cron" kwrite " irc3.plugins.logger" kwrite " irc3.plugins.userlist" kwrite " plugins.b33p" kwrite " plugins.krylon" kblank kwrite "flood_burst = 0" kwrite "flood_rate = 1" kwrite "flood_rate_delay = 1" kwrite "storage = json://.krylon_database" kblank kwrite "[irc3.plugins.command]" kwrite "cmd = ?" kwrite "guard = irc3.plugins.command.mask_based_policy" kblank kwrite "[irc3.plugins.command.masks]" kwrite "d"'!'"*dr1p@* = all_permissions" kwrite "* = view" kblank kwrite "ignore_list =" kwrite " g1mp_"'!'"*@*" kwrite " g1mp"'!'"*@*" kwrite " ken_"'!'"*@*" kwrite " ken"'!'"*@*" kblank for i in $(seq 1 $BOTCOUNT); do kwrite "[bot_$i]" RANDOM=$((1 + $RANDOM % 255)) SALT=$(printf '%x\n' $RANDOM) THIS=$SALT"_krylon_$(printf '%x\n' $i)" THAT=$(python -c "import random; print(''.join(random.sample('$THIS',len('$THIS'))))"); kwrite "nick = $THAT" RANDOM=$((1 + $RANDOM % 255)) SALT=$(printf '%x\n' $RANDOM) THIS=$SALT"$USERNAME" THAT=$(python -c "import random; print(''.join(random.sample('$THIS',len('$THIS'))))"); kwrite "username = $THAT" kwrite "channel = $CHANNEL" kblank done; fi; echo -e "\n-\n" [ -f $CONFIG ] && cat $CONFIG echo -e "\n-\nEXECUTING" irc3 $CONFIG exit