Advertisement
Guest User

AyyAyy Bot

a guest
Aug 29th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.54 KB | None | 0 0
  1. #
  2. # AyyAyyBot
  3. # An ii IRC bot written in bash
  4. #
  5. trap quit SIGINT
  6.  
  7. workingDir="~/Documents/AyyAyyBot/"
  8. networks=$(cat $workingDir/networks.txt)
  9. introduction="[AyyAyy] A bash bot wrapper for ii."
  10.  
  11. startAyyAyyBot()
  12. {
  13.   echo "== Starting AyyAyyBot =="
  14.   cd $workingDir
  15.   echo "[AyyAyy] Loading support for the following networks:"
  16.   echo "$networks"
  17.   echo "[AyyAyy] Starting ii and connecting to networks..."
  18.   for i in $networks;
  19.   do
  20.     echo "[AyyAyy] Joining: $i"
  21.     screen -dmS AyyAyy-$i ii -n AyyAyyBot -i $workingDir -s $networks
  22.     echo "[AyyAyy] Joined $i"
  23.   done
  24.   echo "[AyyAyy] ii launched and connected!"
  25.   echo "[AyyAyy] Executing autostart commands and joining channels..."
  26.  
  27.   for i in $networks;
  28.   do
  29.     grep -v '^#' ayyAutostart-$i >> $i/in # Run autostart commands.
  30.     for c in $(cat chans-$i.txt); # Autojoin channels listed in chans-network.txt
  31.     do
  32.       echo "[AyyAyy] Joining $c on $i."
  33.       echo "/join $c" >> $i/in
  34.       echo $introduction >> $i/$c/in
  35.     done
  36.   done
  37. }
  38.  
  39. bots()
  40. {
  41.   for i in $networks;
  42.   do
  43.     for c in $(cat chans-$i.txt); # Fetch channels.
  44.     do
  45.       if tail -n 1 $i/$c/out | grep ".bots"; then
  46.       echo "Reporting in! [Bash] AyyAyy is a bot wrapper for ii." >> $i/$c/in
  47.       fi
  48.     done
  49.   done
  50. }
  51.  
  52. about()
  53. {
  54.   for i in $networks;
  55.   do
  56.     for c in $(cat chans-$i.txt); # Fetch channels.
  57.     do
  58.       if tail -n 1 $i/$c/out | grep "&ayy about"; then
  59.       echo "[AyyAyy] AyyAyy is a wrapper for ii written in bash. v0.01" >> $i/$c/in
  60.       fi
  61.     done
  62.   done
  63. }
  64.  
  65. help()
  66. {
  67.   for i in $networks;
  68.   do
  69.     for c in $(cat chans-$i.txt); # Fetch channels.
  70.     do
  71.       if tail -n 1 $i/$c/out | grep "&ayy help"; then
  72.       echo "[AyyAyy] Preface commands with &ayy" >> $i/$c/in
  73.       echo "[AyyAyy] &ayy version: Prints about and version information." >> $i/$c/in
  74.       fi
  75.     done
  76.   done
  77. }
  78.  
  79. auth() # Auth botmods.
  80. {
  81.   for i in $networks;
  82.   do
  83.     if tail -n 1 $i/$c/out | grep "&ayy auth"; then
  84.       echo "[AyyAyy] Usage: &ayy auth {status | auth | deauth}"  >> $i/$c/in
  85.       echo "[AyyAyy] ^^ This command doesn't work yet. ^^" >> $i/$c/in
  86.     fi
  87.   done
  88. }
  89.  
  90. # iiStatus()
  91. # {
  92. #   pgrep ii || echo "[AyyAyy] ii died!"
  93. # }
  94.  
  95. tick()
  96. {
  97.   # iiStatus >> /dev/null
  98.   # Channel Commands
  99.   bots  # Respond to .bots
  100.   help # Prints help information.
  101.   about # Prints about information.
  102.  
  103.   # PM Commands
  104.   # auth -- Disabled for now.
  105. }
  106.  
  107. quit()
  108. {
  109.   echo "[AyyAyy] Shutting Down..."
  110.   killall ii
  111.   exit
  112. }
  113.  
  114. startAyyAyyBot
  115. while true; do tick; done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement