all repos — python-meme-bot @ 40c83258dcc1ec16822e667287b4415380300b69

Telegram Bot that uses PIL to compute light image processing.

Constants.py (view raw)

  1import logging
  2
  3localization = {
  4    'us': {
  5        'welcome' : "Welcome to PILuAnimeBot!",
  6        'sauce' : "Sauce ๐Ÿ",
  7        'no_caption' : "No caption detected.",
  8        'lewd_toggle' : "Lewd content was {} for this chat.",
  9        'enabled' : "enabled",
 10        'disabled' : "disabled",
 11        'unknown' : "Sorry, I didn't understand that command.",
 12        'error': "An error has occurred. Please retry.",
 13        'failed_effect': "Couldn't apply effect."
 14    },
 15    'it': {
 16        'welcome' : "Benvenuto da PILuAnimeBot!",
 17        'sauce' : "Salsa ๐Ÿ",
 18        'no_caption' : "Scrivi un testo per favore.",
 19        'lewd_toggle' : "La roba lewd รจ stata {} per questa chat.",
 20        'enabled' : "abilitata",
 21        'disabled' : "disabilitata",
 22        'unknown' : "Non ho capito.",
 23        'error': "Qualcosa รจ andato storto, riprova.",
 24        'failed_effect': "Impossibile applicare l'effetto."
 25    },
 26}
 27
 28symbols = {
 29    "grape",
 30    "lemon",
 31    "bar",
 32    "seven"
 33}
 34
 35slot_machine_value = {
 36    1: ("bar", "bar", "bar"),
 37    2: ("grape", "bar", "bar"),
 38    3: ("lemon", "bar", "bar"),
 39    4: ("seven", "bar", "bar"),
 40    5: ("bar", "grape", "bar"),
 41    6: ("grape", "grape", "bar"),
 42    7: ("lemon", "grape", "bar"),
 43    8: ("seven", "grape", "bar"),
 44    9: ("bar", "lemon", "bar"),
 45    10: ("grape", "lemon", "bar"),
 46    11: ("lemon", "lemon", "bar"),
 47    12: ("seven", "lemon", "bar"),
 48    13: ("bar", "seven", "bar"),
 49    14: ("grape", "seven", "bar"),
 50    15: ("lemon", "seven", "bar"),
 51    16: ("seven", "seven", "bar"),
 52    17: ("bar", "bar", "grape"),
 53    18: ("grape", "bar", "grape"),
 54    19: ("lemon", "bar", "grape"),
 55    20: ("seven", "bar", "grape"),
 56    21: ("bar", "grape", "grape"),
 57    22: ("grape", "grape", "grape"),
 58    23: ("lemon", "grape", "grape"),
 59    24: ("seven", "grape", "grape"),
 60    25: ("bar", "lemon", "grape"),
 61    26: ("grape", "lemon", "grape"),
 62    27: ("lemon", "lemon", "grape"),
 63    28: ("seven", "lemon", "grape"),
 64    29: ("bar", "seven", "grape"),
 65    30: ("grape", "seven", "grape"),
 66    31: ("lemon", "seven", "grape"),
 67    32: ("seven", "seven", "grape"),
 68    33: ("bar", "bar", "lemon"),
 69    34: ("grape", "bar", "lemon"),
 70    35: ("lemon", "bar", "lemon"),
 71    36: ("seven", "bar", "lemon"),
 72    37: ("bar", "grape", "lemon"),
 73    38: ("grape", "grape", "lemon"),
 74    39: ("lemon", "grape", "lemon"),
 75    40: ("seven", "grape", "lemon"),
 76    41: ("bar", "lemon", "lemon"),
 77    42: ("grape", "lemon", "lemon"),
 78    43: ("lemon", "lemon", "lemon"),
 79    44: ("seven", "lemon", "lemon"),
 80    45: ("bar", "seven", "lemon"),
 81    46: ("grape", "seven", "lemon"),
 82    47: ("lemon", "seven", "lemon"),
 83    48: ("seven", "seven", "lemon"),
 84    49: ("bar", "bar", "seven"),
 85    50: ("grape", "bar", "seven"),
 86    51: ("lemon", "bar", "seven"),
 87    52: ("seven", "bar", "seven"),
 88    53: ("bar", "grape", "seven"),
 89    54: ("grape", "grape", "seven"),
 90    55: ("lemon", "grape", "seven"),
 91    56: ("seven", "grape", "seven"),
 92    57: ("bar", "lemon", "seven"),
 93    58: ("grape", "lemon", "seven"),
 94    59: ("lemon", "lemon", "seven"),
 95    60: ("seven", "lemon", "seven"),
 96    61: ("bar", "seven", "seven"),
 97    62: ("grape", "seven", "seven"),
 98    63: ("lemon", "seven", "seven"),
 99    64: ("seven", "seven", "seven"),
100}
101
102win_table = {
103    (3, "seven"): 50,
104    (3, "bar"): 20,
105    (3, "lemon"): 10,
106    (3, "grape"): 5,
107    
108    (2, "seven"): 10,
109    (2, "bar"): 5,
110    (2, "lemon"): 2,
111    (2, "grape"): 1
112}
113
114def get_symbols(value: int):
115    try:
116        return slot_machine_value[value]
117    except IndexError:
118        return slot_machine_value[50]
119
120def get_multiplier(count: int, symbol: str):
121    try:
122        return win_table[(count, symbol)]
123    except KeyError as e:
124        return 0
125
126def get_localized_string(text, lang='us'):
127    try:
128        return localization[lang][text]
129    except KeyError:
130        logging.error("No text was found.")
131        return "localization error {}{}{}{}{}{}"
132