Exemplo n.º 1
0
import time
import re

from lib import Plugin, cron
plgn = Plugin('repeat')
logger = plgn.logger
plgn.__doc__ = "Demo/Dummy plugin"


@plgn.command(
    'repeat (?P<what>[-a-zA-Z0-9 `,;!@#$%^&*()_=.{}:"\?\<\>/\[\'\]\\n]+)')
def repeat(data, what):
    return 'repeating ' + what


#@plgn.schedule(cron(second=range(0,60,5)), maximum = 2)
#def logr(*args, **kwargs):
#    plgn.myid =myid= getattr(plgn,'myid',0) + 1
#    logger.info('start myid is %s' % myid)
#    time.sleep(20)
#    logger.info('end myid is %s' % myid)
Exemplo n.º 2
0
import os
from datetime import datetime
from csv import DictWriter, DictReader
from lib import Plugin, cron
from collections import defaultdict

plgn = Plugin('reimburse')
logger = plgn.logger
plgn.__doc__ = "Use this plugin to store reimbursements. The details will be mailed to you by the end of month"


@plgn.command('reim (?P<amt>-?\d+) (?P<why>[A-Za-z0-9 !@#$%^&*()]+)')
def save(data, **details):
    """
    save reimbursement details:
    usage: reim <amt> <why>
    """
    with open(plgn.exp_filename, 'a') as f:
        wr = DictWriter(f, ['dt', 'by', 'amt', 'why', 'status'])
        dt = datetime.now()
        details['status'] = 1
        details['dt'] = dt
        details['by'] = data['user_object'].name if data.get(
            'user_object') else data['user']
        wr.writerow(details)
    sendMonthlyEmail(None, **details)
    return '{amt} was spent for {why}'.format(**details)


def userwise():
    """
Exemplo n.º 3
0
import os
from datetime import datetime
import logging
from csv import DictWriter, DictReader
from lib import Plugin, cron
from collections import defaultdict



logger = logging.getLogger('bot.reimburse')
logger.setLevel(logging.DEBUG)
plgn = Plugin('reimburse')
plgn.__doc__ = "Use this plugin to store reimbursements. The details will be mailed to you by the end of month"


@plgn.command('reim (?P<amt>-?\d+) (?P<why>[A-Za-z0-9 !@#$%^&*()]+)')
def save(data, **details):
    """
    save reimbursement details:
    usage: reim <amt> <why>
    """
    with open(plgn.exp_filename, 'a') as f:
        wr = DictWriter(f, ['dt','by','amt', 'why','status'])
        dt = datetime.now()
        details['status'] = 1
        details['dt'] = dt
        details['by'] = data['user_object'].name if data.get('user_object') else data['user']
        wr.writerow(details)
    sendMonthlyEmail(None, **details)
    return '{amt} was spent for {why}'.format(**details)
Exemplo n.º 4
0
import time
import re

from lib import Plugin, cron
import logging

logger = logging.getLogger("bot.repeat")
logger.setLevel(logging.DEBUG)
plgn = Plugin("repeat")
plgn.__doc__ = "Demo/Dummy plugin"


@plgn.command("repeat (?P<what>[-a-zA-Z0-9 `,;!@#$%^&*()_=.{}:\"\?\<\>/\['\]\\n]+)")
def repeat(data, what):
    return "repeating " + what


# @plgn.schedule(cron(second=range(0,60,5)), maximum = 2)
# def logr(*args, **kwargs):
#    plgn.myid =myid= getattr(plgn,'myid',0) + 1
#    logger.info('start myid is %s' % myid)
#    time.sleep(20)
#    logger.info('end myid is %s' % myid)