Skip to content

Commit

Permalink
2022 11 16 - Merge with Old MiBot Folder
Browse files Browse the repository at this point in the history
  • Loading branch information
clcmo authored Nov 16, 2022
1 parent 457abc1 commit 37fec17
Show file tree
Hide file tree
Showing 892 changed files with 43,802 additions and 6 deletions.
107 changes: 107 additions & 0 deletions .replit
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# The command that runs the program.
run = ["python3", "main.py"]
# The primary language of the repl. There can be others, though!
language = "python3"
# The main file, which will be shown by default in the editor.
entrypoint = "main.py"
# A list of globs that specify which files and directories should
# be hidden in the workspace.
hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"]

# Specifies which nix channel to use when building the environment.
[nix]
channel = "stable-21_11"

# Per-language configuration: python3
[languages.python3]
# Treats all files that end with `.py` as Python.
pattern = "**/*.py"
# Tells the workspace editor to syntax-highlight these files as
# Python.
syntax = "python"

# The command needed to start the Language Server Protocol. For
# linting and formatting.
[languages.python3.languageServer]
start = ["pyls"]

# The command to start the interpreter.
[interpreter]
[interpreter.command]
args = [
"stderred",
"--",
"prybar-python3",
"-q",
"--ps1",
"\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ",
"-i",
]

# The environment variables needed to correctly start Python and use the
# package proxy.
[env]
VIRTUAL_ENV = "/home/runner/${REPL_SLUG}/venv"
PATH = "${VIRTUAL_ENV}/bin"
PYTHONPATH="${VIRTUAL_ENV}/lib/python3.8/site-packages"
REPLIT_POETRY_PYPI_REPOSITORY="https://package-proxy.replit.com/pypi/"
MPLBACKEND="TkAgg"

# Enable unit tests. This is only supported for a few languages.
[unitTest]
language = "python3"

# Add a debugger!
[debugger]
support = true

# How to start the debugger.
[debugger.interactive]
transport = "localhost:0"
startCommand = ["dap-python", "main.py"]

# How to communicate with the debugger.
[debugger.interactive.integratedAdapter]
dapTcpAddress = "localhost:0"

# How to tell the debugger to start a debugging session.
[debugger.interactive.initializeMessage]
command = "initialize"
type = "request"

[debugger.interactive.initializeMessage.arguments]
adapterID = "debugpy"
clientID = "replit"
clientName = "replit.com"
columnsStartAt1 = true
linesStartAt1 = true
locale = "en-us"
pathFormat = "path"
supportsInvalidatedEvent = true
supportsProgressReporting = true
supportsRunInTerminalRequest = true
supportsVariablePaging = true
supportsVariableType = true

# How to tell the debugger to start the debuggee application.
[debugger.interactive.launchMessage]
command = "attach"
type = "request"

[debugger.interactive.launchMessage.arguments]
logging = {}

# Configures the packager.
[packager]
# Search packages in PyPI.
language = "python3"
# Never attempt to install `unit_tests`. If there are packages that are being
# guessed wrongly, add them here.
ignoredPackages = ["unit_tests"]

[packager.features]
enabledForHosting = false
# Enable searching packages from the sidebar.
packageSearch = true
# Enable guessing what packages are needed from the code.
guessImports = true
Binary file added __pycache__/html_page.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/keep_alive.cpython-38.pyc
Binary file not shown.
12 changes: 6 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Insert Title
# MiBot

[![GitHub license](https://img.shields.io/github/license/clcmo/web?style=for-the-badge)](https://github.com/clcmo/web)
[![GitHub stars](https://img.shields.io/github/stars/clcmo/web?style=for-the-badge)](https://github.com/clcmo/web/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/clcmo/web?style=for-the-badge)](https://github.com/clcmo/web/network)
[![GitHub issues](https://img.shields.io/github/issues/clcmo/web?style=for-the-badge)](https://github.com/clcmo/web/issues)
[![GitHub license](https://img.shields.io/github/license/clcmo/MiBot?style=for-the-badge)](https://github.com/clcmo/MiBot)
[![GitHub stars](https://img.shields.io/github/stars/clcmo/MiBot?style=for-the-badge)](https://github.com/clcmo/MiBot/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/clcmo/MiBot?style=for-the-badge)](https://github.com/clcmo/MiBot/network)
[![GitHub issues](https://img.shields.io/github/issues/clcmo/MiBot?style=for-the-badge)](https://github.com/clcmo/MiBot/issues)
[![GitHub donate](https://img.shields.io/github/sponsors/clcmo?color=pink&style=for-the-badge)](https://github.com/sponsors/clcmo)

Description about the project
Create a Motivational Bot for Discord, using the knowledge acquired from the [Free Bootcamp tutorial](https://www.freecodecamp.org/portuguese/news/tutorial-de-criacao-de-bot-para-o-discord-em-python/).

Insert screenshot to inform what the visualization will be like

Expand Down
16 changes: 16 additions & 0 deletions keep_alive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from flask import Flask
from threading import Thread
import webbrowser

app = Flask('')

@app.route('/')
def home():
return "Hello, It Works!"

def run():
app.run(host='0.0.0.0',port=8080)

def keep_alive():
t = Thread(target=run)
t.start()
105 changes: 105 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import os
import discord
import requests
import json
import random
from replit import db
from keep_alive import keep_alive

my_secret = os.getenv('TOKEN')

client = discord.Client()

sad_words = ["sad", "depressed", "unhappy", "angry", "miserable"]

starter_encouragements = [
"Cheer up!", "Hang in there.", "You are a great person / bot!"
]

cool_words = ["happy", "kind", "cheer", "great", "beautiful"]

if "responding" not in db.keys():
db["responding"] = True


def get_quote():
response = requests.get("https://zenquotes.io/api/random")
json_data = json.loads(response.text)
quote = json_data[0]["q"] + " -" + json_data[0]["a"]
return (quote)


def update_encouragements(encouraging_message):
if "encouragements" in db.keys():
encouragements = db["encouragements"]
encouragements.append(encouraging_message)
db["encouragements"] = encouragements
else:
db["encouragements"] = [encouraging_message]


def delete_encouragment(index):
encouragements = db["encouragements"]
if len(encouragements) > index:
del encouragements[index]
db["encouragements"] = encouragements


@client.event
async def on_ready():
print("We have logged in as {0.user}".format(client))


@client.event
async def on_message(message):
if message.author == client.user:
return

msg = message.content

if msg.startswith("$inspire"):
quote = get_quote()
await message.channel.send(quote)

if db["responding"]:
options = starter_encouragements
if "encouragements" in db.keys():
options = options + db["encouragements"]

if any(word in msg for word in sad_words):
await message.channel.send(random.choice(options))
if any(word in msg for word in cool_words):
await message.channel.send(random.choice(options))

if msg.startswith("$new"):
encouraging_message = msg.split("$new ", 1)[1]
update_encouragements(encouraging_message)
await message.channel.send("New encouraging message added.")

if msg.startswith("$del"):
encouragements = []
if "encouragements" in db.keys():
index = int(msg.split("$del", 1)[1])
delete_encouragment(index)
encouragements = db["encouragements"]
await message.channel.send(encouragements)

if msg.startswith("$list"):
encouragements = []
if "encouragements" in db.keys():
encouragements = db["encouragements"]
await message.channel.send(encouragements)

if msg.startswith("$responding"):
value = msg.split("$responding ", 1)[1]

if value.lower() == "true":
db["responding"] = True
await message.channel.send("Responding is on.")
else:
db["responding"] = False
await message.channel.send("Responding is off.")


keep_alive()
client.run(my_secret)
Loading

0 comments on commit 37fec17

Please sign in to comment.