Skip to content
Permalink
Browse files
fix merge
  • Loading branch information
veleva committed Nov 29, 2018
2 parents 7b40016 + 687ef61 commit d3ac96c6845c4df4c279e89f876942f9b22a43bc
Show file tree
Hide file tree
Showing 24 changed files with 1,030 additions and 306 deletions.
@@ -6,10 +6,17 @@
/._pycache_
/kopia
/TextExtracts
/seq2seq
/py-googletrans
/BOT
/botsfloor
/nlp


names.json

names.json
names.pck
brain.pck

### Linux ###
*~
@@ -0,0 +1,25 @@
import requests
ui_bitcoin = ["bitcoin", "bitcoin price"]
ui_gold = ["gold", "gold price"]
bye = ["bye", "goodbye", ""]


def ui(enter):
for word in ui_bitcoin:
if enter.lower().strip() == word.lower().strip():
bit = requests.get('https://api.coindesk.com/v1/bpi/currentprice.json')
print ('₤' + bit.json()['bpi']['GBP']['rate'] + " For 1 BTC")
return bit
for worn in ui_gold:
if enter.lower().strip() == word.lower().strip():
gold = requests.get('http://gold-feed.com/paid/d7d6s6d66k4j4658e6d6cds638940e/all_metals_json_usd.php')
print ('₤' + (gold.json()['gold_londonfix_pm']) + " Per 10 grams of 14K gold")
for word in bye:
if enter.lower().strip() == word.lower().strip():
gbye = ("Thank you for using our service!")
print(gbye)
exit()
return gbye

while True:
ui(input("Please enter Bitcoin or Gold: "))
@@ -1,31 +1,31 @@
import discord
import webbrowser
import nltk
import random
from discord.ext import commands
import asyncio

TOKEN = 'NTA3NjMyNDUwMzkwODUxNTg1.Drzsew.lVbUm7WKIPrV56q_9LegdqZuXZo'

client = commands.Bot(command_prefix = '?')

@client.event
async def on_ready():
print('"BOT ON DUTY"')

@client.command
async def test(ctx):
await ctx.send('I heard you! {0}'.format(ctx.author))

@client.event
async def message(message):

if message.author.id == client.user.id:
return

if message.content.lower().startswith ('!math'):




client.run(TOKEN)
import discord
import webbrowser
import nltk
import random
from discord.ext import commands
import asyncio

TOKEN = 'NTA3NjMyNDUwMzkwODUxNTg1.Drzsew.lVbUm7WKIPrV56q_9LegdqZuXZo'

client = commands.Bot(command_prefix = '?')

@client.event
async def on_ready():
print('"BOT ON DUTY"')

@client.command
async def test(ctx):
await ctx.send('I heard you! {0}'.format(ctx.author))

@client.event
async def message(message):

if message.author.id == client.user.id:
return

if message.content.lower().startswith ('!math'):




client.run(TOKEN)
@@ -0,0 +1,60 @@
''' All codes in this file are extracted and editted from https://stackoverflow.com/questions/25798674/python-duplicate-words '''
def isRepeat(sentence):
words = sentence.split(" ")
words.sort() # ascending sorting

# keep user original input
words_copied = sentence.split(" ")
words_copied.sort()

wordL=[]
'''Copied codes to loop through the sentence given.'''
for word in words[0:len(words)-1]:
count = 0
while True:
try:
index = words_copied.index(word)
count += 1
del words_copied[index]
except ValueError:
if count > 1:
wordL.append([word,count])
break
'''Copied code ends'''
if wordL != []:
repeat=True
else:
repeat=False
return repeat

def CountRepeat(sentence):
words = sentence.split(" ")
words.sort() # ascending sorting

# keep user original input
words_copied = sentence.split(" ")
words_copied.sort()

wordL={}

for word in words[0:len(words)-1]:
count = 0
while True:
try:
index = words_copied.index(word)
count += 1
del words_copied[index]
except ValueError:
if count > 1:
wordL.update({word:count})
break
if wordL != []:
repeat=True
else:
repeat=False
return wordL
'''Debugger'''
#sentence=input('Enter your sentence : ')
#print(isRepeat(input()))
#print(CountRepeat(sentence))
'''Debugger ends'''
@@ -0,0 +1,44 @@
'''Data referenced from https://apps.worldwritable.com/tutorials/chatbot/ '''
# Sentences for responding the user
MyDictionary={
"GREETING_KEYWORDS":["hello", "hi", "greetings", "sup", "what's up"],
"GREETING_RESPONSES":["'sup bro", "hey", "*nods*", "hey you get my snap?"],
"REFUSE":["no","nah","not"],
"AGREE":["yes","sure","agreed","why not"],
"EMOTION_POSITIVE":["happy","thrilled","enjoyed","yo","high spirits"],
"EMOTION_NEGATIVE":["sad","blue","dissatisfied","heck","hell no"]
}
'''Referenced data ends here'''
def ref(category):
catName=[]
for j,k in MyDictionary.items(): #listing a whole dictionary
catName.append(j)
for i in catName:
if (category.upper()).strip() == i:
return i
if (category.upper()).strip() not in catName:
return False



'''Function checks if a value is in a specified dictionary'''
def isRef(word):
try:
for j,k in MyDictionary.items(): #listing a whole dictionary
for i in k: #looping through the dictionary
for p in word.split():
if (p.lower()).strip()==i:
return True
else:
continue
continue
continue
except:
print("Invalid input!")
print("Type of i: ",type(i),";type of p: ",type(p))
else:
return False
'''Debugger'''
#print(isRef(input("Test a word: ")))
#print(ref(input("Test a word: ")))
'''Debugger ends here'''
@@ -1,38 +1,18 @@
# Discord Chatbot
# Discord User's Assistant Chatbot

Multi-purpose discord chatbot for module 4006CEM - Oct/Nov 2018
Semi-intelligent discord chatbot for module 4006CEM - Oct/Nov 2018

Usage: `python3 connector.py`
Usage: python3 connector.py

Libraries being used:
- requests (http://docs.python-requests.org/en/master/) by Kenneth Reitz for web requests
- bs4 (https://www.crummy.com/software/BeautifulSoup/) by Leonard Richardson for parsing HTML pages
- discord.py (https://github.com/Rapptz/discord.py/) by Rapptz used to connect to Discord.
- selenium (https://docs.seleniumhq.org/) by (originally) Jason Huggins used to scrap pages that use javascript calls for data (translate module)
- googletrans(https://pypi.org/project/googletrans/) by SuHun Han used as Google Translate API

How to get god-forsaken Selenium to work:
(https://selenium-python.readthedocs.io/installation.html)

Step1. sudo python3 -m pip install selenium

Step2. download Driver for your browser (I chose Chrome, download links in the link above)

Step3. Set this part in your code to match your locations of: 1. Driver you've just downloaded, 2. Browser's exe location

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.binary_location = r"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
chrome_driver_binary = "/mnt/c/Users/your_username/chromedriver.exe"

Step4. When creating a driver, do it like this:

driver = webdriver.Chrome(chrome_driver_binary, chrome_options = chrome_options)

Step5. Pray to lord that it is working now




# Python 3.5 or 3.6 must be installed due to asynchronous functions
If you get an error (error 'NoneType' object has no attribute 'group') when using googletrans follow these instructions:
Step 1. pip uninstall googletrans
Step 2. clone https://github.com/BoseCorp/py-googletrans.git
Step 3. ./py-googletrans
Step 4. setup.py install
@@ -9,29 +9,36 @@ players = {'https://www.youtube.com/'}

TOKEN = 'NTA3NjMyNDUwMzkwODUxNTg1.Drzsew.lVbUm7WKIPrV56q_9LegdqZuXZo'

"""Code From The online disclord.py documentation"""
@client.event
async def on_ready():
await client.change_presence(game=discord.Game(name = 'Fortnite like a Boss'))
print ("BOT ONLINE")
""""""

"""Code From The online disclord.py documentation"""
@client.command(pass_context = True)
async def join(ctx):
channel = ctx.message.author.voice.voice_channel
await client.join_voice_channel(channel)

""""""

"""Code From The online disclord.py documentation"""
@client.command(pass_context = True)
async def leave(ctx):
server = ctx.message.server
voice_channel = client.vocemessage_in(server)
await voice_channel.disconnect()


""""""

"""Code by Lucas Kumara"""
@client.command(pass_context = True)
async def play(ctx, url):
server = ctx.message.server
client = client.voice_client_in(server)
player = await voice_client.create_ytdl_player(url)
players [server.id] = player
player.start()
""""""

client.run(TOKEN)

0 comments on commit d3ac96c

Please sign in to comment.