Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.06 KB | None | 0 0
  1. #!/bin/bash
  2. Version="3.5"
  3. Author="Dis"
  4. Name="Konversation User Notes Script"
  5. #note: $1=Server, $2=Channel, $3=File, $4=t/c/tc/n/d, $5=Nick,
  6. #note: t=No Date/Time, c=check, d=delete last nick opened
  7. #feature: /nn n Nick on PM's or No Nick Selected; Done.
  8. #feature: /nn l; list what's in LN Done.
  9. #feature: /nn v/vs; version/version show in IRC; Done.
  10. # /nn nc Manually check if Note Exist.
  11. #/nn nd broken.
  12. #emoticon script.
  13.  
  14. File=$3 #this is so, b/c positional parameters are very hard to change
  15. BB= #Turns Text Bold in IRC #0x02 = Bold
  16.  
  17. if [[ "$4" == *v* ]]; then
  18.     if [ "$4" == "vs"  ]; then
  19.         qdbus org.kde.konversation /irc say $1 "$2" "/me is using $BB $Name $BB By: $BB $Author $BB v:$Version"
  20.     else   
  21.         qdbus org.kde.konversation /irc info "Is $BB $Name $BB By: $Author $BB v:$Version"
  22.     fi
  23.     exit;
  24. fi
  25.  
  26. LN=`echo ${3##*/}` #LN=Last nick; ##=last last part; *=*; /=split char
  27. Dir=`echo ${3%/*}` #Dir = Working Directory; %=first part;
  28.  
  29. if [[ "$4" != *d* ]] && [[ "$4" != *l* ]]; then
  30.     echo "$5$LN" > $Dir/LN; #saves file/nick into current working dir
  31.      
  32.     if [[ "$4" == *n* ]]; then # && [[ "$5" != "" ]]
  33.         File="$Dir/$5$LN"
  34.         LN=`echo ${File##*/}`
  35.         Dir=`echo ${File%/*}`
  36.     fi
  37. elif [[ "$4" == *d* ]] || [[ "$4" == *l* ]]; then
  38.     File=$Dir/`cat $Dir/LN` #File = file/Last Nick Used
  39.     if [[ "$4" == *l* ]]; then
  40.         LN=`echo ${File##*/}`
  41.         Dir=`echo ${File%/*}`
  42.         qdbus org.kde.konversation /irc info "Last Nick: $Dir/$BB $LN $BB"
  43.         exit;
  44.     fi
  45. fi
  46.  
  47. if [ -e $File ]; then
  48.     ex="t" #if exist (ex) then True
  49.     NL='\n'
  50. elif [ ! -e $File ]; then
  51.     ex="f" #if not exist (ex) then False
  52.     CF="$BB Created $BB File: $Dir/$BB $LN"
  53. else
  54.     qdbus org.kde.konversation /irc error "An Unknown Error has Occurred."
  55.     exit;
  56. fi
  57.  
  58. if [[ "$4" == *t*  ]]; then #spaces matter! Just like regular commands!
  59.     UU=`echo $4 | tr '[a-z]' '[A-Z]'`; #lower to upper case
  60.     KonInfo="In Mode: $BB $UU"
  61.    
  62.     if [[ "$4" == *tc* ]]; then
  63.         if [ "$ex" == "f" ]; then
  64.             qdbus org.kde.konversation /irc info "File: $Dir/$BB $LN does not exist"
  65.             exit;
  66.         fi
  67.     fi
  68. else #&&=to make new file, e.g. /nn n dis; || b/c check fails, /nn c
  69.     if [ "$ex" == "t" ] && [[ "$4" == *c* ]]; then
  70.         qdbus org.kde.konversation /irc info "File: $Dir/$BB$LN exist"
  71.         exit;
  72.     elif [ "$ex" == "t" ] || [[ "$4" != *c* ]]; then
  73.         if [[ "$4" != *d* ]]; then
  74.             echo -e $NL`date +"%a, %b %d %r %Y %Z"`'\n' >> $File
  75.         fi
  76.     fi
  77.     if [ "$ex" == "f" ] && [ "$5" == "" ]; then
  78.         if [[ "$4" == *c* ]]; then
  79.             ERR='info'
  80.         else
  81.             ERR="$BB error $BB"
  82.         fi
  83.         qdbus org.kde.konversation /irc $ERR "File: $Dir/$BB $LN does not exist"
  84.         exit;
  85.     fi
  86. fi
  87.  
  88. if [[ "$4" != *d* ]]; then
  89.     if [ "$ex" == "f" ]; then
  90.         qdbus org.kde.konversation /irc info "$CF"
  91.     fi
  92.    
  93.     qdbus org.kde.konversation /irc info "$BB Opened $BB up: $Dir/$BB $LN $BB from $2 $KonInfo";
  94.     gedit $File;
  95.     qdbus org.kde.konversation /irc info "$BB Closed: $BB $Dir/$BB $LN $BB from $2 $KonInfo";
  96. elif [[ "$4" == *d* ]]; then
  97.     rm $File
  98.     qdbus org.kde.konversation /irc info "File $Dir/$BB$LN was deleted."
  99. else
  100.     qdbus org.kde.konversation /irc error "Unknown Command."
  101. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement