Skip to content

Commit d0078aa

Browse files
committed
initial commit
0 parents  commit d0078aa

File tree

393 files changed

+208888
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

393 files changed

+208888
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/.env

.idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/hed_dictionary.iml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vscode/launch.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Current File",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal"
13+
}
14+
]
15+
}

.vscode/settings.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"python.linting.pylintEnabled": false,
3+
"python.linting.enabled": false,
4+
"python.linting.flake8Enabled": true,
5+
"python.linting.pydocstyleEnabled": false,
6+
"python.linting.mypyEnabled": false,
7+
"python.linting.prospectorEnabled": false,
8+
"python.linting.pycodestyleEnabled": false,
9+
"python.linting.pylamaEnabled": false
10+
}

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
worker: python dictionary_bot.py

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Sze_Yap_bot
2+
3+
Sze Yap Bot is a dictionary bot which searches Stephen Li's Taishanese Dictionary and Gene Chin's Hoisanva English dictionary!
4+
5+
Sze Yap Bot is feature rich with advanced searching for both english and chinese words and phrases.
6+
You can also join a voice channel to listen to audio from Stephen Li's dictionary and listen to taishanese words being read!
7+
8+
Features:
9+
10+
* Search english and chinese words in both Stephen Li and Gene Chin's dictionaries
11+
* Intuitive and easy to use search navigation system
12+
* Chinese character to pinyin
13+
* Pronounciation audio
14+
* Customizable welcome message with optional chinese title!
15+
16+
Sze Yap Bot is actively being developed so expect more features to come!
23.9 KB
Binary file not shown.

__pycache__/embed.cpython-38.pyc

3.29 KB
Binary file not shown.

__pycache__/hed.cpython-38.pyc

6.91 KB
Binary file not shown.

__pycache__/helpfxn.cpython-38.pyc

762 Bytes
Binary file not shown.

__pycache__/synonym.cpython-38.pyc

1.31 KB
Binary file not shown.

__pycache__/thumbnail.cpython-38.pyc

3.21 KB
Binary file not shown.

requirements.txt

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
aiohttp==3.7.4.post0
2+
async-timeout==3.0.1
3+
attrs==21.2.0
4+
beautifulsoup4==4.9.3
5+
bs4==0.0.1
6+
cachetools==4.2.2
7+
certifi==2020.12.5
8+
cffi==1.14.5
9+
chardet==3.0.4
10+
click==8.0.1
11+
colorama==0.4.4
12+
discord==1.0.1
13+
discord.py==1.7.2
14+
ffmpeg-progress-yield==0.0.4
15+
flake8==3.9.2
16+
futures==3.1.1
17+
google-api-core==1.28.0
18+
google-api-python-client==2.5.0
19+
google-auth==1.30.1
20+
google-auth-httplib2==0.1.0
21+
google-auth-oauthlib==0.4.4
22+
googleapis-common-protos==1.53.0
23+
googletrans==3.0.0
24+
goslate==1.5.1
25+
h11==0.9.0
26+
h2==3.2.0
27+
hpack==3.0.0
28+
hstspreload==2020.12.22
29+
httpcore==0.9.1
30+
httplib2==0.19.1
31+
httpx==0.13.3
32+
hyperframe==5.2.0
33+
idna==2.10
34+
mccabe==0.6.1
35+
multidict==5.1.0
36+
mutagen==1.45.1
37+
numpy==1.19.3
38+
oauthlib==3.1.0
39+
packaging==20.9
40+
pandas==1.2.4
41+
Pillow==8.2.0
42+
protobuf==3.17.1
43+
pyasn1==0.4.8
44+
pyasn1-modules==0.2.8
45+
pycodestyle==2.7.0
46+
pycparser==2.20
47+
PyDictionary==2.0.1
48+
pydub==0.25.1
49+
pyflakes==2.3.1
50+
PyNaCl==1.4.0
51+
pynormalize==0.1.4
52+
pyparsing==2.4.7
53+
python-dateutil==2.8.1
54+
python-dotenv==0.17.1
55+
pytz==2021.1
56+
requests==2.25.1
57+
requests-oauthlib==1.3.0
58+
rfc3986==1.5.0
59+
rsa==4.7.2
60+
six==1.16.0
61+
sniffio==1.2.0
62+
soupsieve==2.2.1
63+
tqdm==4.60.0
64+
typing-extensions==3.10.0.0
65+
Unidecode==1.2.0
66+
uritemplate==3.0.1
67+
urllib3==1.26.4
68+
yarl==1.6.3

src/HED Alphabetical 20200622.csv

+80,568
Large diffs are not rendered by default.

src/canto_freq_list.csv

+44,436
Large diffs are not rendered by default.

src/cat_404.jpg

13.5 KB
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.
2.15 KB
Binary file not shown.
Binary file not shown.
1.19 KB
Binary file not shown.
10.9 KB
Binary file not shown.

src/cogs/command_count.py

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
from embed import EmbedList, add_to_master
2+
from discord.ext import commands
3+
import discord
4+
from os.path import join, dirname
5+
from cogs.jsonfxn import open_datajson, save_json
6+
7+
8+
emoji_list = ('⬅️', '➡️', '🔊', '⬇️', '⬆️', '📚')
9+
filepath = dirname(__file__)
10+
11+
class CommandCount(commands.Cog):
12+
13+
def __init__(self, client):
14+
self.client = client
15+
16+
@commands.command()
17+
async def count(self, ctx):
18+
embed_list = EmbedList(message_id=None, type_id=8)
19+
if isinstance(ctx.channel, discord.DMChannel):
20+
guild_id = 'dm'
21+
else:
22+
guild_id = str(ctx.guild.id)
23+
data = open_datajson('data.json', guild_id)[str(ctx.guild.id)]['command_count']
24+
try:
25+
for command in data.items():
26+
text = f'***{command[0]}***\n```'
27+
for channel in command[1].items():
28+
if ctx.guild is not None or ctx.channel.id == int(channel[0]):
29+
text += f'{self.client.get_channel(int(channel[0])).name} -'\
30+
f' {channel[1]}\n'
31+
embed = discord.Embed(
32+
title=f"Commands for {ctx.guild.name}",
33+
description=text + '```')
34+
embed_list.add_page(embed, audio=[], link=[])
35+
except KeyError:
36+
return
37+
sent_embed = await ctx.send(embed=embed_list.first_page())
38+
add_to_master(embed_list, sent_embed)
39+
for emoji in emoji_list[:2]:
40+
await sent_embed.add_reaction(emoji)
41+
42+
43+
@commands.Cog.listener()
44+
async def on_command(self, ctx):
45+
channel = ctx.channel
46+
if channel is None:
47+
return
48+
elif isinstance(channel, discord.DMChannel):
49+
guild_id = "dm"
50+
else:
51+
guild_id = str(ctx.guild.id)
52+
channel_id = str(channel.id)
53+
command = ctx.command.name
54+
55+
data = open_datajson('data.json', guild_id)
56+
com_count = data[guild_id]['command_count']
57+
try:
58+
if command not in com_count:
59+
com_count[command] = {}
60+
if channel_id not in com_count[command]:
61+
com_count[command][channel_id] = 1
62+
else:
63+
com_count[command][channel_id] += 1
64+
65+
except KeyError:
66+
return
67+
68+
data[guild_id]['command_count'] = com_count
69+
save_json('data.json', data)
70+
71+
72+
73+
def setup(client):
74+
client.add_cog(CommandCount(client))

src/cogs/command_prefix.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from discord.ext import commands
2+
import json
3+
import os
4+
5+
json_path = os.path.join(os.path.dirname(__file__), 'prefixes.json')
6+
7+
8+
class InitializeCommandPrefix(commands.Cog):
9+
10+
def __init__(self, client):
11+
self.client = client
12+
13+
@commands.Cog.listener()
14+
async def on_guild_join(self, guild):
15+
with open(json_path, 'r') as f:
16+
prefixes = json.load(f)
17+
prefixes[str(guild.id)] = '+'
18+
with open(json_path, 'w') as f:
19+
json.dump(prefixes, f, indent=4)
20+
try:
21+
await guild.system_channel.send(
22+
"Thanks for adding me to this server! You can use the command "
23+
"+help to find out some help commands!")
24+
except:
25+
pass
26+
27+
@commands.Cog.listener()
28+
async def on_guild_remove(self, guild):
29+
with open(json_path, 'r') as f:
30+
prefixes = json.load(f)
31+
prefixes.pop(str(guild.id))
32+
with open(json_path, 'w') as f:
33+
json.dump(prefixes, f, indent=4)
34+
35+
@commands.command(aliases=['changeprefix', 'prefixset', 'prefixchange'])
36+
@commands.has_permissions(administrator=True)
37+
async def setprefix(self, ctx, prefix):
38+
with open(json_path, 'r') as f:
39+
prefixes = json.load(f)
40+
prefixes[str(ctx.guild.id)] = prefix
41+
with open(json_path, 'w') as f:
42+
json.dump(prefixes, f, indent=4)
43+
44+
await ctx.send(f'Successfully changed the prefix to: **``{prefix}``**')
45+
46+
47+
def setup(client):
48+
client.add_cog(InitializeCommandPrefix(client))

src/cogs/easter_eggs/gummy_bear.mp3

255 KB
Binary file not shown.

src/cogs/easter_eggs/meow.mp3

330 KB
Binary file not shown.

src/cogs/easter_eggs/pig.mp3

406 KB
Binary file not shown.

src/cogs/easteregg.py

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
from discord.ext import commands
2+
from discord.utils import get
3+
from discord.player import FFmpegPCMAudio
4+
import os
5+
from asyncio import sleep
6+
import json
7+
8+
path = os.path.dirname(__file__)
9+
10+
async def play_egg(self, ctx, type_: str):
11+
if type_ == 'gummybear':
12+
file = os.path.join(path, 'easter_eggs', 'gummy_bear.mp3')
13+
elif type_ == 'pig':
14+
file = os.path.join(path, 'easter_eggs', 'pig.mp3')
15+
elif type_ == 'meow':
16+
file = os.path.join(path, 'easter_eggs', 'meow.mp3')
17+
18+
if not ctx.author.voice:
19+
return
20+
channel = ctx.author.voice.channel
21+
voice = get(self.client.voice_clients, guild=ctx.guild)
22+
23+
if voice is not None:
24+
if voice.channel != ctx.author.voice.channel:
25+
voice = await voice.move_to(ctx.author.voice.channel)
26+
else:
27+
permissions = channel.permissions_for(ctx.guild.me)
28+
if permissions.connect:
29+
voice = await channel.connect()
30+
else:
31+
permissions = ctx.channel.permissions_for(ctx.guild.me)
32+
if permissions.send_messages:
33+
await ctx.send("Sorry, I can't seem to connect to the vc")
34+
else:
35+
await ctx.author.send(
36+
"Sorry, I can't seem to connect to the vc "
37+
f"or even type in ur channel! "
38+
f"What kind of permissions are these?")
39+
return
40+
41+
source = FFmpegPCMAudio(file)
42+
voice.play(source)
43+
await sleep(8)
44+
await voice.disconnect()
45+
46+
47+
class EasterEgg(commands.Cog):
48+
def __init__(self, client):
49+
self.client = client
50+
51+
@commands.command()
52+
async def gummybear(self, ctx):
53+
await play_egg(self, ctx, 'gummybear')
54+
55+
@commands.command()
56+
async def pig(self, ctx):
57+
await play_egg(self, ctx, 'pig')
58+
59+
@commands.command()
60+
async def meow(self, ctx):
61+
await play_egg(self, ctx, 'meow')
62+
63+
64+
def setup(client):
65+
client.add_cog(EasterEgg(client))
66+
67+
68+
69+
70+

0 commit comments

Comments
 (0)