package org.freertr.line; import java.util.ArrayList; import java.util.List; import org.freertr.auth.authLocal; import org.freertr.pipe.pipeSide; import org.freertr.tab.tabGen; import org.freertr.user.userHelp; import org.freertr.user.userScript; import org.freertr.util.bits; import org.freertr.util.cmds; import org.freertr.util.debugger; import org.freertr.util.logger; /** * chat script for lines * * @author matecsaba */ public class lineScript { /** * create instance */ public lineScript() { } /** * name of script */ public String scrName; /** * actions */ protected tabGen actions = new tabGen(); /** * reindex script * * @param beg first number * @param inc increment */ public void reindex(int beg, int inc) { if (beg < 1) { beg = 10; } if (inc < 1) { inc = 10; } for (int i = 0; i < actions.size(); i++) { lineScriptNtry t = actions.get(i); t.seq = (inc * i) + beg; } } /** * get config * * @param beg beginning string * @param filter filter defaults * @return configuration */ public List getCfg(String beg, int filter) { List l = new ArrayList(); for (int i = 0; i < actions.size(); i++) { l.add(beg + actions.get(i).getCfg(filter)); } return l; } /** * do configuration * * @param cmd command to do * @param negate negated command * @return false on success, true on error */ public boolean doCfg(cmds cmd, boolean negate) { lineScriptNtry ntry = new lineScriptNtry(); if (ntry.fromString(cmd)) { return true; } if (negate) { actions.del(ntry); return false; } if (ntry.seq < 1) { ntry.seq = 0; lineScriptNtry old = actions.get(actions.size() - 1); if (old == null) { old = ntry; } ntry.seq = old.seq + 10; } actions.put(ntry); return false; } /** * get help text * * @param l where to write */ public void getHelp(userHelp l) { l.add(null, false, 1, new int[]{2}, "sequence", "set sequence number"); l.add(null, false, 2, new int[]{1}, "", "sequence number"); l.add(null, false, 1, new int[]{2}, "description", "specify description"); l.add(null, false, 2, new int[]{2, -1}, "", "description"); l.add(null, false, 1, new int[]{2}, "tcl", "execute tcl commands"); l.add(null, false, 2, new int[]{2, -1}, "", "tcl command"); l.add(null, false, 1, new int[]{2}, "sleep", "wait some time"); l.add(null, false, 2, new int[]{-1}, "", "ms to wait"); l.add(null, false, 1, new int[]{-1}, "success", "exit with success"); l.add(null, false, 1, new int[]{-1}, "failure", "exit with failure"); l.add(null, false, 1, new int[]{-1}, "disconnect", "disconnect session"); l.add(null, false, 1, new int[]{2}, "onerror", "go to sequence on error"); l.add(null, false, 2, new int[]{-1}, "", "ms to wait"); l.add(null, false, 1, new int[]{2}, "goto", "go to sequence"); l.add(null, false, 2, new int[]{-1}, "", "ms to wait"); l.add(null, false, 1, new int[]{2}, "send", "send text to line"); l.add(null, false, 2, new int[]{2, -1}, "", "text to send"); l.add(null, false, 1, new int[]{2}, "password", "send text to line"); l.add(null, false, 2, new int[]{2, -1}, "", "text to send"); l.add(null, false, 1, new int[]{2}, "recv", "wait for text to arrive"); l.add(null, false, 2, new int[]{3}, "