From 0d08503421e92acc07814c43d1132883c33a2369 Mon Sep 17 00:00:00 2001 From: Nils Schweinsberg Date: Tue, 5 Sep 2017 21:22:28 +0200 Subject: [PATCH 1/4] Add info on how to run in standalone development mode --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 9f557f0..e9d3ee2 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ cp nxy/files/{.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: ```sh 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 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=:$PYTHONPATH +``` + +Finally run nxy: + +``` +python3 -m bot +``` From 9a096ad455b891cfc294aa668e6feb66538b48de Mon Sep 17 00:00:00 2001 From: Nils Schweinsberg Date: Tue, 5 Sep 2017 21:24:09 +0200 Subject: [PATCH 2/4] Ignore vim .swp files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4f08f6a..1875ced 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ __pycache__ /.env /env .idea/ +*.swp From dacbf44d440f6f89f27f33977c40f0f2c61e87ea Mon Sep 17 00:00:00 2001 From: Nils Schweinsberg Date: Tue, 5 Sep 2017 21:54:47 +0200 Subject: [PATCH 3/4] Dope module --- bot/dope.py | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 bot/dope.py diff --git a/bot/dope.py b/bot/dope.py new file mode 100644 index 0000000..3d469db --- /dev/null +++ b/bot/dope.py @@ -0,0 +1,116 @@ +# -*- 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', + ], + } + + @command + def dope(self, mask: IrcString, target: IrcString, args: Dict): + """Smoke weed everyday + + %%dope [] + """ + + strain_types = list(self.STRAINS.keys()) + strain_type = random.choice(strain_types) + strain = random.choice(self.STRAINS[strain_type]) + + actions = { + 'joint': [ + 'passes', + 'rolls', + 'lights', + ], + 'bong': [ + 'passes', + 'preps', + 'lights', + ], + 'vape': [ + 'passes', + ], + 'blunt': [ + 'passes', + 'rolls', + 'lights', + ], + } + + consume_type = random.choice(list(actions.keys())) + action = random.choice(actions[consume_type]) + + if args['']: + nick = args[''] + else: + nick = mask.nick + + self.bot.action(target, '{action} a {consume_type} of the finest {strain_type} "{strain}" to {nick}'.format( + action=action, + consume_type=consume_type, + strain_type=strain_type, + strain=strain, + nick=nick)) From 3dd02bb94d838c8b1d777d2812100bfaca5b6d38 Mon Sep 17 00:00:00 2001 From: Nils Schweinsberg Date: Tue, 5 Sep 2017 22:00:40 +0200 Subject: [PATCH 4/4] Fix actions --- bot/dope.py | 56 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/bot/dope.py b/bot/dope.py index 3d469db..ffee116 100644 --- a/bot/dope.py +++ b/bot/dope.py @@ -68,6 +68,27 @@ class Dope(Plugin): ], } + 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 @@ -79,37 +100,14 @@ class Dope(Plugin): strain_type = random.choice(strain_types) strain = random.choice(self.STRAINS[strain_type]) - actions = { - 'joint': [ - 'passes', - 'rolls', - 'lights', - ], - 'bong': [ - 'passes', - 'preps', - 'lights', - ], - 'vape': [ - 'passes', - ], - 'blunt': [ - 'passes', - 'rolls', - 'lights', - ], - } + consume_type = random.choice(list(self.ACTIONS.keys())) + action = random.choice(self.ACTIONS[consume_type]) - consume_type = random.choice(list(actions.keys())) - action = random.choice(actions[consume_type]) + nick = args.get('', mask.nick) - if args['']: - nick = args[''] - else: - nick = mask.nick - - self.bot.action(target, '{action} a {consume_type} of the finest {strain_type} "{strain}" to {nick}'.format( - action=action, + 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,