Ejemplo n.º 1
0
  @OnAlias("sendreqadd")
  public void sendreqadd(TeamchatAPI api) throws IOException {
    String name = api.context().currentReply().getField("name");
    String host = api.context().currentReply().getField("host");
    String Protocol = api.context().currentReply().getField("Protocol");

    pingdomintegrator ob1 = new pingdomintegrator();

    String resp = ob1.addChecks(Username, Password, App_key, host, name, Protocol);

    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 {

      api.perform(
          api.context()
              .currentRoom()
              .post(new PrimaryChatlet().setQuestionHtml("<br /><b>" + resp + "</b>")));
    }
  }
Ejemplo n.º 2
0
  // communicating with pingdomintegrator class
  @OnAlias("sendreqdel")
  public void sendreqdel(TeamchatAPI api) throws IOException {

    int i;
    String chks[] = new String[count - 1];
    int s = 1;
    for (i = 0; i < count - 1; i++) {

      chks[i] = api.context().currentReply().getField("Checks" + String.valueOf(s));
      s++;
    }

    s = 1;
    url = "https://api.pingdom.com/api/2.0/checks";
    pingdomintegrator ob1 = new pingdomintegrator();

    String resp = ob1.getChecks(Username, Password, App_key, url);
    Gson gson = new Gson();
    Checks checks = gson.fromJson(resp, Checks.class);

    int k = 0;

    int del[] = new int[count - 1];

    for (Check check : checks.getChecks()) {
      if (check.getHostname().equals(chks[k])) {

        del[k] = check.getId();
      } else {

        del[k] = 1;
      }
      k++;
    }

    k = 1;

    String respdel = ob1.delChecks(Username, Password, App_key, del);

    if (respdel.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 {
      PrimaryChatlet prime = new PrimaryChatlet();
      api.perform(
          api.context().currentRoom().post(prime.setQuestionHtml("<br /><b>" + respdel + "</b>")));
    }
  }
  @OnAlias("selectedproject")
  public void select_story(TeamchatAPI api) {
    String[] Project = api.context().currentReply().getField("project_name").split("-");
    pid = Long.valueOf(Project[Project.length - 1]);
    String URL = "https://www.pivotaltracker.com/services/v5/projects/" + pid + "/stories";
    String URL_parameter = "";
    SendGet sg = new SendGet();
    Field field_story = null;
    try {
      String jsonData = sg.sendGet(URL, USER_AGENT, URL_parameter, pb.getAccess_token());

      Gson gson = new Gson();
      Data[] Story = gson.fromJson(jsonData, Data[].class);

      field_story = api.objects().select().name("story_name").label("Story");
      for (Data story : Story) {
        field_story.addOption(story.getName() + "-" + story.getId());
      }
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    api.perform(
        api.context()
            .currentRoom()
            .post(
                new PrimaryChatlet()
                    .setQuestion("Select story to be deleted")
                    .setReplyScreen(api.objects().form().addField(field_story))
                    .alias("deleteselectedstory")));
  }
  @OnKeyword("Notification")
  public void Notification(TeamchatAPI api) {

    String URL = "https://www.pivotaltracker.com/services/v5/my/notifications";
    String URL_parameter = "envelope=true";
    Database_Handler db = new Database_Handler();
    pb = db.GetBasicStuff(api.context().currentSender().getEmail());
    SendGet sg = new SendGet();
    // list of messages
    String responseHTML = "";
    @SuppressWarnings("unused")
    Field f = null;
    try {
      String jsonData = sg.sendGet(URL, USER_AGENT, URL_parameter, pb.getAccess_token());
      @SuppressWarnings("unused")
      Gson gson = new Gson();
      JSONArray jsonArray = new JSONObject(jsonData).getJSONArray("data");
      for (int i = 0; i < jsonArray.length(); i++) {
        responseHTML += jsonArray.getJSONObject(i).get("message").toString() + "<br />";
      }
      System.out.println("Notifications are:" + responseHTML);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    api.perform(
        api.context().currentRoom().post(new PrimaryChatlet().setQuestionHtml(responseHTML)));
  }
Ejemplo n.º 5
0
  @OnKeyword("help")
  public void help(TeamchatAPI api) {

    api.perform(
        api.context()
            .currentRoom()
            .post(
                new PrimaryChatlet()
                    .setQuestionHtml(
                        "<h4><b>Hi, I'm Pingdom Bot.</b></h4>"
                            + "<img src=\"http://monitorama.com/2014/images/logo_pingdom.png\" height=\"90\" width=\"230\">"
                            + "<br />"
                            + "<br /><b>You can use me to check the status of your website, using following keywords:</b>"
                            + "<br />"
                            + "<ul type=\"square\"; style=\"color:#359FD8\";><li><a1 style=\"color:black\";><b>ping - </b></a1><a2 style=\"color:#359FD8\";>"
                            + "Type this command to Check the status for your website added in your pingdom account."
                            + "</a2></li><li><a3 style=\"color:black\";><b>addcheck - </b></a3><a4 style=\"color:#359FD8\";>"
                            + "Type this command to create any check i.e to add any website in your pingdom account."
                            + "</a4></li><li><a5 style=\"color:black\";><b>deletecheck - </b></a5><a6 style=\"color:#359FD8\";>"
                            + "Type this command to delete any check i.e to delete any website in your pingdom account."
                            + "</a6></li><li><a7 style=\"color:black\";><b>login - </b></a5><a6 style=\"color:#359FD8\";>"
                            + "Type this command if you are logging for the first time from this room or you want to log in from other account."
                            + "</a6></li><li><a7 style=\"color:black\";><b>logout - </b></a7><a8 style=\"color:#359FD8\";>"
                            + "Type this command to log out from your existing account."
                            + "</a8></li></ul>")));

    // list of keywords
    // 1.)ping
    // 2.)add
    // 3.)delete

  }
Ejemplo n.º 6
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));
  }
Ejemplo n.º 7
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")));
  }
Ejemplo n.º 8
0
 @OnKeyword("help")
 public void box(TeamchatAPI api) {
   api.perform(
       api.context()
           .currentRoom()
           .post(
               new PrimaryChatlet().setQuestionHtml("'Share' - Share multiple file or folders")));
 }
  @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")));
    }
  }
Ejemplo n.º 10
0
  @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));
    }
  }
  @OnAlias("createproject")
  public void create_project(TeamchatAPI api) throws IOException {
    String ProjectName = api.context().currentReply().getField("project_name");

    String[] Account = api.context().currentReply().getField("account_name").split("-");
    long id = Long.valueOf(Account[Account.length - 1]);
    System.out.println(id);
    String URL = "https://www.pivotaltracker.com/services/v5/projects",
        URL_parameter = "name=" + ProjectName + "&account_id=" + id;
    new SendPost().sendPost(URL, USER_AGENT, URL_parameter, pb.getAccess_token());
    api.perform(api.context().currentRoom().post(new TextChatlet("Project Created!")));
  }
  @OnAlias("deleteselectedstory")
  public void delete_task(TeamchatAPI api) {

    String[] Project = api.context().currentReply().getField("story_name").split("-");
    long id = Long.valueOf(Project[Project.length - 1]);
    String URL = "https://www.pivotaltracker.com/services/v5/projects/" + pid + "/stories/" + id;
    String URL_parameter;
    URL_parameter = "";
    SendDelete sd = new SendDelete();
    sd.sendDelete(URL, USER_AGENT, URL_parameter, pb.getAccess_token());
    api.perform(api.context().currentRoom().post(new TextChatlet("Story Deleted!")));
  }
Ejemplo n.º 13
0
  @OnKeyword("logout")
  public void logout(TeamchatAPI api) throws SQLException {

    String rmid;
    rmid = api.context().currentRoom().getId();

    DBHandler chk = new DBHandler();
    boolean flag;
    flag = chk.roomchk(rmid);
    if (flag == true) {
      DBHandler datacng = new DBHandler();
      datacng.stmt.executeUpdate("DELETE FROM Bot.pingdom_auth" + " WHERE roomId='" + rmid + "'");
      datacng.conn.close();
      PrimaryChatlet prime = new PrimaryChatlet();
      prime.setQuestionHtml("<h5><b>You are successfully logged out!!</b></h5>");
      api.perform(api.context().currentRoom().post(prime));
    } else {
      PrimaryChatlet prime = new PrimaryChatlet();
      prime.setQuestionHtml("<h5><b>You are not logged in!!</b></h5>");
      api.perform(api.context().currentRoom().post(prime));
    }
  }
Ejemplo n.º 14
0
  @OnAlias("getdatafeed")
  public void getdatafeed(TeamchatAPI api) {

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

    api.perform(api.context().currentRoom().post(new TextChatlet("Thank You !!")));

    DBHandler datacng = new DBHandler();

    String Tkt = api.context().currentReply().getField("TicketID");
    String rate = api.context().currentReply().getField("Rating");
    String rcom = api.context().currentReply().getField("rcomment");

    System.out.println(Tkt);
    System.out.println(rate);
    System.out.println(rcom);

    try {
      datacng.stmt.executeUpdate(
          "UPDATE "
              + datacng.configProps.getProperty("dbname").trim()
              + "."
              + datacng.configProps.getProperty("tablename").trim()
              + " SET rating ='"
              + rate
              + "'"
              + ",Rcomment ='"
              + rcom
              + "'"
              + " where ticketId='"
              + Tkt
              + "'");
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    Ticket t = zd.getTicket(Long.parseLong(Tkt));
    SatisfactionRating sr = new SatisfactionRating();
    sr.setScore(rate);
    sr.setComment(rcom);
    t.setSatisfactionRating(sr);

    // updating existing ticket in out database
    zd.updateTicket(t);
    System.out.println("Tested");
  }
  @OnKeyword("Deletestory")
  public void deleteStory(TeamchatAPI api) {
    Database_Handler db = new Database_Handler();
    pb = db.GetBasicStuff(api.context().currentSender().getEmail());
    GetProjects gp = new GetProjects();
    Field f = null;
    f = gp.getProject(pb.getAccess_token(), api);

    api.perform(
        api.context()
            .currentRoom()
            .post(
                new PrimaryChatlet()
                    .setQuestion("Select project in which the story exists")
                    .setReplyScreen(api.objects().form().addField(f))
                    .alias("selectedproject")));
  }
Ejemplo n.º 16
0
 @OnKeyword(value = "help")
 public void help(TeamchatAPI api) {
   api.perform(
       api.context()
           .currentRoom()
           .post(
               new PrimaryChatlet()
                   .setQuestionHtml(
                       "<h4><b>Hi, I'm Room Bot.</b></h4>"
                           + "<img src=\"https://slack.global.ssl.fastly.net/1e47/plugins/room/assets/service_128.png\" height=\"120\" width=\"120\">"
                           + "<br />"
                           + "<br /><b>I'll help you to interact with your friends or relatives with the help of video chat.</b>"
                           + "<br />"
                           + "<ul type=\"square\"; style=\"color:#359FD8\";><li><a1 style=\"color:black\";><b>Room - </b></a1><a2 style=\"color:#359FD8\";>"
                           + "Use This keyword to continue with video chat"
                           + "</a2></li></ul>")));
 }
Ejemplo n.º 17
0
  @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));
  }
  @OnKeyword("Deleteproject")
  public void deleteProject(TeamchatAPI api) throws ClientProtocolException, IOException {
    Database_Handler db = new Database_Handler();
    pb = db.GetBasicStuff(api.context().currentSender().getEmail());
    GetProjects gp = new GetProjects();
    Field f = null;
    f = gp.getProject(pb.getAccess_token(), api);

    api.perform(
        api.context()
            .currentRoom()
            .post(
                new PrimaryChatlet()
                    .setQuestion("Select project to be deleted")
                    .setReplyScreen(api.objects().form().addField(f))
                    .alias("deleteproject")));
  }
Ejemplo n.º 19
0
 @OnAlias(value = "adduser")
 public void adduser(TeamchatAPI api) {
   String Name = api.context().currentReply().getField("Name");
   String EmailId = api.context().currentReply().getField("EmailId");
   String roomlink = api.context().currentReply().getField("roomlink");
   Room roo = api.context().create().setName("RoomBot").add(EmailId);
   api.perform(
       roo.post(
           new PrimaryChatlet()
               .setQuestionHtml(
                   "<h4><b>Room Details:</b></h4>"
                       + "<ul type=\"square\"; style=\"color:#359FD8\";><li><a1 style=\"color:black\";><b>Contact Person- </b></a1><a2 style=\"color:#359FD8\";>"
                       + Name
                       + "</a2></li></ul>"
                       + "<br /><b>Click on the link below to join the Video Chat.</b>"
                       + "<br /><a href=\""
                       + roomlink
                       + "\"><b style=\"color:#359FD8\";>Go To Room</b></a>")));
 }
Ejemplo n.º 20
0
 @OnKeyword("onenote")
 public void ononenote(TeamchatAPI api) throws Exception {
   System.out.println(c.configProps.getProperty("client_id"));
   Token.api1 = api;
   api.perform(
       api.context()
           .currentRoom()
           .post(
               new PrimaryChatlet()
                   .setQuestionHtml(
                       "<h4 style=\"display:block;margin:0 auto;\">Login with OneNote</h4>"
                           + "<hr/>"
                           + "<a class=\"login-button\" target=\"_blank\" href=\""
                           + "https://login.live.com/oauth20_authorize.srf?client_id="
                           + c.configProps.getProperty("client_id")
                           + "&scope=office.onenote_update&response_type=token&redirect_uri="
                           + URLEncoder.encode(c.configProps.getProperty("redirect_url"), "UTF-8")
                           + "\" style=\"display: block;box-sizing: border-box; margin: 0 auto;font-size: 21px;color: #fff;padding: 15px;border-radius: 6px;background-color: rgb(128, 57, 123);\">Login</a>")));
 }
Ejemplo n.º 21
0
  // inserting the data into the database.
  @OnAlias("setdata")
  public void setdata(TeamchatAPI api) throws SQLException {

    String Username = api.context().currentReply().getField("Username");
    String Password = api.context().currentReply().getField("Password");
    String App_key = api.context().currentReply().getField("App_key");

    this.Username = Username;
    this.Password = Password;
    this.App_key = App_key;
    roomId = api.context().currentRoom().getId();
    DBHandler ob4 = new DBHandler();
    boolean flag;
    flag = ob4.roomchk(roomId);
    if (flag == false) {
      DBHandler ob1 = new DBHandler();
      ob1.setData(Username, Password, this.App_key, roomId);
    } else {
      DBHandler datacng = new DBHandler();
      datacng.stmt.executeUpdate(
          "UPDATE Bot.pingdom_auth"
              + " SET username ='******'"
              + ", pass ='******'"
              + ", appkey ='"
              + App_key
              + "'"
              + " where roomId='"
              + roomId
              + "'");
      datacng.conn.close();
    }
    api.perform(
        api.context()
            .currentRoom()
            .post(
                new PrimaryChatlet()
                    .setQuestionHtml("<h5><b>You are logged in successfully!!</b></h5>")));
  }
Ejemplo n.º 22
0
  @OnKeyword("share")
  public void share(TeamchatAPI api) {
    String roomId = api.context().currentRoom().getId();

    try {
      configProps = loadPropertyFromClasspath("box-config.properties", BoxBot.class);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    String url = configProps.getProperty("server").trim() + "Select.jsp?roomid=" + roomId;

    api.perform(
        api.context()
            .currentRoom()
            .post(
                new PrimaryChatlet()
                    .setQuestionHtml(
                        "<a href='" + url + "' target=_blank>Select files or folders</a>")));
  }
  @OnAlias("createstory")
  public void create_story(TeamchatAPI api) {
    String StoryName = api.context().currentReply().getField("story_name");
    String Notes = api.context().currentReply().getField("notes");

    String[] Project = api.context().currentReply().getField("project_name").split("-");
    long pid = Long.valueOf(Project[Project.length - 1]);

    String URL = "https://www.pivotaltracker.com/services/v5/projects/" + pid + "/stories";
    String URL_parameter;
    URL_parameter = "name=" + StoryName + "&description=" + Notes;
    SendPost sp = new SendPost();
    try {
      sp.sendPost(URL, USER_AGENT, URL_parameter, pb.getAccess_token());
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    api.perform(api.context().currentRoom().post(new TextChatlet("Story Created!")));
    ;
  }
Ejemplo n.º 24
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")));
 }
  @OnKeyword("Createstory")
  public void createStory(TeamchatAPI api) {
    Database_Handler db = new Database_Handler();
    pb = db.GetBasicStuff(api.context().currentSender().getEmail());

    GetProjects gp = new GetProjects();
    Field f_pid = null;
    f_pid = gp.getProject(pb.getAccess_token(), api);

    api.perform(
        api.context()
            .currentRoom()
            .post(
                new PrimaryChatlet()
                    .setQuestion("Fill in details of the story")
                    .setReplyScreen(
                        api.objects()
                            .form()
                            .addField(api.objects().input().label("Story Name:").name("story_name"))
                            .addField(api.objects().input().label("Description").name("notes"))
                            .addField(f_pid))
                    .alias("createstory")));
  }
Ejemplo n.º 26
0
  /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    if (request.getParameter("oauth_problem") != null) {
      if (request.getParameter("oauth_problem").equals("user_refused"))
        response.sendRedirect("refuse.html");
    } else {
      OAuthService service;
      Token requestToken, accessToken;
      OAuthRequest requestLink;
      org.scribe.model.Response responseLink;
      DBHandler db = new DBHandler();

      service =
          new ServiceBuilder()
              .provider(LinkedInApi.class)
              .apiKey("754z46slfke0xm")
              .apiSecret("Jm46YNdPTb2toxoY")
              .build();

      String oAuthToken = request.getParameter("oauth_token");
      String oAuthVerifier = request.getParameter("oauth_verifier");

      String[] data = db.getData(oAuthToken);
      String oAuthSecret = data[1];
      String roomId = data[2];
      String email = data[3];

      requestToken = new Token(oAuthToken, oAuthSecret);

      Verifier v = new Verifier(oAuthVerifier);
      accessToken = service.getAccessToken(requestToken, v);

      System.out.println("\n\n\n\n\n" + accessToken + "\n\n\n\n\n");

      db.setAccessData(email, accessToken.getToken(), accessToken.getSecret());

      requestLink = new OAuthRequest(Verb.GET, "https://api.linkedin.com/v1/people/~?format=json");
      service.signRequest(accessToken, requestLink); // the access token
      // from step 4
      responseLink = requestLink.send();

      if (responseLink.getCode() != 401) {
        JSONObject j1 = new JSONObject(responseLink.getBody());

        TeamchatAPI api = WebAppTeamChatAPI.getTeamchatAPIInstance(getServletConfig());
        api.perform(
            api.context()
                .byId(roomId)
                .post(
                    new PrimaryChatlet()
                        .setQuestionHtml(
                            "Now you are authorized to send linkedin updates from teamchat"
                                + "<br/><b>Use following keywords -</b><br/><ul>"
                                + "<li>'profile' - Get Profile Information</li>"
                                + "<li>'post' - Post on LinkedIn</li></ol>"
                                + "<li>'reset' - Remove your account from teamchat</li></ul>")));

        request.setAttribute("name", j1.getString("firstName") + " " + j1.getString("lastName"));
        RequestDispatcher rd = request.getRequestDispatcher("Auth.jsp");
        rd.forward(request, response);
      } else response.sendRedirect("error.html");
    }
  }
Ejemplo n.º 27
0
  @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")));
      }
    }
  }
Ejemplo n.º 28
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);
  }
Ejemplo n.º 29
0
  @OnAlias("sendreqcheck")
  public void sendreqcheck(TeamchatAPI api) throws IOException {

    int i;
    String chks[] = new String[count - 1];
    int s = 1;
    for (i = 0; i < count - 1; i++) {

      chks[i] = api.context().currentReply().getField("Checks" + String.valueOf(s));
      s++;
    }
    count = 1;
    s = 1;
    url = "https://api.pingdom.com/api/2.0/checks";
    pingdomintegrator ob1 = new pingdomintegrator();
    String resp = ob1.getChecks(Username, Password, App_key, url);

    Gson gson = new Gson();
    Checks checks = gson.fromJson(resp, Checks.class);

    int k = 0;
    String color;
    color = "#359FD8";
    // color="#CF0909";--red
    // color="#24970D";---green
    int len = chks.length;
    for (Check check : checks.getChecks()) {
      for (k = 0; k < len; k++) {
        if (check.getHostname().equals(chks[k])) {
          if (check.getStatus().equals("up")) {

            color = "#24970D";

          } else if (check.getStatus().equalsIgnoreCase("down")) {
            color = "#CF0909";
          }
          PrimaryChatlet prime1 = new PrimaryChatlet();
          prime1.setQuestionHtml(
              "<h4><b>Host Details "
                  + String.valueOf(s)
                  + ":</b></h4>"
                  + "<ul type=\"square\"; style=\"color:#359FD8\";><li><a1 style=\"color:black\";><b>Name- </b></a1><a2 style=\"color:#359FD8\";>"
                  + check.getName()
                  + "</a2></li><li><a3 style=\"color:black\";><b>Hostname- </b></a3><a4 style=\"color:#359FD8\";>"
                  + check.getHostname()
                  + "</a4></li><li><a5 style=\"color:black\";><b>Status - </b></a5><a6 style=\"color:"
                  + color
                  + "\";>"
                  + check.getStatus()
                  + "</a6></li><li><a7 style=\"color:black\";><b>Last Response Time - </b></a7><a8 style=\"color:#359FD8\";>"
                  + check.getLastresponsetime()
                  + " ms"
                  + "</a8></li><li><a9 style=\"color:black\";><b>Type - </b></a9><a10 style=\"color:#359FD8\";>"
                  + check.getType()
                  + "</a10></li></ul>");
          api.perform(api.context().currentRoom().post(prime1));

          s++;
        }
      }
    }

    s = 1;
  }
 @OnKeyword("Logout")
 public void Logout(TeamchatAPI api) {
   Database_Handler db = new Database_Handler();
   db.DeleteData(api.context().currentSender().getEmail());
   api.perform(api.context().currentRoom().post(new TextChatlet("You have been logged out.")));
 }