Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
ozaneski13 committed Aug 31, 2022
1 parent a242907 commit f04901e
Show file tree
Hide file tree
Showing 32 changed files with 235 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/SusmaBot.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
worker: python3 susmabot.py
Binary file added pics/Ağlamaklı Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Delici Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Disney Prensesi Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Efendi Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/HawlıSusma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Heyecanlı Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Karizmatik Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Koca Kafa Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Minnoş Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Paşa Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Seksi Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Sinirli Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Soylu Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Susma Bugün Çok Üzgün.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Susma Gaplana Karşı.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Susma Yemek Peşinde.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Susma Yemek İstiyor.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Taştaşlar Gitti Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Uykulu Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Uyuyan Susma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/ffbaa2ea-eac6-42ce-aad9-ea031dc980b6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added requirements.txt
Binary file not shown.
1 change: 1 addition & 0 deletions runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-3.10.6
114 changes: 114 additions & 0 deletions sketch_aug15a/sketch_aug15a.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <SoftwareSerial.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

String networkID = "";
String networkPass = "";

int rxPin = 10;
int txPin = 11;

String thingSpeakIPAddress = "184.106.153.149";

SoftwareSerial esp(rxPin, txPin);

int resval = 0;
int respin = A3;

unsigned long prevMillis = 0;
const long interval = 1000;

void setup()
{
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
for (;;);
}

display.clearDisplay();
draw(false);

esp.begin(115200);
esp.println("AT");

while (!esp.find("OK"))
{
esp.println("AT");
}

esp.println("AT+CWMODE=1");

while (!esp.find("OK"))
{
esp.println("AT+CWMODE=1");
}

esp.println("AT+CWJAP=\"" + networkID + "\",\"" + networkPass + "\"");

while (!esp.find("OK"));

delay(1000);
}

void loop()
{
draw(true);

esp.println("AT+CIPSTART=\"TCP\",\"" + thingSpeakIPAddress + "\",80");

String thingSpeakData = "";

unsigned long currentMillis = millis();

if (currentMillis - prevMillis >= interval)
{
prevMillis = currentMillis;

resval = analogRead(respin);

display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.cp437(true);
display.print("Res value is: ");
display.println(resval);
display.display();

thingSpeakData += String(resval);
thingSpeakData += "\r\n\r\n";

esp.print("AT+CIPSEND=");
esp.println(thingSpeakData.length() + 2);
delay(2000);

if (esp.find(">"))
{
esp.print(thingSpeakData);
delay(1000);
}

esp.println("AT+CIPCLOSE");
delay(1000);
}
}

void draw(bool status)
{
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.cp437(true);

if (status)
display.write("Detection is ON!");
else
display.write("Detection is OFF!");

display.display();
}
82 changes: 82 additions & 0 deletions susmabot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import os
import random
import discord
import glob
import requests
from discord.ext import commands
from discord.ext import tasks
from dotenv import load_dotenv

images = []
for filename in glob.glob('pics/*.jpg'):
images.append(filename)

load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')

intents = discord.Intents.all()
intents.members = True

help_command = commands.DefaultHelpCommand(
no_category = 'Commands'
)

bot = commands.Bot(command_prefix = '!', intents = intents, help_command = help_command)

lastEntryDate = None

def checkWaterLevel():
msg = requests.get("")
date = msg.json()['feeds'][-1]['created_at']
msg = msg.json()['feeds'][-1]['field1']

return int(msg), date

@bot.command(help = "Woof woof istiyosan woofla!")
async def woof(ctx):
response = "Woof woof!"
await ctx.send(response)

@bot.command(help = "Su seviyesi için su woof woofla!")
async def water(ctx):
response = "Su seviyesi için su woof woofla!"
await ctx.send(response)

@bot.command(help = "Susma foto için susmaVre!")
async def susmaVre(ctx):
response = discord.File(images[random.randrange(0, len(images))])
await ctx.send(file = response)
response = response.filename
await ctx.send(response.split('.', 1)[0])

@bot.event
async def on_ready():
await checkWaterLevelTask.start()
await bot.change_presence(activity = discord.Activity(type = discord.ActivityType.playing, name = "Woof woof!"))

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

if message.content == "Su" or message.content == "su" or message.content == "SU":
response = format(message.author.mention) + ", su seviyesi " + str(checkWaterLevel()[0])
await message.channel.send(response)

if message.content == "Woof" or message.content == "woof" or message.content == "havla" or message.content == "Havla":
response = "Woof woof!"
await message.channel.send(response)

await bot.process_commands(message)

@tasks.loop(minutes = 10)
async def checkWaterLevelTask():
global lastEntryDate
if checkWaterLevel()[0] < 300 and checkWaterLevel()[1] != lastEntryDate:
lastEntryDate = checkWaterLevel()[1]
channel = bot.get_channel()
await channel.send("Woof susadım woof!")

if __name__ == '__main__':
bot.run(TOKEN)

0 comments on commit f04901e

Please sign in to comment.