Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.13 KB | None | 0 0
  1. package TPPDekuBot;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.net.URL;
  7. import java.net.URLConnection;
  8. import java.util.List;
  9. import java.util.concurrent.LinkedBlockingQueue;
  10. import org.apache.http.HttpResponse;
  11. import org.apache.http.NameValuePair;
  12. import org.apache.http.client.HttpClient;
  13. import org.apache.http.client.entity.UrlEncodedFormEntity;
  14. import org.apache.http.client.methods.HttpPost;
  15. import org.apache.http.impl.client.HttpClients;
  16.  
  17. public class DekuBotMain {
  18.  
  19.     public static LinkedBlockingQueue<String> messages = new LinkedBlockingQueue<>();
  20.     public static LinkedBlockingQueue<String> whispers = new LinkedBlockingQueue<>();
  21.  
  22.     public static void main(String[] args) {
  23.         DekuBot b = new DekuBot();
  24.         DekuBot c = new DekuBot();
  25.         try {
  26.             c.setVerbose(true);
  27.             b.setVerbose(true);
  28.             b.connect("199.9.253.120", 6667, "oauth:OneHand");
  29.             c.connect("irc.twitch.tv", 6667, "oauth:OneHand");
  30.             b.sendRawLine("CAP REQ :twitch.tv/commands");
  31.             b.sendRawLine("CAP REQ :twitch.tv/membership");
  32.             c.sendRawLine("CAP REQ :twitch.tv/commands");
  33.             c.sendRawLine("CAP REQ :twitch.tv/membership");
  34.             b.joinChannel("#_killermapper_1417986539782");
  35.             b.joinChannel("#_killermapper_1434489343452");
  36.             b.joinChannel("#_mehcheniti_1420060673372");
  37.             b.joinChannel("#_wow_deku_onehand_1425759882381");
  38.             c.joinChannel("#the_chef1337");
  39.             c.joinChannel("#twitchtriestoplay");
  40.             c.joinChannel("#assassinskye");
  41.             //c.joinChannel("#twitch_plays_3ds");
  42.             b.startBanLog();
  43.         } catch (Exception ex) {
  44.             ex.printStackTrace();
  45.         }
  46.     }
  47.  
  48.     /**
  49.      * Returns a page's Source code as a string
  50.      *
  51.      * @param url Page to look up
  52.      * @return Page Source as a String
  53.      * @throws IOException
  54.      */
  55.     public static String getUrlSource(String url) throws IOException {
  56.         URL u = new URL(url);
  57.         URLConnection uc = u.openConnection();
  58.         uc.setReadTimeout(20000);
  59.         StringBuilder a;
  60.         try (BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream(), "UTF-8"))) {
  61.             String inputLine;
  62.             a = new StringBuilder();
  63.             while ((inputLine = in.readLine()) != null) {
  64.                 a.append(inputLine + "\n");
  65.             }
  66.         }
  67.         return a.toString();
  68.  
  69.     }
  70.  
  71.     public static String sendPost(String url, List<NameValuePair> params, List<NameValuePair> header) throws IOException {
  72.         HttpClient httpclient = HttpClients.createDefault();
  73.         HttpPost httppost = new HttpPost(url);
  74.         httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
  75.         if (header != null && !header.isEmpty()) {
  76.             for (NameValuePair el : header) {
  77.                 httppost.addHeader(el.getName(), el.getValue());
  78.             }
  79.         }
  80.         HttpResponse response = httpclient.execute(httppost);
  81.         return response.toString();
  82.     }
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement