コード例 #1
0
  @OnKeyword("tcfeed")
  public void feedbackform(TeamchatAPI api) {

    Form fo = api.objects().form();

    fo.addField(api.objects().input().name("TicketID").label("TicketID"));

    fo.addField(
        api.objects().select().name("Rating").label("Rating").addOption("good").addOption("bad"));

    fo.addField(api.objects().input().name("rcomment").label("Comment"));

    PrimaryChatlet prime = new PrimaryChatlet();

    api.perform(
        api.context()
            .currentRoom()
            .post(
                prime
                    .setQuestionHtml(
                        "<h3 style=\"color:black\";><b>Give Us Feedback</b></h3>"
                            + "<br />We value your feedback and product suggestions. While we don't respond to suggestions directly, we do review them. If you'd like to give general feedback about Teamchat support, give your feedback here.")
                    .setReplyScreen(fo)
                    .setReplyLabel("Enter")
                    .alias("getdatafeed")));
  }
コード例 #2
0
  @OnKeyword("tcsupport")
  public void support(TeamchatAPI api) {

    zd =
        new Zendesk.Builder("https://teamchat.zendesk.com") // Zendesk account id
            .setUsername("*****@*****.**") // email of zendesk account
            .setPassword("webaroo")
            .build(); // or setToken("0cf1d94606")

    // Setting up Trigger
    // trigger ();

    Form f = api.objects().form();
    f.addField(api.objects().input().label("Subject").name("subject"));
    f.addField(api.objects().input().label("Comment").name("comment"));
    f.addField(api.objects().input().label("Contact No.").name("contact"));

    PrimaryChatlet prime = new PrimaryChatlet();
    prime
        .setQuestionHtml(
            "<img src=\"http://p3.zdassets.com/hc/settings_assets/481529/200038422/Q2xRKEc55HY0Oxq8hxzRaw-teamchatsupportlogo.png\" height=\"90\" width=\"230\">"
                + "<br /><b>Enter your query below:</b>")
        .setReplyScreen(f)
        .setReplyLabel("Enter")
        .setDetailsLabel("Queries")
        .showDetails(true)
        .alias("query");

    api.perform(api.context().currentRoom().post(prime));
  }
コード例 #3
0
ファイル: pingdombot.java プロジェクト: AnujArora94/Teamchat
  @OnKeyword("login")
  public void login(TeamchatAPI api) {

    Form f = api.objects().form();
    f.addField(api.objects().input().label("Username").name("Username"));
    f.addField(api.objects().input().label("Password").name("Password"));
    f.addField(api.objects().input().label("App_key").name("App_key"));

    PrimaryChatlet prime = new PrimaryChatlet();
    prime
        .setQuestionHtml("<h4><b>Enter your login credentials :</b></h4>")
        .setReplyScreen(f)
        .setReplyLabel("Enter")
        .alias("setdata");

    api.perform(api.context().currentRoom().post(prime));
  }
コード例 #4
0
ファイル: pingdombot.java プロジェクト: AnujArora94/Teamchat
  @OnKeyword("addcheck")
  public void addcheck(TeamchatAPI api) throws IOException, SQLException {
    String rmid;
    rmid = api.context().currentRoom().getId();
    DBHandler ob4 = new DBHandler();
    boolean flag;
    flag = ob4.roomchk(rmid);

    if (flag == false) {
      PrimaryChatlet prime = new PrimaryChatlet();
      prime.setQuestionHtml(
          "<br /><b>First you have to sign in!!</b>"
              + "<br /><b>Note: </b><a1  style=\"color:#359FD8\";>For Signing in type \"login\" command</a1>");

      api.perform(api.context().currentRoom().post(prime));
    } else {
      DBHandler ob5 = new DBHandler();
      String[] usrpassapp = ob5.getusrpassapp(rmid);
      Username = usrpassapp[0];
      Password = usrpassapp[1];
      App_key = usrpassapp[2];
      url = "https://api.pingdom.com/api/2.0/checks";
      PrimaryChatlet prime = new PrimaryChatlet();
      Form f = api.objects().form();
      f.addField(api.objects().input().label("Check Name :").name("name"));
      f.addField(api.objects().input().label("Hostname :").name("host"));
      f.addField(
          api.objects()
              .select()
              .name("Protocol")
              .label("Select any protocol :")
              .addOption("http")
              .addOption("https"));

      prime
          .setQuestionHtml("<h5><b>Enter the Check details below:</b></h5>")
          .setReplyScreen(f)
          .setReplyLabel("Enter")
          .alias("sendreqadd");
      api.perform(api.context().currentRoom().post(prime));
    }
  }
コード例 #5
0
 @OnKeyword(value = "Room")
 public void Room(TeamchatAPI api) {
   Form fo = api.objects().form();
   fo.addField(api.objects().input().name("Name").label("Your Name:"));
   fo.addField(api.objects().input().name("roomlink").label("Room Link:"));
   fo.addField(api.objects().input().name("EmailId").label("Recepient's email-Id:"));
   api.perform(
       api.context()
           .currentRoom()
           .post(
               new PrimaryChatlet()
                   .setQuestionHtml(
                       "<center><h4 style=\"color:black\";><b>Click on the button below:-</b></h4></center>"
                           + "<br />"
                           + "<center><a href=\"https://room.co/#/\" target=\"_blank\"><img src=\"https://slack.global.ssl.fastly.net/1e47/plugins/room/assets/service_128.png\" border=\"0\" height=\"64\" width=\"64\" ></a></center>"
                           + "<br />"
                           + "<ul type=\"square\"; style=\"color:#359FD8\";><li><a1 style=\"color:#484848\";><b>It will redirect you to a page, Where you will find a Start video chat button</b></a1></li></ul>"
                           + "<ul type=\"square\"; style=\"color:#359FD8\";><li><a1 style=\"color:#484848\";><b>Clicking on it will redirect you to a page Where you will find a link</b></a1></li></ul>"
                           + "<ul type=\"square\"; style=\"color:#359FD8\";><li><a1 style=\"color:#484848\";><b>Copy that link and paste it in the reply with the Email Id of the person you want to interact with</b></a1></li></ul>")
                   .setReplyScreen(fo)
                   .setReplyLabel("Connect")
                   .alias("adduser")));
 }
コード例 #6
0
  @OnKeyword("help")
  public void Pivotal(TeamchatAPI api) throws IOException {
    api.perform(
        api.context()
            .currentRoom()
            .post(
                new PrimaryChatlet()
                    .setQuestionHtml(
                        "<br/>Hi! This is Pivotal Tracker Bot. I am going to guide you how to use me to do thinks in Tracker.<br/>Type the following commands to:<br/>1)Createproject: To create project<br/>2)Deleteproject: To delete project<br/>3)Createstory: To add story<br/>4)Deletestory: To delete story<br/>5)Notification: To get notifications<br/>6)Logout: To log out<br/>BUT FIRST YOU HAVE TO LOGIN!")));
    email = api.context().currentSender().getEmail();
    if (db.isAuthorized(email)) {
      // get the basic info

      api.perform(
          api.context()
              .currentRoom()
              .post(
                  new PrimaryChatlet()
                      .setQuestionHtml(
                          "Hi, you may proceed to use your <u>Pivotal account</u>. ")));
      // welcome message and continue
    } else {
      // display the button so the user can begin authentication

      api.perform(
          api.context()
              .currentRoom()
              .post(
                  new PrimaryChatlet()
                      .setQuestionHtml(
                          "Follow the instructions given below.We need you to get your access token one time.<br/>Open your Pivotal account.<br/>Click on your username in the top right.<br/>Click on Profile.<br/> Scroll down to API TOKEN. <br/>Copy the api token from the api token field and paste below.<html><body><a target='_blank' href='https://www.pivotaltracker.com/profile'>To Get to your profile click here</a><br/>")));

      Form f = api.objects().form();
      f.addField(api.objects().input().name("token").label("Paste Token here"));
      api.perform(
          api.context()
              .currentRoom()
              .post(
                  new PrimaryChatlet()
                      .setQuestionHtml("Paste your token")
                      .setReplyScreen(f)
                      .setReplyLabel("Enter")
                      .alias("got_token")));
    }
  }
コード例 #7
0
 @OnKeyword("select")
 public static void selectBucket(TeamchatAPI api) {
   JSONArray j = RunscopeFetch.getBuckets();
   name = new String[j.length()];
   key = new String[j.length()];
   for (int i = 0; i < j.length(); i++) {
     JSONObject j1 = j.getJSONObject(i);
     name[i] = j1.getString("name");
     key[i] = j1.getString("key");
   }
   Form f = api.objects().form();
   f.addField(getOptions(api, name));
   api.performPostInCurrentRoom(
       new PrimaryChatlet()
           .setQuestionHtml("Select the bucket for which you want results.")
           .setReplyScreen(f)
           .setReplyLabel("Select")
           .alias("onSelect"));
 }
コード例 #8
0
  @OnAlias("query")
  public void query(TeamchatAPI api) {
    zd =
        new Zendesk.Builder("https://teamchat.zendesk.com") // Zendesk account id
            .setUsername("*****@*****.**") // email of zendesk account
            .setPassword("webaroo")
            .build(); // or setToken("0cf1d94606")

    String sub = api.context().currentReply().getField("subject");
    String com = api.context().currentReply().getField("comment");
    String con = api.context().currentReply().getField("contact");

    // Setting comment
    Comment c = new Comment();
    c.setBody(com);

    // Creating a new ticket, administrator privilege is required
    Ticket ticket = new Ticket();
    ticket.setSubject(sub);
    ticket.setComment(c);

    ticket = zd.createTicket(ticket);
    ticketId = String.valueOf(ticket.getId());
    requesterId = String.valueOf(ticket.getRequesterId());
    String stat = "open";
    String rat = "";
    String Rc = "";

    Form f = api.objects().form();
    f.addField(api.objects().input().label("Comment").name("upCom"));

    PrimaryChatlet prime = new PrimaryChatlet();
    prime
        .setQuestionHtml(
            "<h4><b>Ticket Details:</b></h4>"
                + "<ul type=\"square\"; style=\"color:#359FD8\";><li><a1 style=\"color:black\";><b>Ticket ID- </b></a1><a2 style=\"color:#359FD8\";>"
                + ticketId
                + "</a2></li><li><a3 style=\"color:black\";><b>Requester ID- </b></a3><a4 style=\"color:#359FD8\";>"
                + requesterId
                + "</a4></li><li><a5 style=\"color:black\";><b>Subject - </b></a5><a6 style=\"color:#359FD8\";>"
                + sub
                + "</a6></li><li><a7 style=\"color:black\";><b>Comment - </b></a7><a8 style=\"color:#359FD8\";>"
                + com
                + "</a8></li></ul>")
        .setReplyScreen(f)
        .setReplyLabel("Update")
        .setDetailsLabel("Update")
        .showDetails(true)
        .alias("update");

    api.perform(api.context().currentRoom().post(prime));

    roomId = api.context().currentRoom().getId();
    formId = prime.getFormId();
    comment = com;
    contact = con;
    status = stat;
    rating = rat;
    Rcomment = Rc;

    // System.out.println("TICKET ID"+ticketId);
    //	System.out.println("REQUESTER ID"+requesterId);
    //	System.out.println("FORM ID"+formId);
    //	System.out.println("ROOM ID"+roomId);
    //	System.out.println(status);
    ticketData.setData(
        roomId, formId, ticketId, requesterId, comment, contact, status, rating, Rcomment);

    // Saving ticketid with formid for further replies
    // api.data().addField (formId, "RoomID", roomId);
    // api.data().addField (formId, "FormID", formId);
    // api.data().addField (formId, "TicketID", ticketId);
    // api.data().addField (formId, "RequesterID", requesterId);
  }
コード例 #9
0
ファイル: pingdombot.java プロジェクト: AnujArora94/Teamchat
  @OnKeyword("deletecheck")
  public void deletecheck(TeamchatAPI api) throws IOException, SQLException {
    String rmid;
    count = 1;
    rmid = api.context().currentRoom().getId();
    DBHandler ob4 = new DBHandler();
    boolean flag;
    flag = ob4.roomchk(rmid);

    if (flag == false) {
      PrimaryChatlet prime = new PrimaryChatlet();
      prime.setQuestionHtml(
          "<br /><b>First you have to sign in!!</b>"
              + "<br /><b>Note: </b><a1  style=\"color:#359FD8\";>For Signing in type \"login\" command</a1>");

      api.perform(api.context().currentRoom().post(prime));
    } else {
      DBHandler ob5 = new DBHandler();
      String[] usrpassapp = ob5.getusrpassapp(rmid);
      Username = usrpassapp[0];
      Password = usrpassapp[1];
      App_key = usrpassapp[2];
      url = "https://api.pingdom.com/api/2.0/checks";
      pingdomintegrator ob1 = new pingdomintegrator();
      String resp = ob1.getChecks(Username, Password, App_key, url);

      if (resp.equals("Error")) {
        PrimaryChatlet prime = new PrimaryChatlet();
        api.perform(
            api.context()
                .currentRoom()
                .post(
                    prime.setQuestionHtml(
                        "<br /><b>Error :</b>"
                            + "<br /><b>Status Code: 403</b>"
                            + "<br /><b>StatusDesc: Forbidden</b>"
                            + "<br /><b>Something went wrong!</b>")));

      } else {

        Gson gson = new Gson();
        Checks checks = gson.fromJson(resp, Checks.class);
        Form fo = api.objects().form();

        for (Check check : checks.getChecks()) {

          fo.addField(
              api.objects()
                  .select()
                  .name("Checks" + String.valueOf(count))
                  .label("Select check " + String.valueOf(count) + ":")
                  .addOption(check.getHostname())
                  .addOption("none"));

          count++;
        }

        api.perform(
            api.context()
                .currentRoom()
                .post(
                    new PrimaryChatlet()
                        .setQuestionHtml("<br /><b>Select Checks from below :</b>")
                        .setReplyScreen(fo)
                        .setReplyLabel("Enter")
                        .alias("sendreqdel")));
      }
    }
  }
コード例 #10
0
ファイル: pingdombot.java プロジェクト: AnujArora94/Teamchat
  @OnKeyword("ping")
  public void ping(TeamchatAPI api) throws IOException, SQLException {
    String rmid;
    count = 1;
    // getting roomid
    rmid = api.context().currentRoom().getId();
    DBHandler ob4 = new DBHandler();
    boolean flag;
    flag = ob4.roomchk(rmid);
    // checking if roomid is available in the database.If it is available then user will be logged
    // in automatically n flag will become true else false
    if (flag == false) {
      PrimaryChatlet prime = new PrimaryChatlet();
      prime.setQuestionHtml(
          "<br /><b>First you have to sign in!!</b>"
              + "<br /><b>Note: </b><a1  style=\"color:#359FD8\";>For Signing in type \"login\" command</a1>");

      api.perform(api.context().currentRoom().post(prime));
    } else {
      DBHandler ob5 = new DBHandler();
      String[] usrpassapp = ob5.getusrpassapp(rmid);
      Username = usrpassapp[0];
      Password = usrpassapp[1];
      App_key = usrpassapp[2];
      url = "https://api.pingdom.com/api/2.0/checks";
      pingdomintegrator ob1 = new pingdomintegrator();
      String resp = ob1.getChecks(Username, Password, App_key, url);

      // error if there is some issue in the authentication.

      if (resp.equals("Error")) {
        PrimaryChatlet prime = new PrimaryChatlet();
        api.perform(
            api.context()
                .currentRoom()
                .post(
                    prime.setQuestionHtml(
                        "<br /><b>Error :</b>"
                            + "<br /><b>Status Code: 403</b>"
                            + "<br /><b>StatusDesc: Forbidden</b>"
                            + "<br /><b>Something went wrong!</b>")));

      } else {

        // parsing a json like this

        // {
        // "checks": [
        // {
        // "id": 1650784,
        // "created": 1435769579,
        // "name": "google",
        // "hostname": "www.google.com",
        // "use_legacy_notifications": true,
        // "resolution": 1,
        // "type": "http",
        // "lasttesttime": 1435806884,
        // "lastresponsetime": 167,
        // "status": "up",
        // "probe_filters": []
        // },
        // {
        // "id": 1650785,
        // "created": 1435769756,
        // "name": "Teamchat",
        // "hostname": "www.teamchat.com",
        // "use_legacy_notifications": true,
        // "resolution": 1,
        // "type": "http",
        // "lasttesttime": 1435806881,
        // "lastresponsetime": 725,
        // "status": "up",
        // "probe_filters": []
        // },
        // {
        // "id": 1650787,
        // "created": 1435769804,
        // "name": "Interns Teamchat",
        // "hostname": "interns.teamchat.com",
        // "use_legacy_notifications": true,
        // "resolution": 1,
        // "type": "http",
        // "lasterrortime": 1435806882,
        // "lasttesttime": 1435806882,
        // "lastresponsetime": 0,
        // "status": "down",
        // "probe_filters": []
        // }
        // ],
        // "counts": {
        // "total": 3,
        // "limited": 3,
        // "filtered": 3
        // }
        // }

        Gson gson = new Gson();
        Checks checks = gson.fromJson(resp, Checks.class);
        Form fo = api.objects().form();

        for (Check check : checks.getChecks()) {

          fo.addField(
              api.objects()
                  .select()
                  .name("Checks" + String.valueOf(count))
                  .label("Select check " + String.valueOf(count) + ":")
                  .addOption(check.getHostname())
                  .addOption("none"));

          count++;
        }

        api.perform(
            api.context()
                .currentRoom()
                .post(
                    new PrimaryChatlet()
                        .setQuestionHtml("<br /><b>Select Checks from below :</b>")
                        .setReplyScreen(fo)
                        .setReplyLabel("Enter")
                        .alias("sendreqcheck")));
      }
    }
  }