-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPro Talking_BOT.py
86 lines (72 loc) · 2.92 KB
/
Pro Talking_BOT.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import random
import telebot
import apiai
import json
from telebot import types
bot = telebot.TeleBot("1100038091:AAESXzUtbx39eGW1Vfm25UvQZa9rOmLnO-U")
a = 0
@bot.message_handler(commands=['start'])
def start(message):
global a
a = a + 1
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item2 = types.KeyboardButton("/start")
item4 = types.KeyboardButton("/help")
item1 = types.KeyboardButton("/OaR")
item3 = types.KeyboardButton("/OaR10")
item5 = types.KeyboardButton("/stats")
markup.add(item1, item2, item3, item4, item5)
bot.send_message(message.chat.id, 'Привет! Давай общаться.'
' Для большей информации нажми на /help',
reply_markup=markup)
@bot.message_handler(commands=['help'])
def help(message):
global a
a = a + 1
bot.send_message(message.chat.id, 'Привет данный '
'бот был разработан для обучения ИИ '
'что бы помочь компаниям в обслуживании клиентов.')
bot.send_message(message.chat.id, 'Что-бы начать '
'пользоваться ботом просто напишите ему. '
'Так-же есть функция орла и решки(/OaR) '
'для решения споров с друзьями)))'
'(/OaR10 кинет монету 10 раз)')
bot.send_message(message.chat.id, 'Создан Фомченковым Семёном')
@bot.message_handler(commands=['OaR'])
def randomf(message):
global a
a = a + 1
if random.randint(0, 1) == 0:
bot.send_message(message.chat.id, 'Орёл')
else:
bot.send_message(message.chat.id, 'Решка')
@bot.message_handler(commands=['OaR10'])
def random10(message):
global a
a = a + 1
for i in range(10):
if random.randint(0, 1) == 0:
bot.send_message(message.chat.id, 'Орёл')
else:
bot.send_message(message.chat.id, 'Решка')
@bot.message_handler(commands=['stats'])
def stats(message):
global a
a = a + 1
bot.send_message(message.chat.id, 'Количество запросов боту')
bot.send_message(message.chat.id, a)
@bot.message_handler(content_types=['text'])
def textMessage(message):
global a
a = a + 1
request = apiai.ApiAI('c9a720bc0bb041e1bb9273d057eccfde').text_request()
request.lang = 'ru'
request.session_id = 'BOTOBHALKIN'
request.query = message.text
responseJson = json.loads(request.getresponse().read().decode('utf-8'))
response = responseJson['result']['fulfillment']['speech']
if response:
bot.send_message(message.chat.id, response)
else:
bot.send_message(message.chat.id, 'Я не очень понял тебя.')
bot.polling(none_stop=True)