Merge branch 'master' into 'master'

Smoke Weed Everyday

See merge request !9
This commit is contained in:
mrhanky 2017-09-05 20:02:59 +00:00
commit eefae51ad2
3 changed files with 137 additions and 0 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ __pycache__
/.env /.env
/env /env
.idea/ .idea/
*.swp

View File

@ -33,6 +33,8 @@ cp nxy/files/{.env,config.json} .
vim .env config.json vim .env config.json
``` ```
## Running as Service
Enable linger for the bot user (so it starts at boot and keeps running), install and activate systemd unit: Enable linger for the bot user (so it starts at boot and keeps running), install and activate systemd unit:
```sh ```sh
sudo loginctl enable-linger nxy sudo loginctl enable-linger nxy
@ -46,3 +48,23 @@ Install and activate timer for database dumps:
ln -fs $HOME/nxy/files/nxy-db-dump.{timer,service} $HOME/.config/systemd/user ln -fs $HOME/nxy/files/nxy-db-dump.{timer,service} $HOME/.config/systemd/user
systemctl --user enable --now nxy-db-dump.timer systemctl --user enable --now nxy-db-dump.timer
``` ```
## Running as Standalone in Development Mode
For development set the BOT_DEV variable:
```
export BOT_DEV=
```
Then add the current git repository to your python path:
```
export PYTHONPATH=<git repository>:$PYTHONPATH
```
Finally run nxy:
```
python3 -m bot
```

114
bot/dope.py Normal file
View File

@ -0,0 +1,114 @@
# -*- coding: utf-8 -*-
import random
import irc3
from docopt import Dict
from irc3.plugins.command import command
from irc3.utils import IrcString
from . import Plugin
class Dope(Plugin):
# All strains from https://www.leafly.com/explore
STRAINS = {
'sativa': [
'Sour Diesel',
'Green Crack',
'Jack Herer',
'Durban Poison',
'Lemon Haze',
'Strawberry Cough',
'Super Silver Haze',
'Alaskan Thunder Fuck',
'Super Lemon Haze',
'Amnesia Haze',
'Maui Wowie',
'Chocolope',
'Harlequin',
],
'indica': [
'Granddaddy Purple',
'Bubba Kush',
'Northern Lights',
'Blue Cheese',
'Purple Kush',
'Blueberry',
'Grape Ape',
'Blackberry Kush',
'Master Kush',
'God\'s Gift',
'LA Confidential',
'Death Star',
'Purple Urkle',
'Afghan Kush',
'Skywalker',
'White Rhino',
'Hindu Kush',
],
'hybrid': [
'Blue Dream',
'Girl Scout Cookies',
'OG Kush',
'White Widow',
'Gorilla Glue #4',
'Pineapple Express',
'Trainwreck',
'AK-47',
'Headband',
'Chemdawg',
'Cheese',
'Cherry Pie',
'Skywalker OG',
'Tahoe OG Kush',
'Lemon Kush',
'Platinum Girl Scout Cookies',
'Golden Goat',
'Agent Orange',
],
}
ACTIONS = {
'joint': [
('passes', 'to'),
('rolls', 'for'),
('lights', 'for'),
],
'bong': [
('passes', 'to'),
('preps', 'for'),
('lights', 'for'),
],
'vape': [
('passes', 'to'),
],
'blunt': [
('passes', 'to'),
('rolls', 'for'),
('lights', 'for'),
],
}
@command
def dope(self, mask: IrcString, target: IrcString, args: Dict):
"""Smoke weed everyday
%%dope [<nick>]
"""
strain_types = list(self.STRAINS.keys())
strain_type = random.choice(strain_types)
strain = random.choice(self.STRAINS[strain_type])
consume_type = random.choice(list(self.ACTIONS.keys()))
action = random.choice(self.ACTIONS[consume_type])
nick = args.get('<nick>', mask.nick)
self.bot.action(target, '{action0} a {consume_type} of the finest {strain_type} "{strain}" {action1} {nick}'.format(
action0=action[0],
action1=action[1],
consume_type=consume_type,
strain_type=strain_type,
strain=strain,
nick=nick))