Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #75 from agraubert/story
Browse files Browse the repository at this point in the history
Story overhaul
  • Loading branch information
agraubert authored Mar 1, 2018
2 parents 193c794 + 6068fce commit 4639247
Show file tree
Hide file tree
Showing 12 changed files with 1,821 additions and 814 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
dfrotz
games/
textplayer/
git.token
token.txt
_token.txt
permissions.yml
Expand Down
13 changes: 12 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,18 @@ don't know what a shell is, you're going to have a bad time
rule), the fallback behavior is to allow the command if it is not an
**Underscore Command**. This is the lowest priority behavior, so it can be
overridden by any rule, including `defaults`.
4. Connect your bot to your **Server**
4. Get extras
1. If you plan on using the story/text game system, you'll need to get a few things first:
* dfrotz (put `dfrotz` in the same directory as `main.py`):
```bash
$ git clone https://github.com/DavidGriffith/frotz.git
$ cd frotz
$ make dumb
```
* Some `.z5` games (put them in a folder called `games` in the same directory
as `main.py`)
* You can get a good starter pack from [textplayer](https://github.com/danielricks/textplayer)
5. Connect your bot to your **Server**
1. At this point, your bot is configured and ready to work. Go back to the
[Discord Developers page](https://discordapp.com/developers/) from step 2.1
and navigate to your bot
Expand Down
50 changes: 25 additions & 25 deletions bots/birthday.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .core import CoreBot
from .utils import load_db, save_db
from .utils import Database
import asyncio
import re
import datetime
Expand All @@ -22,33 +22,33 @@ async def cmd_birthday(self, message, content):
)
else:
result = re.match(r'(\d{1,2})/(\d{1,2})/(\d{4})', content[1])
birthdays = load_db('birthdays.json')
birthdays[message.author.id] = {
'month': int(result.group(1)),
'day': int(result.group(2)),
'year': int(result.group(3))
}
await self.send_message(
message.channel,
"Okay, I'll remember that"
)
save_db(birthdays, 'birthdays.json')
async with Database('birthdays.json') as birthdays:
birthdays[message.author.id] = {
'month': int(result.group(1)),
'day': int(result.group(2)),
'year': int(result.group(3))
}
await self.send_message(
message.channel,
"Okay, I'll remember that"
)
birthdays.save()

@bot.add_task(43200) #12 hours
async def check_birthday(self):
birthdays = load_db('birthdays.json')
today = datetime.date.today()
for uid, data in birthdays.items():
month = data['month']
day = data['day']
if today.day == day and today.month == month:
await self.send_message(
self.fetch_channel('general'),
"@everyone congratulate %s, for today is their birthday!"
" They are %d!" % (
self.users[uid]['mention'] if uid in self.users else "someone",
today.year - data['year']
async with Database('birthdays.json') as birthdays:
today = datetime.date.today()
for uid, data in birthdays.items():
month = data['month']
day = data['day']
if today.day == day and today.month == month:
await self.send_message(
self.fetch_channel('general'),
"@everyone congratulate %s, for today is their birthday!"
" They are %d!" % (
self.users[uid]['mention'] if uid in self.users else "someone",
today.year - data['year']
)
)
)

return bot
Loading

0 comments on commit 4639247

Please sign in to comment.