Skip to content

Commit 6e9e223

Browse files
committed
Merge from "master"
2 parents a87604b + 2e42e7e commit 6e9e223

File tree

6 files changed

+51
-44
lines changed

6 files changed

+51
-44
lines changed

README.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,15 @@ When a user sends a direct message to the bot, a channel is created within an is
4444

4545
## Installation
4646

47-
You have two options for using this bot, host on Heroku or self-host the bot. If you choose to install the bot using Heroku, you will not need to download anything. Read the **[installation guide](https://github.com/kyb3r/modmail/wiki/Installation)** or watch the **[video tutorial](https://youtu.be/TH_1QfKUl_k)**. If you ran into any problems, join our [discord server](https://discord.gg/etJNHCQ) for help and support. Even if you don't have any issues, you should come and check out our awesome Discord community! :wink:
47+
You have two options for using this bot, host on Heroku or self-host the bot. If you choose to install the bot using Heroku, you will not need to download anything. Read the **[installation guide](https://github.com/kyb3r/modmail/wiki/Installation)**. If you ran into any problems, join our [discord server](https://discord.gg/etJNHCQ) for help and support. Even if you don't have any issues, you should come and check out our awesome Discord community! :wink:
4848

4949
## What is Heroku?
5050

51-
Heroku is a container based cloud platform that currently offers a free plan to host web apps. However, these apps have an ephemeral file system and thus cannot store any data on site. We have made Modmail be accessible to anyone while still being feature-rich; it's a community run project that lets anyone get it up and running 24/7 for free. So how does our bot store data? Configs and logs are stored in a [centralized web service](https://modmail.tk) hosted by us. This enables you to get started easily and fast.
52-
53-
## Self-hosted logs
54-
55-
If you want complete control over your data and do not want to use the centralized API service, you can self-host your logs. We recommend this if you want stability and security for your bot. You can do this by adding two config variables:
56-
57-
* `MONGO_URI` - MongoDB connection URI, you can get a free 500 MB cluster from [MongoDB Atlas](https://www.mongodb.com/cloud/atlas).
58-
* `LOG_URL` - The URL of your log viewer Heroku app (`https://yourlogviewerappname.herokuapp.com`)
59-
60-
Optionally if you want autoupdates (bot syncs your fork with origin) you can add another config var:
61-
* `GITHUB_ACCESS_TOKEN` - Personal access token you can get from your GitHub developer settings.
62-
63-
You also need to create a separate Heroku app for the log viewer that you can deploy from [here](https://github.com/kyb3r/logviewer).
51+
Heroku is a container based cloud platform that currently offers a free plan to host web apps. However, these apps have an ephemeral file system and thus cannot store any data on site. We have made Modmail be accessible to anyone while still being feature-rich; it's a community run project that lets anyone get it up and running 24/7 for free. So how does our bot store data? Configs and logs are stored in a [centralized web service](https://modmail.tk) hosted by us. This enables you to get started easily and fast. However, you do also have the option to self-host your data, check the installation guide for more info.
6452

6553
## Features and Commands
6654
The bot comes with a plethora of useful functionality. Take a look at the [list of commands](https://github.com/kyb3r/modmail/wiki/Features-and-commands).
6755

68-
6956
### Automatic Updates
7057
The bot checks for new updates every hour and automatically updates to a newer version if found. This bot is under active development so you can always look forward to new, useful features! If you do not want this functionality, for example, if you want to make changes to your fork, you can do so by adding a `disable_autoupdates` config variable.
7158

app.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,20 @@
1212
"required": true
1313
},
1414
"OWNERS": {
15-
"description": "Comma separated user IDs of people that are allowed to use owner only commands. (eval and update)",
15+
"description": "Comma separated user IDs of people that are allowed to use owner only commands. (eval and update).",
1616
"required": true
1717
},
1818
"MODMAIL_API_TOKEN": {
19-
"description": "API token from https://modmail.tk",
20-
"required": true
19+
"description": "API token from https://modmail.tk.",
20+
"required": false
21+
},
22+
"MONGO_URI": {
23+
"description": "Mongo DB connection URI for self-hosting your data.",
24+
"required": false
25+
},
26+
"LOG_URL": {
27+
"description": "The url of the log viewer app for viewing self-hosted logs.",
28+
"required": false
2129
}
2230
}
2331
}

bot.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@
3535
from datetime import datetime
3636
from types import SimpleNamespace
3737

38+
import uvloop
3839
from aiohttp import ClientSession
3940
from motor.motor_asyncio import AsyncIOMotorClient
40-
from colorama import init, Fore, Style
41+
import colorama
42+
from colorama import Fore, Style
4143
from emoji import UNICODE_EMOJI
4244

4345
from core.clients import Github, ModmailApiClient, SelfHostedClient
@@ -46,7 +48,7 @@
4648
from core.changelog import ChangeLog
4749

4850

49-
init()
51+
colorama.init()
5052

5153
line = Fore.BLACK + Style.BRIGHT + '-------------------------' + \
5254
Style.RESET_ALL
@@ -594,5 +596,6 @@ def uptime(self):
594596

595597

596598
if __name__ == '__main__':
599+
uvloop.install()
597600
bot = ModmailBot()
598601
bot.run()

cogs/utility.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ async def changelog(self, ctx):
180180
@trigger_typing
181181
async def about(self, ctx):
182182
"""Shows information about the bot."""
183-
em = Embed(color=0x36393F,
183+
em = Embed(color=Color.blurple(),
184184
timestamp=datetime.utcnow())
185185
em.set_author(name='Modmail - About',
186186
icon_url=self.bot.user.avatar_url)
@@ -295,7 +295,7 @@ async def update(self, ctx):
295295
for name, value in latest.fields.items():
296296
em.add_field(name=name, value=value)
297297
# TODO: message unused?
298-
message = commit_data['commit']['message']
298+
# message = commit_data['commit']['message']
299299
html_url = commit_data["html_url"]
300300
short_sha = commit_data['sha'][:6]
301301
em.add_field(name='Merge Commit',
@@ -367,7 +367,7 @@ async def ping(self, ctx):
367367
em = Embed(
368368
title='Pong! Websocket Latency:',
369369
description=f'{self.bot.ws.latency * 1000:.4f} ms',
370-
color=0x00FF00
370+
color=Color.blurple()
371371
)
372372
return await ctx.send(embed=em)
373373

core/thread.py

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,15 @@ async def send(self, message, destination=None,
250250

251251
em = discord.Embed(
252252
description=message.content,
253-
# timestamp=message.created_at
253+
timestamp=message.created_at
254254
)
255255

256256
system_avatar_url = 'https://discordapp.com/assets/' \
257257
'f78426a064bc9dd24847519259bc42af.png'
258258

259259
# store message id in hidden url
260260
if not note:
261-
em.set_author(name=author.name,
261+
em.set_author(name=author,
262262
icon_url=author.avatar_url,
263263
url=message.jump_url)
264264
else:
@@ -322,9 +322,11 @@ def is_image_url(u, _):
322322

323323
if from_mod:
324324
em.color = self.bot.mod_color
325+
em.set_footer(text=f'Moderator')
325326
elif note:
326327
em.color = discord.Color.blurple()
327328
else:
329+
em.set_footer(text=f'Recipient')
328330
em.color = self.bot.recipient_color
329331

330332
await destination.trigger_typing()
@@ -450,11 +452,11 @@ async def create(self, recipient, *, creator=None, category=None):
450452
em = discord.Embed(
451453
color=self.bot.mod_color,
452454
description=thread_creation_response,
453-
title='Thread Created',
454455
timestamp=datetime.utcnow(),
455456
)
456457
em.set_footer(text='Your message has been sent',
457458
icon_url=self.bot.guild.icon_url)
459+
em.set_author(name='Thread Created')
458460

459461
if creator is None:
460462
self.bot.loop.create_task(recipient.send(embed=em))
@@ -566,14 +568,8 @@ def _format_info_embed(self, user, creator, log_url, log_count, dc):
566568
member = self.bot.guild.get_member(user.id)
567569
avi = user.avatar_url
568570
time = datetime.utcnow()
569-
if creator:
570-
desc = f'{creator.mention} has created ' \
571-
f'a thread with {user.mention}'
572-
else:
573-
desc = f'{user.mention} has started a thread'
574571

575-
key = log_url.split('/')[-1]
576-
desc = f'{desc} [`{key}`]({log_url})'
572+
# key = log_url.split('/')[-1]
577573

578574
role_names = ''
579575
if member:
@@ -586,30 +582,42 @@ def _format_info_embed(self, user, creator, log_url, log_count, dc):
586582
role_names = ' '.join(r.mention for r in roles
587583
if r.name != "@everyone")
588584

589-
em = discord.Embed(colour=dc, description=desc, timestamp=time)
585+
em = discord.Embed(colour=dc, description=user.mention, timestamp=time)
590586

591587
def days(d):
592-
return ' day ago.' if d == '1' else ' days ago.'
588+
if d == '0':
589+
return '**today**'
590+
return f'{d} day ago' if d == '1' else f'{d} days ago'
593591

594592
created = str((time - user.created_at).days)
595-
# em.add_field(name='Mention', value=user.mention)
596-
em.add_field(name='Registered', value=created + days(created))
593+
# if not role_names:
594+
# em.add_field(name='Mention', value=user.mention)
595+
# em.add_field(name='Registered', value=created + days(created))
596+
em.description += f' was created {days(created)}'
597+
597598
footer = 'User ID: ' + str(user.id)
598599
em.set_footer(text=footer)
599-
em.set_author(name=str(user), icon_url=avi)
600-
em.set_thumbnail(url=avi)
600+
em.set_author(name=str(user), icon_url=avi, url=log_url)
601+
# em.set_thumbnail(url=avi)
601602

602603
if member:
603-
if log_count:
604-
em.add_field(name='Past logs', value=f'{log_count}')
605604
joined = str((time - member.joined_at).days)
606-
em.add_field(name='Joined', value=joined + days(joined))
605+
# em.add_field(name='Joined', value=joined + days(joined))
606+
em.description += f', joined {days(joined)}'
607+
607608
if member.nick:
608609
em.add_field(name='Nickname', value=member.nick, inline=True)
609610
if role_names:
610-
em.add_field(name='Roles', value=role_names, inline=False)
611+
em.add_field(name='Roles', value=role_names, inline=True)
611612
else:
612613
em.set_footer(text=f'{footer} | Note: this member'
613614
' is not part of this server.')
614615

616+
if log_count:
617+
# em.add_field(name='Past logs', value=f'{log_count}')
618+
t = 'thread' if log_count == 1 else 'threads'
619+
em.description += f" with **{log_count}** past {t}."
620+
else:
621+
em.description += '.'
622+
615623
return em

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ motor==2.0.0
1212
sanic==18.12.0
1313
dnspython==1.16.0
1414
aiohttp==3.4.4
15-
pymongo==3.7.2
15+
pymongo==3.7.2
16+
uvloop==0.12.0

0 commit comments

Comments
 (0)