Commits

lan Nomar committed ace3f0f

added files plugins/(define forth misc translate).brc

changed ii-plugins.brc
functional
changed plugins/rms.brc
works accordingly

  • Participants
  • Parent commits 89872e6

Comments (0)

Files changed (6)

 	serv = $*($serv)
 }
 
- echo -n loading: 
+nick = moII		# replace me
+
+fn +cmd		{ cmds = ( $cmds $* ) }
+fn +event	{ evts = ( $evts $* ) }
+
+ echo loading: 
   for (* in `{ cat $dir/cmds } ) {
 	echo '	'^$^*
-	{ . /home/nal/Oven/Potatoes/ircfs/plugins/$^*.brc }
+	{ . $HOME/Oven/Potatoes/ircfs/plugins/$^*.brc }
   }
 
 fn say		{ echo $* > $inF }
 fn reply	{ echo $^name: $* > $inF }
+fn msg		{ echo /PRIVMSG $^name :^$^* > $inF }
 
-tail -f -n0 $^dir/out | while (true) { # that true bothers me
+tail -f -n0 $^dir/out |\
+while (true) { # no true
  *=`{ask}
  date = $1
  time = $2
  name = `` '<>' { echo -n $3 }
 	shift 3
  text = $*
- for (* in $cmds) { $* }
-}
-
-
-
-
-
-
+ *=$* { for (* in $evts) { $* } }
+ if ( ~ $1 *^$^nick^* ) {
+  shift ; text = $*
+  for (* in $cmds) { $* }
+ }
+}

plugins/define.brc

+
++cmd define
+
+fn def {
+ ifs=() {
+  w3m -dump definefor.me/^`{ urlencode $* } |\
+	awk '!/wordnik/ && NR>4'
+ }
+}
+
+fn define {
+ if (~ $text(1) [Dd][Ee][Ff]* ) {
+  *=$text ; shift
+  { def $* | awk '{print $0 ; system("sleep 1")}' } > $^inF
+  # | sed '10q'
+ }
+}

plugins/forth.brc

+
++cmd forth fortheval
+
+fn forth {
+ if ( ~ $text(1) [Ff][Tt][Hh] ) {
+  * = $text ; shift
+  ifs=() { reply `{ fth -e $^* } }
+ }
+}
+
+fn fortheval {
+ if ( ~ $text(1) [Ff][Tt][Hh][Ee] ) {
+	* = $text ; shift
+	*=(: t $* ';' t)
+	ifs=() { reply `{ fth -e $^* } }
+ }
+}
+
++cmd ping plugins help
+
+fn ping {
+ if ( ~ $text(1) [Pp]^[Ii]^[Nn]^[Gg] ) {
+  reply Pong
+ }
+}
+
+fn plugins {
+ if ( ~ $text(1) plugins) {
+	reply $cmds $evts
+ }
+}
+
+
+# each command will have a fn which will display a description
+
+fn help {
+ if ( ~ $text(1) [hH] help ayuda) {
+  if ( ~ $#text 1 ) {
+	reply ping plugins define fth fthe translate
+  } else {
+	switch ($text(2)) {
+	 case ping		; reply 'Replies with PONG'
+	 case plugins	; reply 'displays all plugins loaded'
+	 case define	; reply 'defines word(2)'
+	 case fth fthe	; reply 'executes forth command'
+	 case translate ; reply '(en2es 2es) TEXT'
+	}
+  }
+ }
+}
 
-cmds=($cmds rms)
++event rms
 
 fn rms { ~ $text *^[Ll]^[Ii]^[Nn]^[Uu]^[Xx]^* && {
  ~ $text *GNU/Linux* || reply 'es GNU/Linux!' }

plugins/translate.brc

+
++cmd Gtranslate
+
+fn Gtranslate {
+ switch ($text(1)) {
+   case [Tt][Rr]*
+	*=$text ; shift	; *=(/ $*)
+   case 2?? ??2?? ??^'-'^??^2^* *^2^??^'-'^??
+	*=(/ $text)
+ }
+ 
+ if ( ~ $1 / ) { shift
+	* = `` () { gtranslate $* }
+	~ $* /* && * = .^$*
+	# if the message is long and needs to be broken up into pieces
+	# and a piece happens to start with '/', shit will go down
+	say $*
+ }
+}