Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Chatbot[GSSoC23] #65 #164

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 4 additions & 36 deletions Discord_Bot/README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
# Music Bot 🎧
<p align="center"> <img width="75" alt="hello" src="https://user-images.githubusercontent.com/88873588/152376709-bf1f48c1-2eb9-4b0b-be4a-ae8627cc8dcc.png">

A Discord Music Bot Written in Python by [Aritra Belel](belelaritra)

# <p align="center"> Welcome bot </p>

## Access Token :

To get the access token, go to the [Bot List](https://discordapp.com/developers/applications/me) and click on the **Create Bot** button.
Then click on the **OAuth2** tab and click on the **Generate Bot** button.
Then copy the **Bot Token** and paste it in `Line No 307` of the `main.py` in the place of `YOUR_TOKEN_HERE`

## Installation

In Terminal Run this Command :

```
pip install -r requirements.txt
```

Downloads:

- Download [ffmpeg](https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z)

## Bot commands

The bot can be called into action using `-` which also provides a list of commands:

| Shortcut Command | Command | Description |
| ---------------- | ---------------------------- | --------------------------------- |
| | `-help` | Default Help Command |
| `-h` | `-command` | Gives All Command Lists of EDM |
| `-j` | `-join` | Connects Voice Channel |
| `-l` | `-leave` | Leaves the Voice Channel |
| `-p` | `-play` `<song name or url>` | Plays a Song from Youtube |
| `-pa` | `-pause` | Pauses Current song |
| `-re` | `-resume` | Resume the paused song |
| `-st` | `-stop` | Stops the song + Clears the Queue |
| `sk` | `-skip` | Skips the song |
| `-cur` | `-current` | Gives the current playing song |
**<p align="center"> A simple bot that can be used to welcome new users to a discord server, sending them a custom private message, send a welcome message to a specific channel, and adding them to a role.**
14 changes: 14 additions & 0 deletions currency conversion chat bot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# currency-convertor Bot
1. currency converter chatbot code with Flask to create a web-based chatbot.

# Getting Started

## Prerequisites
[Python](https://www.python.org/downloads/)
[API USED](https://app.exchangerate-api.com/)


## How to setup

2. To run the Flask application, save the code in a file and execute it using the command python app.py. The chatbot will be accessible at http://localhost:5000.
49 changes: 49 additions & 0 deletions currency conversion chat bot/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import requests
import json
from flask import Flask, request, render_template

# Constants
API_KEY = '7cecaa58d6244a0b73104ba3'
API_URL = f'https://openexchangerates.org/api/latest.json?app_id={API_KEY}'

app = Flask(__name__)

def convert_currency(amount, source_currency, target_currency):
# Make API request
response = requests.get(API_URL)
data = response.json()

# Check if API request was successful
if response.status_code == 200:
# Get exchange rates from API response
rates = data['rates']

# Convert amount from source to target currency
if source_currency in rates and target_currency in rates:
converted_amount = amount * (rates[target_currency] / rates[source_currency])
return converted_amount
else:
return None
else:
return None

@app.route('/', methods=['GET', 'POST'])
def home():
if request.method == 'POST':
amount = float(request.form['amount'])
source_currency = request.form['source_currency']
target_currency = request.form['target_currency']

converted_amount = convert_currency(amount, source_currency, target_currency)

if converted_amount is not None:
result = f'{amount} {source_currency} = {converted_amount} {target_currency}'
else:
result = 'Currency conversion failed.'

return render_template('index.html', result=result)

return render_template('index.html')

if __name__ == '__main__':
app.run()
22 changes: 22 additions & 0 deletions currency conversion chat bot/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>Currency Converter Chatbot</title>
</head>
<body>
<h1>Currency Converter Chatbot</h1>
<form method="post" action="/">
<label for="amount">Amount:</label>
<input type="number" step="0.01" name="amount" required><br><br>
<label for="source_currency">Source Currency:</label>
<input type="text" name="source_currency" required><br><br>
<label for="target_currency">Target Currency:</label>
<input type="text" name="target_currency" required><br><br>
<input type="submit" value="Convert">
</form>
{% if result %}
<h3>Result:</h3>
<p>{{ result }}</p>
{% endif %}
</body>
</html>
2 changes: 2 additions & 0 deletions currency conversion chat bot/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flask
requests