Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const axios = require("axios");
- const fetch = require("node-fetch");
- const tmi = require("tmi.js");
- const channelname = "kitolito";
- const token = "xxx";
- const broadcaster_id = "41772911";
- const helixBaseUrl = "https://api.twitch.tv/helix";
- const clipAPI = `https://api.twitch.tv/helix/clips?broadcaster_id=${broadcaster_id}`;
- const helix = axios.create({
- baseURL: helixBaseUrl
- });
- async function createClip() {
- var clipRAW = await fetch(clipAPI, {
- method: "post",
- headers: {
- Authorization: `Bearer ${token}`
- }
- });
- var clipJSON = await clipRAW.json();
- var clipURL = clipJSON.data[0].edit_url;
- return clipURL;
- }
- async function getUser() {
- const response = await helix.get("/users", {
- headers: { Authorization: `Bearer ${token}` }
- });
- return response.data[0] || null;
- }
- async function getChannelInfo() {
- const response = await helix.get(`/users?login=juztim`, {
- headers: {
- Authorization: `Bearer ${token}`
- }
- });
- console.log(response.data);
- return response.data[0] || null;
- }
- async function getFollowDate(username) {
- const followedAPI = `https://beta.decapi.me/twitch/followed/kitolito/${username}`;
- var followInfoRAW = await fetch(followedAPI, {
- method: "get",
- headers: {
- Authorization: `Bearer ${token}`
- }
- });
- var followdate = await followInfoRAW.text();
- return followdate;
- }
- async function getWeatherInfo(location) {
- const weatherAPI = `http://api.openweathermap.org/data/2.5/weather?q=${location}&appid=0fcc15a2ad746790e472df3d5fe344f4&units=metric`;
- var weatherInfoRAW = await fetch(weatherAPI);
- var weatherJSON = await weatherInfoRAW.json();
- var temperature = await weatherJSON.main.temp;
- console.log(temperature);
- return temperature;
- }
- async function getMatchupsLaLiga() {
- const matchUPAPI = `http://api.football-data.org/v2/competitions/PD/matches?matchday=22`;
- const matchUPRAW = await fetch(matchUPAPI, {
- headers: {
- "X-Auth-Token": `a339e5327cd74c3fb35c9f5d977a61cd`
- }
- });
- const matchUPJSON = await matchUPRAW.json();
- console.log(matchUPJSON);
- const matchTeams = matchUPJSON.matches.map(
- match => `${match.homeTeam.name} - ${match.awayTeam.name}`
- );
- return matchTeams;
- }
- async function getMatchupsBuLi() {
- const matchUPAPI = `http://api.football-data.org/v2/competitions/BL1/matches?matchday=20`;
- const matchUPRAW = await fetch(matchUPAPI, {
- headers: {
- "X-Auth-Token": `a339e5327cd74c3fb35c9f5d977a61cd`
- }
- });
- const matchUPJSON = await matchUPRAW.json();
- console.log(matchUPJSON);
- const matchTeams = matchUPJSON.matches.map(
- match => `${match.homeTeam.name} - ${match.awayTeam.name}`
- );
- return matchTeams;
- }
- async function getMatchupsBPL() {
- const matchUPAPI = `http://api.football-data.org/v2/competitions/PL/matches?matchday=25`;
- const matchUPRAW = await fetch(matchUPAPI, {
- headers: {
- "X-Auth-Token": `a339e5327cd74c3fb35c9f5d977a61cd`
- }
- });
- const matchUPJSON = await matchUPRAW.json();
- console.log(matchUPJSON);
- const matchTeams = matchUPJSON.matches.map(
- match => `${match.homeTeam.name} - ${match.awayTeam.name}`
- );
- return matchTeams;
- }
- module.exports = {
- getUser,
- createClip,
- getChannelInfo,
- getFollowDate,
- getWeatherInfo,
- getMatchupsLaLiga,
- getMatchupsBuLi,
- getMatchupsBPL
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement