Guest User

OpBot, un bot IRC en Bash

a guest
Sep 13th, 2011
144
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. if test "$1" == ""
  4. then
  5.   CHAN=#OpBot
  6. else
  7.   CHAN=\#$1
  8. fi
  9. echo "Canal à joindre : $CHAN"
  10.  
  11. exec 3<>/dev/tcp/irc.example.net/6667
  12. echo -e "NICK OpBot" >&3
  13. echo -e "USER OpBot 8 * : Auto-Op Bot" >&3
  14. echo -e "JOIN $CHAN" >&3
  15. echo -e "PRIVMSG $CHAN :Hello world" >&3
  16. sleep 1
  17.  
  18. while read ligne <&3
  19. do
  20.   join=`echo $ligne | grep "JOIN :$CHAN"`
  21.   if test "$join" != ""
  22.   then
  23.     username=`echo $join | cut -d "!" -f 1`
  24.     username=`echo $username | cut -d ":" -f 2`
  25.     echo "JOIN $username -> op"
  26.     echo -e "PRIVMSG $CHAN :Bienvenue $username" >&3
  27.     echo -e "MODE $CHAN +o $username" >&3
  28.   fi
  29.   ping=`echo $ligne | grep PING`
  30.   if test "$ping" != ""
  31.   then
  32.     echo -n `date`
  33.     echo " - $ping"
  34.     pong=`echo $ligne | cut -d " " -f 2`
  35.     echo -e "PONG $pong" >&3
  36.   fi
  37.   deop=`echo $ligne | grep "MODE $CHAN -o OpBot"`
  38.   if test "$deop" != ""
  39.   then
  40.     echo -e "PRIVMSG $CHAN :Attention, je ne pourrai plus opérer tant que je ne serai pas op." >&3
  41.   fi
  42. done
RAW Paste Data