├── public ├── bot.png ├── logo1.png ├── logo2.png ├── favicon.ico ├── bg-curve.png └── hashnode.svg ├── postcss.config.js ├── .vscode └── settings.json ├── next.config.js ├── tailwind.config.js ├── pages └── api │ ├── hello.ts │ └── user │ ├── ai.ts │ ├── tweets.ts │ └── profiles.ts ├── hooks └── useResize.ts ├── app ├── play │ ├── Slogan.tsx │ ├── page.tsx │ ├── Example.tsx │ ├── Answers.tsx │ └── Form.tsx ├── head.tsx ├── layout.tsx ├── Navbar.tsx ├── Faqs.tsx ├── Footer.tsx ├── Accordian.tsx └── page.tsx ├── .gitignore ├── tsconfig.json ├── package.json ├── LICENSE ├── styles └── globals.css ├── CONTRIBUTING.md ├── README.md └── CODE_OF_CONDUCT.md /public/bot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aadarsh805/TweetSage/HEAD/public/bot.png -------------------------------------------------------------------------------- /public/logo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aadarsh805/TweetSage/HEAD/public/logo1.png -------------------------------------------------------------------------------- /public/logo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aadarsh805/TweetSage/HEAD/public/logo2.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aadarsh805/TweetSage/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/bg-curve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aadarsh805/TweetSage/HEAD/public/bg-curve.png -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules/typescript/lib", 3 | "typescript.enablePromptUseWorkspaceTsdk": true 4 | } -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | module.exports = { 3 | reactStrictMode: true, 4 | experimental: { 5 | appDir: true, 6 | }, 7 | images: { 8 | domains: ["pbs.twimg.com"], 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | "./pages/**/*.{js,ts,jsx,tsx}", 5 | "./components/**/*.{js,ts,jsx,tsx}", 6 | "./app/**/*.{js,ts,jsx,tsx}", 7 | ], 8 | theme: { 9 | extend: {}, 10 | }, 11 | plugins: [], 12 | }; 13 | -------------------------------------------------------------------------------- /pages/api/hello.ts: -------------------------------------------------------------------------------- 1 | // Next.js API route support: https://nextjs.org/docs/api-routes/introduction 2 | import type { NextApiRequest, NextApiResponse } from 'next' 3 | 4 | type Data = { 5 | name: string 6 | } 7 | 8 | export default function handler( 9 | req: NextApiRequest, 10 | res: NextApiResponse 11 | ) { 12 | res.status(200).json({ name: 'John Doe' }) 13 | } 14 | -------------------------------------------------------------------------------- /hooks/useResize.ts: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from "react"; 2 | const useResize = (): number => { 3 | const [width, setWidth] = useState(0); 4 | function handleResize() { 5 | setWidth(window.innerWidth); 6 | } 7 | 8 | useEffect(() => { 9 | window.addEventListener("resize", handleResize); 10 | return () => window.removeEventListener("resize", handleResize); 11 | }, []); 12 | 13 | return width; 14 | }; 15 | 16 | export default useResize; 17 | -------------------------------------------------------------------------------- /app/play/Slogan.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const Slogan = () => { 4 | return ( 5 |
6 |

7 | TweetSage : 8 |

9 |

10 | Because your tweets deserve some sage advice. 11 |

12 |
13 | ); 14 | }; 15 | 16 | export default Slogan; 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | .pnpm-debug.log* 27 | 28 | # local env files 29 | .env*.local 30 | 31 | # vercel 32 | .vercel 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | next-env.d.ts 37 | -------------------------------------------------------------------------------- /app/head.tsx: -------------------------------------------------------------------------------- 1 | export default function Head() { 2 | return ( 3 | <> 4 | TweetSage 5 | 9 | 10 | 11 | 12 | 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /pages/api/user/ai.ts: -------------------------------------------------------------------------------- 1 | import { NextApiRequest, NextApiResponse } from "next"; 2 | import { Configuration, OpenAIApi } from "openai"; 3 | 4 | const configuration = new Configuration({ 5 | apiKey: process.env.OPEN_API_KEY, 6 | }); 7 | const openai = new OpenAIApi(configuration); 8 | 9 | export default async (req: NextApiRequest, res: NextApiResponse) => { 10 | const completion = await openai.createCompletion({ 11 | model: "text-davinci-003", 12 | prompt: req.body.prompt, 13 | temperature: 1, 14 | top_p: 1, 15 | frequency_penalty: 0, 16 | presence_penalty: 0, 17 | max_tokens: 256, 18 | }); 19 | 20 | res.status(200).json({ result: completion.data }); 21 | }; 22 | -------------------------------------------------------------------------------- /pages/api/user/tweets.ts: -------------------------------------------------------------------------------- 1 | import { NextApiRequest, NextApiResponse } from "next"; 2 | import Twitter from "twitter-v2"; 3 | import { Client } from "twitter-api-sdk"; 4 | 5 | export default async (req: NextApiRequest, res: NextApiResponse) => { 6 | const client = new Client(process.env.BearerToken!); 7 | 8 | try { 9 | const data = await client.tweets.tweetsRecentSearch({ 10 | query: `(from:${req.body.user}) -is:retweet -is:reply -is:quote`, 11 | max_results: 10, 12 | expansions: ["author_id"], 13 | "user.fields": [ 14 | "name", 15 | "profile_image_url", 16 | ], 17 | }); 18 | res.status(200).json({ data }); 19 | } catch (err) { 20 | console.log(err); 21 | } 22 | }; 23 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "strict": true, 12 | "forceConsistentCasingInFileNames": true, 13 | "noEmit": true, 14 | "esModuleInterop": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "jsx": "preserve", 20 | "incremental": true, 21 | "plugins": [ 22 | { 23 | "name": "next" 24 | } 25 | ] 26 | }, 27 | "include": [ 28 | "next-env.d.ts", 29 | "**/*.ts", 30 | "**/*.tsx", 31 | ".next/types/**/*.ts" 32 | ], 33 | "exclude": [ 34 | "node_modules" 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /public/hashnode.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "next dev", 5 | "build": "next build", 6 | "start": "next start" 7 | }, 8 | "dependencies": { 9 | "@emotion/react": "^11.10.5", 10 | "@emotion/styled": "^11.10.5", 11 | "@mui/icons-material": "^5.11.0", 12 | "@mui/lab": "^5.0.0-alpha.112", 13 | "@mui/material": "^5.11.0", 14 | "@vercel/analytics": "^0.1.6", 15 | "axios": "^1.2.1", 16 | "framer-motion": "^7.10.2", 17 | "next": "^13.0.4", 18 | "openai": "^3.1.0", 19 | "react": "^18.2.0", 20 | "react-copy-to-clipboard": "^5.1.0", 21 | "react-dom": "^18.2.0", 22 | "swr": "^2.0.0", 23 | "twitter-api-sdk": "^1.2.1", 24 | "twitter-lite": "^1.1.0", 25 | "twitter-v2": "^1.1.0", 26 | "zod": "^3.20.2" 27 | }, 28 | "devDependencies": { 29 | "@types/node": "18.11.3", 30 | "@types/react": "18.0.21", 31 | "@types/react-dom": "18.0.6", 32 | "autoprefixer": "^10.4.12", 33 | "postcss": "^8.4.18", 34 | "tailwindcss": "^3.2.1", 35 | "typescript": "4.8.4" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Aadarsh Thakur 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /pages/api/user/profiles.ts: -------------------------------------------------------------------------------- 1 | import { NextApiRequest, NextApiResponse } from "next"; 2 | import { Client } from "twitter-api-sdk"; 3 | 4 | export default async (req: NextApiRequest, res: NextApiResponse) => { 5 | const client = new Client(process.env.BearerToken!); 6 | const allReplies = []; 7 | 8 | let nextToken; 9 | try { 10 | const replies: any = await client.tweets.tweetsRecentSearch({ 11 | query: `in_reply_to_status_id:1611991686523289601`, 12 | expansions: ["author_id"], 13 | "user.fields": ["name", "profile_image_url"], 14 | max_results: 100, 15 | }); 16 | const users = replies.data 17 | ?.filter((tweet: any) => tweet.author_id !== undefined) 18 | .map((tweet: any) => tweet.author_id); 19 | const userData = await Promise.all( 20 | users!.map(async (user_id: any) => { 21 | if (user_id !== undefined) { 22 | const userInfo = await client.users.findUserById(user_id); 23 | return userInfo.data; 24 | } 25 | }) 26 | ); 27 | allReplies.push(...userData); 28 | nextToken = replies.pagination?.next_token; 29 | res.status(200).json({ allReplies }); 30 | } catch (err) { 31 | console.log(err); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /app/layout.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import "../styles/globals.css"; 4 | import { createTheme } from "@mui/material"; 5 | import { ThemeProvider } from "@mui/material"; 6 | import Navbar from "./Navbar"; 7 | import { Analytics } from "@vercel/analytics/react"; 8 | import { useEffect } from "react"; 9 | import bgImage from "public/bg-curve.png"; 10 | import Image from "next/image"; 11 | import Footer from "./Footer"; 12 | 13 | const theme = createTheme({ 14 | palette: { 15 | action: { 16 | disabledBackground: "#e0e0e0", 17 | disabled: "#9f9898", 18 | }, 19 | }, 20 | }); 21 | 22 | export default function RootLayout({ 23 | children, 24 | }: { 25 | children: React.ReactNode; 26 | }) { 27 | useEffect(() => { 28 | window.scrollTo(0, 0); 29 | }, []); 30 | 31 | return ( 32 | 33 | 34 | 35 | curve-image 40 |
41 | {children} 42 |
43 |
44 |
45 |
46 | 47 | 48 | 49 | 50 | ); 51 | } 52 | -------------------------------------------------------------------------------- /app/Navbar.tsx: -------------------------------------------------------------------------------- 1 | import Link from "next/link"; 2 | import React from "react"; 3 | import GitHubIcon from "@mui/icons-material/GitHub"; 4 | import TwitterIcon from "@mui/icons-material/Twitter"; 5 | import Logo from "../public/logo2.png"; 6 | import Image from "next/image"; 7 | 8 | const Navbar = () => { 9 | return ( 10 | 37 | ); 38 | }; 39 | 40 | export default Navbar; 41 | -------------------------------------------------------------------------------- /app/play/page.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { useState } from "react"; 4 | import Answers from "./Answers"; 5 | import Example from "./Example"; 6 | import Form from "./Form"; 7 | import Slogan from "./Slogan"; 8 | import ArrowUpwardIcon from "@mui/icons-material/ArrowUpward"; 9 | import { motion } from "framer-motion"; 10 | 11 | const page = () => { 12 | const [answer, setAnswer] = useState(""); 13 | const [displayedText, setDisplayedText] = useState(""); 14 | 15 | return ( 16 |
17 | 23 | 24 |
30 | 31 | 32 | 33 | 34 | {/*
{ 37 | transitionRef!.current!.style.transform = `translateY(0)`; 38 | }} 39 | className="absolute lg:bottom-0 bottom-[2em] hidden lg:flex right-28 w-12 h-12 rounded-full shadow-2xl transition duration-300 hover:bg-[#7214fff1] bg-[#7214ff] items-center justify-center z-50" 40 | > 41 | 42 |
*/} 43 |
44 | ); 45 | }; 46 | 47 | export default page; 48 | -------------------------------------------------------------------------------- /app/play/Example.tsx: -------------------------------------------------------------------------------- 1 | import React, { FC } from "react"; 2 | import ContentPasteIcon from "@mui/icons-material/ContentPaste"; 3 | import ContentCopyIcon from "@mui/icons-material/ContentCopy"; 4 | import { Tooltip } from "@mui/material"; 5 | 6 | export const exampleQuestion = [ 7 | "Tell me about this person", 8 | "What does this person do", 9 | "Tell a joke on this person", 10 | "Describe this person in 5 words", 11 | "Describe this person in 5 points", 12 | ]; 13 | 14 | const Example = () => { 15 | return ( 16 |
17 |
18 |
19 |

20 | Try these questions: 21 |

22 | 23 |
24 | 25 |
26 |
27 |
28 |
29 | ); 30 | }; 31 | 32 | export default Example; 33 | 34 | const Examples: FC = () => { 35 | return ( 36 |
37 | {exampleQuestion.map((item, index) => ( 38 |
42 |

{item}

43 |
navigator.clipboard.writeText(item)}> 44 | 45 | 46 | 47 |
48 |
49 | ))} 50 |
51 | ); 52 | }; 53 | -------------------------------------------------------------------------------- /app/Faqs.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { useEffect } from 'react'; 3 | import Backdrop from '@mui/material/Backdrop'; 4 | import Box from '@mui/material/Box'; 5 | import Modal from '@mui/material/Modal'; 6 | import Fade from '@mui/material/Fade'; 7 | import Button from '@mui/material/Button'; 8 | import Typography from '@mui/material/Typography'; 9 | import Accordian from './Accordian' 10 | import { width } from '@mui/system'; 11 | 12 | const style = { 13 | position: 'absolute' as 'absolute', 14 | top: '50%', 15 | left: '50%', 16 | transform: 'translate(-50%, -50%)', 17 | width: '90%', 18 | maxWidth: 700, 19 | bgcolor: 'background.paper', 20 | // border: '2px solid #000', 21 | boxShadow: 24, 22 | p: 4, 23 | }; 24 | 25 | const Faqs = () => { 26 | 27 | const [open, setOpen] = React.useState(false); 28 | const handleOpen = () => setOpen(true); 29 | const handleClose = () => setOpen(false); 30 | 31 | 32 | 33 | 34 | 35 | 36 | return ( 37 |
38 | 39 | 52 | 53 | 54 | 55 | 56 | 57 | 58 |
59 | ); 60 | 61 | } 62 | 63 | export default Faqs 64 | -------------------------------------------------------------------------------- /styles/globals.css: -------------------------------------------------------------------------------- 1 | @import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap"); 2 | @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700;800;900&display=swap"); 3 | @import url("https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700;900&display=swap"); 4 | @import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600;700;800&family=Roboto:wght@100;300;400;500;700;900&display=swap"); 5 | 6 | @tailwind base; 7 | @tailwind components; 8 | @tailwind utilities; 9 | 10 | html { 11 | scroll-behavior: smooth; 12 | } 13 | 14 | body { 15 | font-family: "Roboto", sans-serif; 16 | } 17 | 18 | * { 19 | -webkit-user-drag: none; 20 | } 21 | 22 | .purple-color { 23 | background-color: #cb79ff; 24 | } 25 | 26 | .dark-purple-color { 27 | background-color: #7214ff; 28 | } 29 | 30 | .dark-blue-color { 31 | background-color: #090426; 32 | } 33 | 34 | *::-webkit-scrollbar { 35 | display: none; 36 | } 37 | 38 | .typing-effect:after { 39 | content: "^"; 40 | animation: blink 1s linear infinite; 41 | } 42 | .typing-effect2:after { 43 | content: "|"; 44 | animation: blink 1s linear infinite; 45 | } 46 | 47 | .noOutline-btn { 48 | -webkit-tap-highlight-color: transparent; 49 | } 50 | 51 | @keyframes blink { 52 | 0% { 53 | opacity: 1; 54 | } 55 | 50% { 56 | opacity: 0; 57 | } 58 | 100% { 59 | opacity: 1; 60 | } 61 | } 62 | 63 | .cursor { 64 | display: inline-block; 65 | animation: blink 1s infinite; 66 | } 67 | 68 | * { 69 | outline: none; 70 | } 71 | 72 | .bot-chat::after { 73 | content: ""; 74 | position: absolute; 75 | left: 50%; 76 | transform: translateX(-50%); 77 | bottom: -8px; 78 | width: 0; 79 | height: 0; 80 | border-left: 6px solid transparent; 81 | border-right: 6px solid transparent; 82 | border-top: 12px solid white; 83 | z-index: -10; 84 | } -------------------------------------------------------------------------------- /app/Footer.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import GitHubIcon from "@mui/icons-material/GitHub"; 3 | import FacebookRoundedIcon from "@mui/icons-material/FacebookRounded"; 4 | import TwitterIcon from "@mui/icons-material/Twitter"; 5 | import LinkedInIcon from "@mui/icons-material/LinkedIn"; 6 | import Link from "next/link"; 7 | import Faqs from "./Faqs"; 8 | import { Tooltip } from "@mui/material"; 9 | 10 | // #f7f9fc 11 | const Footer = () => { 12 | return ( 13 |
14 | 15 |
16 |

17 | UI by{" "} 18 | 23 | Form Carry 24 | 25 |

26 |

Open Source

27 |
28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 40 | 41 | 42 | 43 | 44 | 48 | 49 | 50 | 51 |
52 |
53 | ); 54 | }; 55 | 56 | export default Footer; 57 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Welcome to TweetSage contributing guide Thank you for investing your time in contributing to my project! 2 | 3 | In this guide, you will get an overview on how to contribute, open issues, open a PR, review and merge it. 4 | 5 | New contributor guide To get an overview of the project, read the README. The README contains everything you need to get yourself started with your contributions to this Open Source Project. 6 | 7 | Getting started Issues Create a new issue If you spot any bugs with the existing code / contributions, head over to the Issues section and make sure the issue / bug is not already in the list of open issues. If you do not find the issue you want to report, you can open a new issue, by clicking on the New Issue button and filling up the form with the relavant information. 8 | 9 | Solve an issue Scan through our existing issues to find one that interests you. You can assign to you, any issue that is open and start working on it. After you have solved an issue, open a Pull Request for review. 10 | 11 | Make Changes For any changes you make, be it solving an existing / new Issue, or contributing a new feature, make sure you: 12 | 13 | Fork the repository, if not already done. Ensure the base branch of your repository is in sync with that of the OS project. Create a new branch in your forked repository, specifically for the task you are doing. Clone the newly created branch from your repository to your local enviroment, perform the initial setup in the README and start working on your change. Commit your update After you've made your changes, make sure to self review to verify its working, and commit the changes once you are happy with them, with an appropriate commit message. 14 | 15 | Pull Request When you're finished with the changes, and have commited the same, create a pull request, also known as a PR. 16 | 17 | Head over to your repository and branch you want to merge. Click on Contribute and select Open pull request. Fill the form with a title relavant to the changes / additions that you're making, and add a relevant description and create a pull request. Be sure to check out the PR later, as we may request that you do some changes, before we merge the PR. The details of what needs to be changed can be found as comments in the PR. As you update your PR and apply changes, mark each conversation as resolved, or add relavent comments to indicate the changes made. Your PR is merged! Yayyyyy!! Your PR is merged..confetti_ballconfetti_ball Now you can chill out or look for other issues to contribute to!! 18 | -------------------------------------------------------------------------------- /app/Accordian.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import Accordion from "@mui/material/Accordion"; 3 | import AccordionSummary from "@mui/material/AccordionSummary"; 4 | import AccordionDetails from "@mui/material/AccordionDetails"; 5 | import Typography from "@mui/material/Typography"; 6 | import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; 7 | import Link from "next/link"; 8 | 9 | export default function Accordian() { 10 | return ( 11 |
12 | 13 | Frequently asked questions 14 | 15 | 16 | 17 | } 19 | aria-controls="panel1a-content" 20 | id="panel1a-header" 21 | > 22 | Why are u getting username wrong? 23 | 24 | 25 | 26 |
  • 27 | You don't have your phone number linked with your Twitter account. 28 |
  • 29 |
  • You have not tweeted recently.
  • 30 |
  • Our API might be down, retry after sometime.
  • 31 |
    32 |
    33 |
    34 | 35 | } 37 | aria-controls="panel1a-content" 38 | id="panel1a-header" 39 | > 40 | How does it work? 41 | 42 | 43 | 44 | We are fetching your recent tweets through the Twitter API and 45 | giving them to the chatGPT API along with the question you asked. It 46 | replies with the most optimal answer. 47 | 48 | 49 | 50 | 51 | } 53 | aria-controls="panel1a-content" 54 | id="panel1a-header" 55 | > 56 | Where can I see the source code 57 | 58 | 59 | 60 | It's available right here in our{" "} 61 | 66 | Github repository 67 | 68 | 69 | 70 | 71 | 72 | } 74 | aria-controls="panel2a-content" 75 | id="panel2a-header" 76 | > 77 | Can I contribute to the project? 78 | 79 | 80 | 81 | Definitely yes, this project is completely open-source and open to 82 | your valuable contributions. 83 | 84 | 85 | 86 | {/* 87 | } 89 | aria-controls="panel3a-content" 90 | id="panel3a-header" 91 | > 92 | Disabled Accordion 93 | 94 | */} 95 |
    96 | ); 97 | } 98 | -------------------------------------------------------------------------------- /app/play/Answers.tsx: -------------------------------------------------------------------------------- 1 | import React, { use, useEffect, useRef, useState } from "react"; 2 | import bot from "public/bot.png"; 3 | import Image from "next/image"; 4 | import { motion } from "framer-motion"; 5 | 6 | type AnswerProp = { 7 | answer: string; 8 | displayedText: string; 9 | }; 10 | 11 | const numbers = [ 12 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 13 | ]; 14 | 15 | const Answers = ({ answer, displayedText }: AnswerProp) => { 16 | 17 | const sentences = [ "Damn shawty! 🥵 ", `Elon Musk tweeted what 🤯 `, "Yay! 4 new followers 🥳 " ]; 18 | const [index, setIndex] = useState(0); 19 | const [text, setText] = useState(""); 20 | 21 | useEffect(() => { 22 | const interval = setInterval(() => { 23 | const currentSentence = sentences[index]; 24 | const currentChar = currentSentence[text.length]; 25 | 26 | if (text.length === currentSentence.length) { 27 | setText(""); 28 | setIndex((index + 1) % sentences.length); 29 | } else { 30 | setText(text + currentChar); 31 | } 32 | }, 100); 33 | 34 | return () => clearInterval(interval); 35 | }, [index, text, sentences]); 36 | 37 | return ( 38 | 44 |
    45 |
    50 | bot 51 | 58 | {!answer && ( 59 |
    62 | {text} 63 |
    64 | )} 65 | {answer && ( 66 |
    69 | Oops! my bad, go ahead. 70 |
    71 | )} 72 |
    73 |
    74 |
    75 |
    76 | 77 | 78 | 79 |
    80 |

    81 | Your answer 82 |

    83 |
    84 |
    85 |
    86 | {numbers.map((number) => ( 87 | 88 | {number} 89 | 90 | ))} 91 |
    92 | {!answer && ^} 93 | {answer && ( 94 |

    95 | {displayedText} 96 |

    97 | )} 98 |
    99 |
    100 | ); 101 | }; 102 | 103 | export default Answers; 104 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TweetSage 2 | 3 | ## "Not being maintained currently" 4 | 5 | An open-source tool that analyzes your Twitter activity and answers to your questions based on your recent tweets 6 | 7 | Wanna know more how it's built, check out my blog on how I built it: [BLOG LINK](https://aadarshthakur.hashnode.dev/how-i-built-tweetsage-by-using-chatgpt-and-twitter-api-together) 8 | 9 | https://user-images.githubusercontent.com/95094057/208742885-50db694c-1b8d-4aa4-bbc7-22ac8e932044.mp4 10 | 11 | 12 | ## How it works 13 | 14 | - It works by fetching the user's recent tweets from the Twitter API 15 | - Then we give those tweets to chatGPT thorugh openAI's API and it generate answer based on user's recent tweets 16 | 17 | 27 | 28 | 29 | ## Installation 30 | 31 | > This project is built on nextJS 13 experimental version 32 | 33 | 1. Fork the repo into your account 34 | 35 | ![Fork Image](https://i.imgur.com/mNw6zxu.png) 36 | 37 | 2. Clone the project into your local machine 38 | 39 | ```sh 40 | git clone https://github.com//TweetSage.git 41 | ``` 42 | 43 | 3. Navigate the folder 44 | 45 | ```sh 46 | cd TweetSage 47 | ``` 48 | 49 | 3. Install the dependencies 50 | 51 | ```sh 52 | npm install 53 | ``` 54 | 4. Make .env file in root directory with these variables 55 | 56 | ```sh 57 | BearerToken= 'YOUR TWITTER API KEY GOES HERE' 58 | OPEN_API_KEY= 'YOUR OPENAI API KEY GOES HERE' 59 | ``` 60 | - Get your twitter api key here: [TWITTER API](https://developer.twitter.com/en/products/twitter-api) 61 | - Get your openAi api key here: [OPENAI API](https://openai.com/api/) 62 | 63 | 5. Run the project on local machine 64 | 65 | ```sh 66 | npm run dev 67 | ``` 68 | 6. Every time you start making changes to your forked repo make sure it's in sync with the original repo 69 | 70 | ## Contributing Guidelines 71 | 72 | Thank you for considering to contribute to this project. 73 | 74 | ### What do I need to know to contribute? 75 | 76 | This project is in a very early stage so anybody who's familiar with **ReactJS**/**NextJS**/**Typescript**/**TailwindCSS** can contribute. If you don't feel ready to make a contribution yet, no problem at all. You can also contribute to this `ReadMe` section or the **Documentation** part of our project. 77 | 78 | If you are interested to contribute and want to learn more about the technologies that are used in this project, checkout the links below. 79 | 80 | - [ReactJS Official Docs](https://reactjs.org/docs/getting-started.html) 81 | - [NextJS Documentation](https://beta.nextjs.org/docs) 82 | - [Typescript Documentaion](https://www.typescriptlang.org/docs/) 83 | - [TailwindCSS Docs](https://tailwindcss.com/docs/installation) 84 | - [Material UI Documentaion](https://mui.com/material-ui/getting-started/overview/) 85 | 86 | ### How to make a Contribution? 87 | 88 | Never made an open source contribution before? And wondering how to contribute to this project? 89 | No worries! Here's a quick guide, 90 | 91 | 1. Choose any feature/bug you wish to contribute to. 92 | 2. Fork the repository into your own account. 93 | 3. Clone the repo you have forked in your local machine using `git clone https://github.com//TweetSage.git` 94 | 4. Create a new branch for your fix by using the command `git checkout -b YourName-branch-name ` 95 | 5. Make the changes you wish to do and stage them using the command `git add files-you-have-changed ` or use `git add .` 96 | 6. Use the command `git commit -m "Short description of the changes"` to describe the changes you have done with a message. 97 | 7. Push the changes to your remote repository using `git push origin your-branch-name` 98 | 8. Submit a PR(pull request) to the upstream repository `Aadarsh805/TweeetSage` with a title and a small description. 99 | 9. Wait for the pull request to be reviewed by us. 100 | 10. Make appropriate changes if the maintainer recommends you to and submit it. 101 | 11. Await for your contribution to be merged into the repository. 102 | 103 | Checkout the [Contributing.md](CONTRIBUTING.md) file before contributing. 104 | 105 | 106 | ### Where can I go for help? 107 | 108 | If you need help, you can ask questions on our twitter : 109 | 110 | - [**Aadarsh Thakur**](https://twitter.com/Aadarsh805) 111 | - [**Somidh Roy**](https://twitter.com/RoySomidh) 112 | 113 | ## Credits 114 | 115 | - UI credits : [form carry](https://formcarry.com) 116 | 117 | 118 | ## License 119 | 120 | [MIT](LICENSE.md) 121 | 122 | 123 | ## Thanks to all the Contributors ❤️ 124 | 125 | 126 | 127 | 128 | 129 | 130 | ## Your Support means a lot 131 | 132 | 133 | Give a ⭐ to the project if you liked it. :) 134 | -------------------------------------------------------------------------------- /app/page.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import Image from "next/image"; 4 | import Link from "next/link"; 5 | import bot from "public/bot.png"; 6 | import { useEffect, useState } from "react"; 7 | import { motion } from "framer-motion"; 8 | 9 | const page = () => { 10 | // const transitionRef = useRef(null); 11 | 12 | // const handleScroll = () => { 13 | // transitionRef!.current!.style.transform = `translateY(-200vh)`; 14 | // }; 15 | 16 | 17 | 18 | const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; 19 | 20 | return ( 21 |
    25 | 31 |
    32 |

    33 | What your tweets tell about you 34 |

    35 |

    36 | Where even your most ridiculous tweets can reveal hidden truths{" "} 37 |

    38 |

    39 | Our website analyzes your Twitter activity to provide you with 40 | accurate and relevant responses to your queries. 41 |

    42 |
    43 | 44 | 49 | Try it out 50 | 51 | 52 |
    53 |
    54 |
    57 | bot 58 | 63 |
    66 | TweetSage is awesome! 67 |
    68 |
    69 |
    70 |
    71 |
    72 | 73 | 74 | 75 |
    76 |

    77 | Guide 78 |

    79 |
    80 |
    81 |
    82 | {numbers.map((number) => ( 83 | 84 | {number} 85 | 86 | ))} 87 |
    88 |
    89 | {``} 90 |

    91 | {``} 92 | 93 | We will first analyze your tweets then generate an answer to your question based on those tweets 94 | 95 | {``} 96 |

    97 |

    98 | {``} 99 | 100 | We are using chatGPT to analyze your tweets. Only works if you are an active user on twitter 101 | 102 | {``} 103 |

    104 | 105 | {``} 106 |
    107 |
    108 |
    109 | 110 | {/* bobo */} 111 |
    112 |
    113 | ); 114 | }; 115 | 116 | export default page; 117 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | Twitter. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /app/play/Form.tsx: -------------------------------------------------------------------------------- 1 | import Link from "next/link"; 2 | import { 3 | HTMLAttributes, 4 | HtmlHTMLAttributes, 5 | MouseEvent, 6 | SyntheticEvent, 7 | useCallback, 8 | useEffect, 9 | useState, 10 | } from "react"; 11 | import useSWR from "swr"; 12 | import { LoadingButton } from "@mui/lab"; 13 | import TextField from "@mui/material/TextField"; 14 | import Image from "next/image"; 15 | import { InputAdornment } from "@mui/material"; 16 | import AlternateEmailIcon from "@mui/icons-material/AlternateEmail"; 17 | import styled from "@emotion/styled"; 18 | import BlockIcon from "@mui/icons-material/Block"; 19 | import { FormControl } from "@mui/material"; 20 | import AutoComplete from "@mui/material/Autocomplete"; 21 | import { exampleQuestion } from "./Example"; 22 | import useResize from "../../hooks/useResize"; 23 | 24 | type TweetData = { 25 | text: string | null | undefined; 26 | }; 27 | 28 | type UserData = { 29 | profile_image_url: string; 30 | username: string; 31 | name: string; 32 | }; 33 | 34 | type AnswerProps = { 35 | answer: string; 36 | setAnswer: (value: string) => void; 37 | displayedText: string; 38 | setDisplayedText: (value: string) => void; 39 | }; 40 | 41 | type SuggestionType = { 42 | id: number; 43 | label: string; 44 | }; 45 | 46 | function getSuggestions(sampleQ: string[]): SuggestionType[] { 47 | return sampleQ.reduce((acc, curr, indx) => { 48 | acc.push({ 49 | id: indx + 1, 50 | label: curr, 51 | }); 52 | return acc; 53 | }, []); 54 | } 55 | 56 | const Form = ({ 57 | answer, 58 | setAnswer, 59 | displayedText, 60 | setDisplayedText, 61 | }: AnswerProps) => { 62 | const [user, setUser] = useState(""); 63 | const [userProfile, setUserProfile] = useState({ 64 | profile_image_url: "", 65 | username: "", 66 | name: "", 67 | }); 68 | const [question, setQuestion] = useState(""); 69 | const [tweets, setTweets] = useState([]); 70 | const [loadingTweets, setLoadingTweets] = useState(false); 71 | const [loadingData, setLoadingData] = useState(false); 72 | const [loadedTweets, setLoadedTweets] = useState(false); 73 | const [noUserError, setNoUserError] = useState(false); 74 | const [noQuestionError, setNoQuestionError] = useState(false); 75 | const [suggestions] = useState( 76 | getSuggestions(exampleQuestion) 77 | ); 78 | const width = useResize(); 79 | 80 | useEffect(() => { 81 | setUser(""); 82 | setQuestion(""); 83 | setTweets([]); 84 | setAnswer(""); 85 | }, []); 86 | 87 | const handleClick = async (e: MouseEvent) => { 88 | e.preventDefault(); 89 | 90 | if (user === "") { 91 | setNoUserError(true); 92 | return; 93 | } else { 94 | setNoUserError(false); 95 | } 96 | setLoadingTweets(true); 97 | 98 | const results = await fetch("/api/user/tweets", { 99 | method: "POST", 100 | body: JSON.stringify({ 101 | user, 102 | }), 103 | headers: { 104 | "Content-Type": "application/json", 105 | }, 106 | }).then((res) => res.json()); 107 | 108 | setTweets(results.data.data); 109 | setUserProfile(results.data?.includes?.users[0]); 110 | setLoadingTweets(false); 111 | setLoadedTweets(true); 112 | }; 113 | 114 | const handleSecondClick = async (e: MouseEvent) => { 115 | e.preventDefault(); 116 | // console.log("clicked button second"); 117 | setAnswer(""); 118 | 119 | if (question === "") { 120 | setNoQuestionError(true); 121 | return; 122 | } else { 123 | setNoQuestionError(false); 124 | } 125 | setLoadingData(true); 126 | 127 | const prompt = `you are given some tweets below, read these tweets : \n 128 | ${tweets.map((tweet) => tweet.text + "\n")} 129 | 130 | and about the person who wrote those Tweets ${question} 131 | `; 132 | 133 | const results = await fetch("/api/user/ai", { 134 | method: "POST", 135 | body: JSON.stringify({ 136 | prompt, 137 | }), 138 | headers: { 139 | "Content-Type": "application/json", 140 | }, 141 | }).then((res) => res.json()); 142 | 143 | setAnswer(results.result.choices[0].text); 144 | setLoadingData(false); 145 | }; 146 | 147 | const handleInputChange = (e: SyntheticEvent, value: string) => { 148 | setQuestion(value); 149 | }; 150 | 151 | let noTweets = tweets?.length < 1; 152 | if (tweets === undefined) noTweets = true; 153 | 154 | // typing effect 155 | 156 | useEffect(() => { 157 | let index = 0; 158 | 159 | const typing = setInterval(() => { 160 | setDisplayedText(`${answer.substring(0, index)}`); 161 | index++; 162 | 163 | if (index > answer.length) { 164 | clearInterval(typing); 165 | } 166 | }, 10); 167 | 168 | return () => { 169 | clearInterval(typing); 170 | }; 171 | }, [answer]); 172 | 173 | // Background color change have been made here 174 | 175 | // background-color: ${loadedTweets && tweets ? 'grey' : '#7214ff'} ; 176 | const StyledButton = styled(LoadingButton)` 177 | background-color: grey; 178 | border: none; 179 | &:hover { 180 | background-color: #7214ff; 181 | } 182 | `; 183 | 184 | // Button Changes adding here 185 | 186 | // const StyledTweetButton = styled(LoadingButton)` 187 | // background-color: ${loadedTweets && tweets ? 'grey' : '#7214ff'} ; 188 | // border: none; 189 | // &:hover { 190 | // background-color: ${loadedTweets ? 'grey' : '#7214ff'}; 191 | // opacity: ${!loadedTweets && user ? '.8' : '1'} 192 | // } 193 | // `; 194 | 195 | // const StyledAnswerButton = styled(LoadingButton)` 196 | // background-color: ${question && tweets ? '#7214ff' : 'grey'} ; 197 | // border: none; 198 | // &:hover { 199 | // background-color: ${question ? '#7214ff' : 'grey'}; 200 | // opacity: ${question && tweets ? '.8' : '1'} 201 | // } 202 | // `; 203 | 204 | return ( 205 |
    206 |
    207 | handleClick} 210 | > 211 | { 218 | setUser(e.currentTarget.value); 219 | setAnswer(""); 220 | setTweets([]); 221 | setLoadedTweets(false); 222 | setNoUserError(false); 223 | }} 224 | required 225 | helperText={ 226 | noUserError 227 | ? `Username can't be empty bro!` 228 | : loadedTweets && !tweets && "username wrong" 229 | } 230 | InputProps={{ 231 | startAdornment: ( 232 | 233 | 234 | 235 | ), 236 | }} 237 | className="col-span-2" 238 | /> 239 | 240 | {/* Making button changes here */} 241 | 252 | {loadedTweets && tweets ? "tweets loaded" : "get tweets"} 253 | 254 | 255 | 256 | {width < 1024 ? ( 257 | , 265 | option: SuggestionType 266 | ) => { 267 | return ( 268 |
  • 269 | {option.label} 270 |
  • 271 | ); 272 | }} 273 | renderInput={(params) => ( 274 | setQuestion(e.currentTarget.value)} 282 | className="" 283 | required 284 | helperText={noQuestionError && `Question can't be empty bro!`} 285 | /> 286 | )} 287 | /> 288 | ) : ( 289 | setQuestion(e.currentTarget.value)} 296 | className="" 297 | required 298 | helperText={noQuestionError && `Question can't be empty bro!`} 299 | /> 300 | )} 301 | 302 |
    307 | 314 | 324 | Get answer 325 | 326 |
    327 |
    328 |
    329 | ); 330 | }; 331 | 332 | export default Form; 333 | --------------------------------------------------------------------------------