run.sh 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. INIT=0
  2. CONFIG=".krylon_config"; #[ -f $CONFIG ] && rm $CONFIG
  3. [ -f $CONFIG ] && INIT=1
  4. MEMORY=""
  5. kset() {
  6. if [[ -z $1 ]] || [[ -z $2 ]]; then echo "error: no variable or value to kset()"; exit; fi
  7. echo "$1 = $2" >> $CONFIG
  8. }
  9. kwrite() {
  10. if [[ -z $1 ]]; then echo "error: no value to kwrite()"; exit; fi
  11. echo "$1" >> $CONFIG
  12. }
  13. kblank() {
  14. echo "" >> $CONFIG
  15. }
  16. kprompt() {
  17. 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
  18. local INIVAR=$1; local PROMPT=$2; local HALPLZ=$3; local ENFORCE=$4; local TYPE=$5; local MEMORIZE=$6; unset REPLY;
  19. while [[ -z "${REPLY}" ]] || [[ $ENFORCE -eq 1 ]]; do
  20. echo -en "$HALPLZ\n$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n "[y/n]: "
  21. read;
  22. if [[ $ENFORCE -eq 1 ]] && [[ $TYPE -eq 0 ]]; then
  23. while ! [[ -z $ENFORCE ]]; do
  24. if ([ ${REPLY} == "y" ] || [ ${REPLY} == "Y" ]); then
  25. return 0
  26. elif ([ ${REPLY} == "n" ] || [ ${REPLY} == "N" ]); then
  27. return 9
  28. else
  29. echo -n "$HALPLZ\n$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n "[y/n]: "
  30. read;
  31. fi;
  32. done;
  33. elif [[ $TYPE -eq 1 ]]; then
  34. while true; do
  35. [[ ${REPLY} =~ ^-?[0-9]+$ ]]
  36. if ! [ $? -eq 0 ]; then
  37. echo -n "$HALPLZ\n$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n "[y/n]: "
  38. read;
  39. else
  40. return ${REPLY}
  41. fi
  42. done;
  43. fi;
  44. done;
  45. if [ $MEMORIZE -eq 1 ]; then
  46. MEMORY=${REPLY}
  47. fi;
  48. [ $TYPE -eq 1 ] && return ${REPLY} || kset "$INIVAR" "${REPLY}"
  49. return 0;
  50. }
  51. if [ $INIT -eq 0 ]; then
  52. kwrite "[bot]"
  53. kprompt "nick" "bot ircnick" "bot's nickname to use on the network. e.g. here!*@*" 0 0 1
  54. BOTNICK=$(python -c "import random; print(''.join(random.sample('$MEMORY',len('$MEMORY'))))");
  55. kprompt "username" "bot username" "bot's username to use on the network. e.g. *!here@*" 0 0 1
  56. USERNAME=$(python -c "import random; print(''.join(random.sample('$MEMORY',len('$MEMORY'))))");
  57. kprompt "realname" "bot realname" "bot's realname that shows if someone. /whois bot." 0 0 0
  58. kprompt "host" "irc address" "the ip/hostname of the irc server this bot will connect to." 0 0 0
  59. kprompt "port" "irc port" "the port number of the irc server this bot will connect to." 0 0 0
  60. kprompt "channel" "irc channel" "the channel the bot(s) will join upon connection." 0 0 1
  61. CHANNEL=$MEMORY;
  62. kwrite "version=1"
  63. kprompt "ssl" "use ssl?" "is the connect to this irc server using secure socket layers?" 1 0 0
  64. [ $? -eq 0 ] && (kset "ssl" "true"; kset "ssl_verify" "cert_none") || (kset "ssl" "false")
  65. kprompt "bots" "how many helper bots?[0-255]" "how many bots will connect to the ircserver?" 0 1 0
  66. BOTCOUNT=$?;
  67. kblank
  68. kwrite "includes ="
  69. kwrite " irc3.plugins.command"
  70. kwrite " irc3.plugins.asynchronious"
  71. kwrite " irc3.plugins.storage"
  72. kwrite " irc3.plugins.uptime"
  73. kwrite " irc3.plugins.ctcp"
  74. kwrite " irc3.plugins.cron"
  75. kwrite " irc3.plugins.logger"
  76. kwrite " irc3.plugins.userlist"
  77. kwrite " plugins.b33p"
  78. kwrite " plugins.krylon"
  79. kblank
  80. kwrite "flood_burst = 0"
  81. kwrite "flood_rate = 1"
  82. kwrite "flood_rate_delay = 1"
  83. kwrite "storage = json://.krylon_database"
  84. kblank
  85. kwrite "[irc3.plugins.command]"
  86. kwrite "cmd = ?"
  87. kwrite "guard = irc3.plugins.command.mask_based_policy"
  88. kblank
  89. kwrite "[irc3.plugins.command.masks]"
  90. kwrite "d"'!'"*dr1p@* = all_permissions"
  91. kwrite "* = view"
  92. kblank
  93. kwrite "ignore_list ="
  94. kwrite " g1mp_"'!'"*@*"
  95. kwrite " g1mp"'!'"*@*"
  96. kwrite " ken_"'!'"*@*"
  97. kwrite " ken"'!'"*@*"
  98. kblank
  99. for i in $(seq 1 $BOTCOUNT); do
  100. kwrite "[bot_$i]"
  101. RANDOM=$((1 + $RANDOM % 255))
  102. SALT=$(printf '%x\n' $RANDOM)
  103. THIS=$SALT"_krylon_$(printf '%x\n' $i)"
  104. THAT=$(python -c "import random; print(''.join(random.sample('$THIS',len('$THIS'))))");
  105. kwrite "nick = $THAT"
  106. RANDOM=$((1 + $RANDOM % 255))
  107. SALT=$(printf '%x\n' $RANDOM)
  108. THIS=$SALT"$USERNAME"
  109. THAT=$(python -c "import random; print(''.join(random.sample('$THIS',len('$THIS'))))");
  110. kwrite "username = $THAT"
  111. kwrite "channel = $CHANNEL"
  112. kblank
  113. done;
  114. fi;
  115. echo -e "\n-\n"
  116. [ -f $CONFIG ] && cat $CONFIG
  117. echo -e "\n-\nEXECUTING"
  118. irc3 $CONFIG
  119. exit