Skip to content

Commit

Permalink
Bot Beta Done
Browse files Browse the repository at this point in the history
  • Loading branch information
NarayanAdithya committed Jun 17, 2022
1 parent be96175 commit b8438cc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
8 changes: 4 additions & 4 deletions app/bot/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def postmessage(message):
current['message'].append(mess)
update = {"$set":{"message":current['message']}}
db_m.update_one(db_m.find(query)[0],update)
print("About to Execute Response")
try:
response=requests.post(app.config['ADI_BOT_URL'],data=json.dumps({'sender':hash(request.remote_addr),'message':mess}))
response=response.json()
except requests.exceptions.ConnectionError:
response={'text':'Connection to Bot Failed, Sorry!'}
print("Emitted")
emit('received_message',response)
response=[{'text':'Connection to Bot Failed, Sorry!'}]
print(response)
emit('received_message',{'data':response})
5 changes: 0 additions & 5 deletions app/bot/routes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from . import bot
from app import db_m

@bot.route('/hello')
def bot_helloe():
todos = db_m.todos
todos.insert_one({'content': 'Trial', 'degree': 'Trial'})
return "Bot Hello Here"
2 changes: 1 addition & 1 deletion app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
{% block body %}

{% endblock %}
<h1 class="text-center text-purple-300"> Bot Coming Soon....</h1>
<h1 class="text-center text-purple-300"> Bot Beta Version is here...</h1>
<footer class="bg-purple-500 flex flex-col md:flex-row text-center text-purple-300 bottom-0 mt-5 p-10 justify-between " >
<a href="https://github.com/NarayanAdithya"><h1 class="font-bold sm:text-lg text-md" >GitHub</h1></a>
<a href="https://www.linkedin.com/in/adithya-narayan-3747081a3/"><h1 class="font-bold sm:text-lg text-md" >LinkedIn</h1></a>
Expand Down
5 changes: 3 additions & 2 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
$(document).ready(function(){
socket = io.connect('http://' + document.domain + ':' + location.port + '/bot/chat');
socket.on('received_message',function(msg){
var elem="<div class=\" justify-self-start bot_message sm:m-2 bg-emerald-600 w-1/2 rounded-md p-2\" ><h6 class=\"text-md\" ><u>Adi Bot</u></h6><p class=\"md:text-sm text-xs\">"+msg['text']+"</p></div>";
console.log(msg.data[0].text);
var elem="<div class=\" justify-self-start bot_message sm:m-2 bg-emerald-600 w-1/2 rounded-md p-2\" ><h6 class=\"text-md\" ><u>Adi Bot</u></h6><p class=\"md:text-sm text-xs\">"+msg.data[0].text+"</p></div>";
var message=document.getElementById('message').value;
var textarea=document.getElementById('user_message');
textarea.innerHTML+=elem;
Expand Down Expand Up @@ -97,7 +98,7 @@ <h3>Projects</h3>
</div>
{%endif%}
<div id="bot" class="container rounded-md mt-24 mb-24 p-10 mx-auto border-purple-400 border-4 bg-purple-300 bg-opacity-25 w-full md:w-3/4 " >
<h3 class="text-center text-2xl text-white" >Adi Bot - <span class="text-red-500" >Coming Soon</span></h3>
<h3 class="text-center text-2xl text-white" >Adi Bot - <span class="text-red-500" >Beta Up</span></h3>
<div id="user_message" class=" rounded-md grid grid-cols-1 bg-purple-700 p-2 sm:p-5 bg-opacity-75 overflow-auto max-h-96 ">
<div class=" justify-self-start bot_message sm:m-2 bg-emerald-600 w-1/2 rounded-md p-2" >
<h6 class="text-md" ><u>Adi Bot</u></h6>
Expand Down

0 comments on commit b8438cc

Please sign in to comment.