Test Failed
Pull Request — master (#86)
by Daniel
04:59
created

irc2phpbb.marvin_general_actions   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 28
dl 0
loc 51
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A getAllGeneralActions() 0 6 1
A marvinMorning() 0 29 4
1
#! /usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
4
"""
5
Make general actions for Marvin, one function for each action.
6
"""
7
import datetime
8
import random
9
10
lastDateGreeted = None
11
12
13
def getAllGeneralActions():
14
    """
15
    Return all general actions as an array.
16
    """
17
    return [
18
        marvinMorning
19
    ]
20
21
22
def marvinMorning(row):
23
    """
24
    Marvin says Good morning after someone else says it
25
    """
26
    msg = None
27
    phrases = [
28
        "morgon",
29
        "godmorgon",
30
        "god morgon",
31
        "morrn",
32
        "morn"
33
    ]
34
35
    morning_phrases = [
36
        "Godmorgon! :-)",
37
        "Morgon allesammans",
38
        "Morgon gott folk",
39
        "Guten morgen",
40
        "Morgon"
41
    ]
42
43
    global lastDateGreeted
44
45
    for phrase in phrases:
46
        if phrase in row:
47
            if lastDateGreeted != datetime.date.today():
48
                lastDateGreeted = datetime.date.today()
49
                msg = random.choice(morning_phrases)
50
    return msg
51