Project Files Added
Browse files- .gitattributes +1 -0
- LICENSE +21 -0
- README.md +20 -0
- app.py +134 -0
- chatt.py +40 -0
- chromedriver +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
chromedriver filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2020 Vaibhav Singh
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
README.md
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Omegle-Chatbot
|
2 |
+
An Omegle Chatbot for promotion of Social media content or use it to increase views on YouTube. With the help of Chatterbot AI, this chatbot can be customized with new QnAs and will deal in a humanly way.
|
3 |
+
Used Selenium for Web Automation and English corpus data to train chatbot. [other languages](https://github.com/gunthercox/chatterbot-corpus/tree/master/chatterbot_corpus/data)
|
4 |
+
|
5 |
+
![](omg/saved2.png)
|
6 |
+
![](omg/saved4.png)
|
7 |
+
## To setup and run
|
8 |
+
`~$ python3 app.py`
|
9 |
+
## ChatterBot Installation
|
10 |
+
[If you are just getting started with ChatterBot](https://chatterbot.readthedocs.io/en/stable/setup.html)
|
11 |
+
## To add custom dataset
|
12 |
+
[Setting the training class in chatt.py](https://chatterbot.readthedocs.io/en/stable/training.html)
|
13 |
+
## Selenium
|
14 |
+
[Getting started and setup](https://selenium-python.readthedocs.io/)
|
15 |
+
## License & copyright
|
16 |
+
© Vaibhav Singh
|
17 |
+
Licensed under the [MIT License](LICENSE).
|
18 |
+
|
19 |
+
|
20 |
+
|
app.py
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from selenium import webdriver
|
2 |
+
import time
|
3 |
+
from time import sleep
|
4 |
+
from selenium.webdriver.common.keys import Keys
|
5 |
+
|
6 |
+
|
7 |
+
class omegle():
|
8 |
+
def __init__(self, interests, chromedriver, headless = False):
|
9 |
+
|
10 |
+
self.driver = webdriver.Chrome(chromedriver)
|
11 |
+
self.driver.get('https://www.omegle.com/')
|
12 |
+
|
13 |
+
interest = self.driver.find_element_by_class_name('newtopicinput')
|
14 |
+
|
15 |
+
for i in interests:
|
16 |
+
interest.send_keys(i)
|
17 |
+
interest.send_keys(Keys.RETURN)
|
18 |
+
|
19 |
+
sleep(1)
|
20 |
+
|
21 |
+
self.driver.find_element_by_xpath('//*[@id="textbtn"]').click()
|
22 |
+
|
23 |
+
sleep(1)
|
24 |
+
|
25 |
+
try:
|
26 |
+
if self.driver.find_element_by_class_name("statuslog").text != None:
|
27 |
+
print('connected ....!')
|
28 |
+
except:
|
29 |
+
sleep(0.5)
|
30 |
+
pass
|
31 |
+
self.screen = 0
|
32 |
+
|
33 |
+
def getChat(self):
|
34 |
+
r = []
|
35 |
+
|
36 |
+
while True:
|
37 |
+
try:
|
38 |
+
texts = self.driver.find_elements_by_xpath("//p[@class='strangermsg']")
|
39 |
+
|
40 |
+
for x in texts:
|
41 |
+
# print(x.text)
|
42 |
+
r.append(x.text)
|
43 |
+
break
|
44 |
+
except:
|
45 |
+
sleep(1)
|
46 |
+
|
47 |
+
return r
|
48 |
+
|
49 |
+
def sendChat(self, key = 'hello !'):
|
50 |
+
try:
|
51 |
+
send = self.driver.find_element_by_class_name('chatmsg')
|
52 |
+
send.send_keys(key)
|
53 |
+
send.send_keys(Keys.RETURN)
|
54 |
+
except:
|
55 |
+
print('fail')
|
56 |
+
pass
|
57 |
+
return
|
58 |
+
|
59 |
+
def newChat(self):
|
60 |
+
try:
|
61 |
+
dis = self.driver.find_element_by_xpath("//button[@class='disconnectbtn']")
|
62 |
+
dis.click()
|
63 |
+
dis.click()
|
64 |
+
dis.click()
|
65 |
+
except:
|
66 |
+
print('failed exiting !')
|
67 |
+
|
68 |
+
def checkChat(self):
|
69 |
+
try:
|
70 |
+
new = self.driver.find_element_by_class_name("newchatbtnwrapper")
|
71 |
+
dis = self.driver.find_element_by_xpath("//button[@class='disconnectbtn']")
|
72 |
+
self.driver.save_screenshot(f'./omg/screenie{self.screen}.png')
|
73 |
+
self.screen += 1
|
74 |
+
dis.click()
|
75 |
+
print('new chat !')
|
76 |
+
return True
|
77 |
+
except:
|
78 |
+
# print('failed new chat')
|
79 |
+
pass
|
80 |
+
return False
|
81 |
+
|
82 |
+
def reChat(self):
|
83 |
+
try:
|
84 |
+
self.driver.find_element_by_class_name("recaptcha-checkbox-border").click()
|
85 |
+
except:
|
86 |
+
print('failed recapta')
|
87 |
+
|
88 |
+
interests = ['NY', 'italy', 'movies', 'justin beiber', 'netflix', 'money hiest', 'iron man', 'marvel','cap','india','mumbai']
|
89 |
+
omg = omegle(interests = interests, chromedriver = './chromedriver')
|
90 |
+
|
91 |
+
|
92 |
+
|
93 |
+
from chatt import Tron
|
94 |
+
|
95 |
+
tron = Tron()
|
96 |
+
|
97 |
+
r,s = [0,0]
|
98 |
+
o = 0
|
99 |
+
while True:
|
100 |
+
|
101 |
+
if r == 0 and s == 0:
|
102 |
+
s += 1
|
103 |
+
omg.sendChat()
|
104 |
+
|
105 |
+
sleep(1)
|
106 |
+
|
107 |
+
rl = omg.getChat()
|
108 |
+
|
109 |
+
if len(rl) > o:
|
110 |
+
|
111 |
+
try:
|
112 |
+
text = rl[-1]
|
113 |
+
r+=1
|
114 |
+
except:
|
115 |
+
r = 0
|
116 |
+
s = 0
|
117 |
+
sleep(1)
|
118 |
+
continue
|
119 |
+
o = len(rl)
|
120 |
+
|
121 |
+
text = list(text.split(':'))
|
122 |
+
text = text[-1]
|
123 |
+
print("stranger : ",text)
|
124 |
+
st = tron.reply(text)
|
125 |
+
st = str(st)
|
126 |
+
print(st)
|
127 |
+
omg.sendChat(key = st)
|
128 |
+
s += 1
|
129 |
+
|
130 |
+
print(f"sent : {s}, recieved : {r}, lenr : {len(rl)}, o : {o}")
|
131 |
+
status = omg.checkChat()
|
132 |
+
|
133 |
+
if status:
|
134 |
+
s,r,o = 0,0,0
|
chatt.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from chatterbot import ChatBot
|
2 |
+
from chatterbot.trainers import ChatterBotCorpusTrainer
|
3 |
+
# from chatterbot.trainers import UbuntuCorpusTrainer
|
4 |
+
|
5 |
+
# bot = ChatBot('Norman')
|
6 |
+
class Tron():
|
7 |
+
def __init__(self):
|
8 |
+
|
9 |
+
self.bot = ChatBot(
|
10 |
+
'Norman',
|
11 |
+
storage_adapter='chatterbot.storage.SQLStorageAdapter',
|
12 |
+
logic_adapters=['chatterbot.logic.MathematicalEvaluation','chatterbot.logic.BestMatch'],
|
13 |
+
database_uri='sqlite:///database.sqlite3'
|
14 |
+
)
|
15 |
+
|
16 |
+
trainer = ChatterBotCorpusTrainer(self.bot)
|
17 |
+
trainer.train("chatterbot.corpus.english")
|
18 |
+
trainer.train("chatterbot.corpus.english.greetings")
|
19 |
+
trainer.train("chatterbot.corpus.english.conversations")
|
20 |
+
|
21 |
+
# trainer = UbuntuCorpusTrainer(bot)
|
22 |
+
# trainer.train()
|
23 |
+
|
24 |
+
def reply(self, msg):
|
25 |
+
if msg:
|
26 |
+
bot_out = self.bot.get_response(msg)
|
27 |
+
return bot_out
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
# agent = Tron()
|
32 |
+
# while True:
|
33 |
+
# inp = input("mark here.")
|
34 |
+
# t = agent.reply(inp)
|
35 |
+
# print(t,type(t))
|
36 |
+
# s = str(t)
|
37 |
+
# p = string(t)
|
38 |
+
# print(s, type(s),type(p))
|
39 |
+
|
40 |
+
|
chromedriver
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:722ae377fcf03cb8e26f65ae51ea5ded9257e299fc6e7f502e85eae9aad0f69d
|
3 |
+
size 10251496
|