Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const axios = require("axios");
  2. const fetch = require("node-fetch");
  3. const tmi = require("tmi.js");
  4.  
  5. const channelname = "kitolito";
  6. const token = "xxx";
  7. const broadcaster_id = "41772911";
  8. const helixBaseUrl = "https://api.twitch.tv/helix";
  9. const clipAPI = `https://api.twitch.tv/helix/clips?broadcaster_id=${broadcaster_id}`;
  10.  
  11. const helix = axios.create({
  12.   baseURL: helixBaseUrl
  13. });
  14.  
  15. async function createClip() {
  16.   var clipRAW = await fetch(clipAPI, {
  17.     method: "post",
  18.     headers: {
  19.       Authorization: `Bearer ${token}`
  20.     }
  21.   });
  22.   var clipJSON = await clipRAW.json();
  23.   var clipURL = clipJSON.data[0].edit_url;
  24.   return clipURL;
  25. }
  26.  
  27. async function getUser() {
  28.   const response = await helix.get("/users", {
  29.     headers: { Authorization: `Bearer ${token}` }
  30.   });
  31.   return response.data[0] || null;
  32. }
  33.  
  34. async function getChannelInfo() {
  35.   const response = await helix.get(`/users?login=juztim`, {
  36.     headers: {
  37.       Authorization: `Bearer ${token}`
  38.     }
  39.   });
  40.   console.log(response.data);
  41.   return response.data[0] || null;
  42. }
  43.  
  44. async function getFollowDate(username) {
  45.   const followedAPI = `https://beta.decapi.me/twitch/followed/kitolito/${username}`;
  46.   var followInfoRAW = await fetch(followedAPI, {
  47.     method: "get",
  48.     headers: {
  49.       Authorization: `Bearer ${token}`
  50.     }
  51.   });
  52.   var followdate = await followInfoRAW.text();
  53.   return followdate;
  54. }
  55.  
  56. async function getWeatherInfo(location) {
  57.   const weatherAPI = `http://api.openweathermap.org/data/2.5/weather?q=${location}&appid=0fcc15a2ad746790e472df3d5fe344f4&units=metric`;
  58.   var weatherInfoRAW = await fetch(weatherAPI);
  59.   var weatherJSON = await weatherInfoRAW.json();
  60.   var temperature = await weatherJSON.main.temp;
  61.   console.log(temperature);
  62.   return temperature;
  63. }
  64.  
  65. async function getMatchupsLaLiga() {
  66.   const matchUPAPI = `http://api.football-data.org/v2/competitions/PD/matches?matchday=22`;
  67.   const matchUPRAW = await fetch(matchUPAPI, {
  68.     headers: {
  69.       "X-Auth-Token": `a339e5327cd74c3fb35c9f5d977a61cd`
  70.     }
  71.   });
  72.   const matchUPJSON = await matchUPRAW.json();
  73.   console.log(matchUPJSON);
  74.   const matchTeams = matchUPJSON.matches.map(
  75.     match => `${match.homeTeam.name} - ${match.awayTeam.name}`
  76.   );
  77.  
  78.   return matchTeams;
  79. }
  80.  
  81. async function getMatchupsBuLi() {
  82.   const matchUPAPI = `http://api.football-data.org/v2/competitions/BL1/matches?matchday=20`;
  83.   const matchUPRAW = await fetch(matchUPAPI, {
  84.     headers: {
  85.       "X-Auth-Token": `a339e5327cd74c3fb35c9f5d977a61cd`
  86.     }
  87.   });
  88.   const matchUPJSON = await matchUPRAW.json();
  89.   console.log(matchUPJSON);
  90.   const matchTeams = matchUPJSON.matches.map(
  91.     match => `${match.homeTeam.name} - ${match.awayTeam.name}`
  92.   );
  93.  
  94.   return matchTeams;
  95. }
  96.  
  97. async function getMatchupsBPL() {
  98.   const matchUPAPI = `http://api.football-data.org/v2/competitions/PL/matches?matchday=25`;
  99.   const matchUPRAW = await fetch(matchUPAPI, {
  100.     headers: {
  101.       "X-Auth-Token": `a339e5327cd74c3fb35c9f5d977a61cd`
  102.     }
  103.   });
  104.   const matchUPJSON = await matchUPRAW.json();
  105.   console.log(matchUPJSON);
  106.   const matchTeams = matchUPJSON.matches.map(
  107.     match => `${match.homeTeam.name} - ${match.awayTeam.name}`
  108.   );
  109.   return matchTeams;
  110. }
  111.  
  112. module.exports = {
  113.   getUser,
  114.   createClip,
  115.   getChannelInfo,
  116.   getFollowDate,
  117.   getWeatherInfo,
  118.   getMatchupsLaLiga,
  119.   getMatchupsBuLi,
  120.   getMatchupsBPL
  121. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement