Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import json
import requests
TOKEN = "<47765431:AAEvDMHzinFvKP0blwI72ku7qXgupAPkfFk>"
my_bot_token = "747765431:AAEvDMHzinFvKP0blwI72ku7qXgupAPkfFk"
URL = "https://api.telegram.org/bot{}/".format(TOKEN)
receive_messages_url ="https://api.telegram.org/bot747765431:AAEvDMHzinFvKP0blwI72ku7qXgupAPkfFk/getUpdates"
acknoledge_messages = "https://api.telegram.org/bot747765431:AAEvDMHzinFvKP0blwI72ku7qXgupAPkfFk/getUpdates?offset={}"
send_messages_url = "https://api.telegram.org/bot747765431:AAEvDMHzinFvKP0blwI72ku7qXgupAPkfFk/sendMessage?chat_id={}&text={}"
# Sentences we'll respond with if the user greeted us
GREETING_KEYWORDS = ("hello", "hi", "greetings", "sup", "what's up",)
GREETING_RESPONSES = ["'sup bro", "hey", "*nods*", "hey you get my snap?"]
name = input("Hello Sir/Madam, what is your name? ")
print("Hello " + name)
feelings = input("How are you feeling today?")
Terrible = input("Stressful Day?")
Great = input("I'm feeling good myself!")
if "Terrible" in feelings:
print("I'm sorry to hear that!")
def check_for_greeting(sentence):
"""If any of the words in the user's input was a greeting, return a greeting response"""
for word in sentence.words:
if word.lower() in GREETING_KEYWORDS:
return random.choice(GREETING_RESPONSES)
Question = input("Computer Science Stress Kicking in?")
Thoughts = input("It'll all be worth it in the end")
if input == 'Yep':
print("Thoughts")
print("Let's do some maths to chill the vibe")
if input == "Let's do some maths to chill the vibe":
print(Name + "what's Five + Eight")
num = input
if num > 12:
print("So close, the correct answer is 13")
elif num == 13:
print("Correct!")
else:
print("The Answer is Thirteen")
from chatterbot.logic import LogicAdapter
from chatterbot.conversation import Statement
class MathematicalEvaluation(LogicAdapter):
def __init__(self, **kwargs):
super(MathematicalEvaluation, self).__init__(**kwargs)
self.language = kwargs.get('language', 'ENG')
self.cache = {}
def can_process(self, statement):
response = self.process(statement)
self.cache[statement.text] = response
return response.confidence == 1
def process(self, statement):
from mathparse import mathparse
input_text = statement.text
# Use the result cached by the process method if it exists
if input_text in self.cache:
cached_result = self.cache[input_text]
self.cache = {}
return cached_result
# Getting the mathematical terms within the input statement
expression = mathparse.extract_expression(input_text, language=self.language)
response = Statement(text=expression)
try:
response.text += ' = ' + str(
mathparse.parse(expression, language=self.language)
)
# The confidence is 1 if the expression could be evaluated
response.confidence = 1
except mathparse.PostfixTokenEvaluationException:
response.confidence = 0
return response
from chatterbot.logic import LogicAdapter
from chatterbot.conversation import Statement
def send_welcome(message):
bot.reply_to(message, 'Heyyy!!!!')
def get_url(url):
response = requests.get(url)
content = response.content.decode("utf8")
return content
def get_json_from_url(url):
content = get_url(url)
js = json.loads(content)
return js
def get_first_name(message):
out = message['message']['from']['first_name']
return out
def get_last_name(message):
out = message['message']['from']['last_name']
return out
def get_updates():
url = URL + "getUpdates"
js = get_json_from_url(url)
return js
def get_last_chat_id_and_text(updates):
num_updates = len(updates["result"])
last_update = num_updates - 1
text = updates["result"][last_update]["message"]["text"]
chat_id = updates["result"][last_update]["message"]["chat"]["id"]
return (text, chat_id)
def send_message(text, chat_id):
url = URL + "sendMessage?text={}&chat_id={}".format(text, chat_id)
get_url(url)