all repos — groupgardenbot @ 8434ee64d0634a3230ff2c7ae8cc3f4eb9d50f47

An extension of the game "botany", originally designed for unix-based systems, to the Telegram Bot API.

initial coommit
Marco Andronaco andronacomarco@gmail.com
Fri, 23 Sep 2022 21:53:04 +0200
commit

8434ee64d0634a3230ff2c7ae8cc3f4eb9d50f47

A .gitignore

@@ -0,0 +1,4 @@

+__pycache__ +.env +bot-data.pkl +venv
A .vscode/launch.json

@@ -0,0 +1,16 @@

+{ + // Usare IntelliSense per informazioni sui possibili attributi. + // Al passaggio del mouse vengono visualizzate le descrizioni degli attributi esistenti. + // Per altre informazioni, visitare: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Bot", + "type": "python", + "request": "launch", + "program": "main.py", + "console": "integratedTerminal", + "justMyCode": true + } + ] +}
A Constants.py

@@ -0,0 +1,215 @@

+stage_descriptions = { + 0:[ + "You're excited about your new seed.", + "You wonder what kind of plant your seed will grow into.", + "You're ready for a new start with this plant.", + "You're tired of waiting for your seed to grow.", + "You wish your seed could tell you what it needs.", + "You can feel the spirit inside your seed.", + "These pretzels are making you thirsty.", + "Way to plant, Ann!", + "'To see things in the seed, that is genius' - Lao Tzu", + ], + 1:[ + "The seedling fills you with hope.", + "The seedling shakes in the wind.", + "You can make out a tiny leaf - or is that a thorn?", + "You can feel the seedling looking back at you.", + "You blow a kiss to your seedling.", + "You think about all the seedlings who came before it.", + "You and your seedling make a great team.", + "Your seedling grows slowly and quietly.", + "You meditate on the paths your plant's life could take.", + ], + 2:[ + "The {} {} makes you feel relaxed.", + "You sing a song to your {} {}.", + "You quietly sit with your {} {} for a few minutes.", + "Your {} {} looks pretty good.", + "You play loud techno to your {} {}.", + "You play piano to your {} {}.", + "You play rap music to your {} {}.", + "You whistle a tune to your {} {}.", + "You read a poem to your {} {}.", + "You tell a secret to your {} {}.", + "You play your favorite record for your {} {}.", + ], + 3:[ + "{}Your {} is growing nicely!", + "{}You're proud of the dedication it took to grow your {}.", + "{}You take a deep breath with your {}.", + "{}You think of all the words that rhyme with {}.", + "{}The {} looks full of life.", + "{}The {} inspires you.", + "{}Your {} makes you forget about your problems.", + "{}Your {} gives you a reason to keep going.", + "{}Looking at your {} helps you focus on what matters.", + "{}You think about how nice this {} looks here.", + "{}The buds of your {} might bloom soon.", + ], + 4:[ + "The {} flowers look nice on your {}!", + "The {} flowers have bloomed and fill you with positivity.", + "The {} flowers remind you of your childhood.", + "The {} flowers remind you of spring mornings.", + "The {} flowers remind you of a forgotten memory.", + "The {} flowers remind you of your happy place.", + "The aroma of the {} flowers energize you.", + "The {} {} has grown beautiful flowers." + "The {} petals remind you of that favorite shirt you lost.", + "The {} flowers remind you of your crush.", + "You smell the {} flowers and are filled with peace.", + ], + 5:[ + "You fondly remember the time you spent caring for your {} {}.", + "Seed pods have grown on your {} {}.", + "You feel like your {} {} appreciates your care.", + "The {} fills you with love.", + "You're ready for whatever comes after your {} {}.", + "You're excited to start growing your next plant.", + "You reflect on when your {} {} was just a seedling.", + "You grow nostalgic about the early days with your {} {}.", + ], + 99:[ + "You wish you had taken better care of your plant.", + "If only you had watered your plant more often..", + "Your plant is dead, there's always next time.", + "You cry over the withered leaves of your plant.", + "Your plant died. Maybe you need a fresh start.", + ], +} + +def get_stage_description(stage: int, number: int, species: str, color: str) -> str: + return stage_descriptions[stage][number].format(color, species) + +plant_art_list = [ + 'poppy', + 'cactus', + 'aloe', + 'flytrap', + 'jadeplant', + 'fern', + 'daffodil', + 'sunflower', + 'baobab', + 'lithops', + 'hemp', + 'pansy', + 'iris', + 'agave', + 'ficus', + 'moss', + 'sage', + 'snapdragon', + 'columbine', + 'brugmansia', + 'palm', + 'pachypodium', + ] + +stage_list = [ + 'seed', + 'seedling', + 'young', + 'mature', + 'flowering', + 'seed-bearing', +] + +color_list = [ + 'red', + 'orange', + 'yellow', + 'green', + 'blue', + 'indigo', + 'violet', + 'white', + 'black', + 'gold', + 'rainbow', +] + +rarity_list = [ + 'common', + 'uncommon', + 'rare', + 'legendary', + 'godly', +] + +species_list = [ + 'poppy', + 'cactus', + 'aloe', + 'venus flytrap', + 'jade plant', + 'fern', + 'daffodil', + 'sunflower', + 'baobab', + 'lithops', + 'hemp', + 'pansy', + 'iris', + 'agave', + 'ficus', + 'moss', + 'sage', + 'snapdragon', + 'columbine', + 'brugmansia', + 'palm', + 'pachypodium', +] + +mutation_list = [ + '', + 'humming', + 'noxious', + 'vorpal', + 'glowing', + 'electric', + 'icy', + 'flaming', + 'psychic', + 'screaming', + 'chaotic', + 'hissing', + 'gelatinous', + 'deformed', + 'shaggy', + 'scaly', + 'depressed', + 'anxious', + 'metallic', + 'glossy', + 'psychedelic', + 'bonsai', + 'foamy', + 'singing', + 'fractal', + 'crunchy', + 'goth', + 'oozing', + 'stinky', + 'aromatic', + 'juicy', + 'smug', + 'vibrating', + 'lithe', + 'chalky', + 'naive', + 'ersatz', + 'disco', + 'levitating', + 'colossal', + 'luminous', + 'cosmic', + 'ethereal', + 'cursed', + 'buff', + 'narcotic', + 'gnu/linux', + 'abraxan', # rip dear friend +]
A Gardening.py

@@ -0,0 +1,259 @@

+import random, time, math, datetime, os +from Constants import * + +water_duration = 3600 # * 24 +stage_factors = (1, 3, 10, 20, 30) + +class Plant(object): + # This is your plant! + def __init__(self, owner, generation=1): + # Constructor + self.points = 0 # one point per second + self.life_stages = tuple(st * water_duration for st in stage_factors) + self.stage = 0 + self.mutation = 0 + self.species = random.randint(0,len(species_list)-1) + self.color = random.randint(0,len(color_list)-1) + self.rarity = self.rarity_check() + self.ticks = 0 + self.age_formatted = "0" + self.generation = generation + self.generation_bonus = 1 + (0.2 * (generation - 1)) + self.dead = False + self.owner = owner + self.start_time = int(time.time()) + self.last_time = int(time.time()) + self.last_update = int(time.time()) + # must water plant first day + #self.last_water = int(time.time())-(24*3600)-1 + self.last_water = int(time.time()) + self.watered_24h = True + self.visitors = [] + + def update(self): + + # find out stage: + self.water_check() + if self.dead_check(): # updates self.time_delta_watered + return + + self.stage = find_stage(self) + + def parse_plant(self): + # Converts plant data to human-readable format + output = "" + if self.stage >= 3: + output += rarity_list[self.rarity] + " " + if self.mutation != 0: + output += mutation_list[self.mutation] + " " + if self.stage >= 4: + output += color_list[self.color] + " " + output += stage_list[self.stage] + " " + if self.stage >= 2: + output += species_list[self.species] + " " + return output.strip() + + def rarity_check(self): + # Generate plant rarity + CONST_RARITY_MAX = 256.0 + rare_seed = random.randint(1,CONST_RARITY_MAX) + common_range = round((2.0/3)*CONST_RARITY_MAX) + uncommon_range = round((2.0/3)*(CONST_RARITY_MAX-common_range)) + rare_range = round((2.0/3)*(CONST_RARITY_MAX-common_range-uncommon_range)) + legendary_range = round((2.0/3)*(CONST_RARITY_MAX-common_range-uncommon_range-rare_range)) + + common_max = common_range + uncommon_max = common_max + uncommon_range + rare_max = uncommon_max + rare_range + legendary_max = rare_max + legendary_range + godly_max = CONST_RARITY_MAX + + if 0 <= rare_seed <= common_max: + return 0 + elif common_max < rare_seed <= uncommon_max: + return 1 + elif uncommon_max < rare_seed <= rare_max: + return 2 + elif rare_max < rare_seed <= legendary_max: + return 3 + elif legendary_max < rare_seed <= godly_max: + return 4 + + def dead_check(self): + # if it has been >5 days since watering, sorry plant is dead :( + self.time_delta_watered = int(time.time()) - self.last_water + if self.time_delta_watered > (5 * water_duration): + self.dead = True + return self.dead + + def water_check(self): + self.time_delta_watered = int(time.time()) - self.last_water + if self.time_delta_watered <= (water_duration): + if not self.watered_24h: + self.watered_24h = True + return True + else: + self.watered_24h = False + return False + + def mutate_check(self): + # Create plant mutation + # Increase this # to make mutation rarer (chance 1 out of x each second) + CONST_MUTATION_RARITY = 20000 + mutation_seed = random.randint(1,CONST_MUTATION_RARITY) + if mutation_seed == CONST_MUTATION_RARITY: + # mutation gained! + mutation = random.randint(0,len(self.mutation_list)-1) + if self.mutation == 0: + self.mutation = mutation + return True + else: + return False + + def growth(self): + # Increase plant growth stage + if self.stage < (len(stage_list)-1): + self.stage += 1 + + def water(self): + # Increase plant growth stage + if not self.dead: + self.last_water = int(time.time()) + self.watered_24h = True + + def start_over(self): + # After plant reaches final stage, given option to restart + # increment generation only if previous stage is final stage and plant + # is alive + if not self.dead: + next_generation = self.generation + 1 + else: + # Should this reset to 1? Seems unfair.. for now generations will + # persist through death. + next_generation = self.generation + self.kill_plant() + + self.__init__(self.owner, next_generation) + + def kill_plant(self): + self.dead = True + +def find_stage(plant: Plant): + now = int(time.time()) + + res1 = min(now - plant.last_water, water_duration) + res2 = min(plant.last_update - plant.last_water, water_duration) + + plant.points += max(0, res1 - res2) # max() not necessary but just in case + + print("generation bonus: ", plant.generation_bonus, ". increase: ", res1 - res2, "max: ", water_duration) + plant.last_update = now + + stages = tuple(ti / plant.generation_bonus for ti in plant.life_stages) # bonus is applied to stage thresholds + count = 0 + closest = None + delta = plant.points + + for n in stages: + if (n <= delta and (closest is None or (delta - n) < (delta - closest))): + closest = n + count += 1 + + print("plant is in stage", count, "because it passed", closest, "seconds of life") + return count + +def get_plant_water(plant: Plant): + water_delta = time.time() - plant.last_water + water_left_pct = max(0, 1 - (water_delta/water_duration)) # 24h + water_left = int(math.ceil(water_left_pct * 10)) + return f"{water_left * '🟦'}{'⬛' * (10 - water_left)} {str(int(water_left_pct * 100))}% " + +def get_plant_description(plant: Plant): + output_text = "" + this_species = species_list[plant.species] + this_color = color_list[plant.color] + this_stage = plant.stage + + if plant.dead: + this_stage = 99 + try: + description_num = random.randint(0,len(stage_descriptions[this_stage]) - 1) + except KeyError as e: + print(e) + description_num = 0 + # If not fully grown + if this_stage <= 4: + # Growth hint + if this_stage >= 1: + last_growth_at = plant.life_stages[this_stage - 1] + else: + last_growth_at = 0 + ticks_since_last = plant.ticks - last_growth_at + ticks_between_stage = plant.life_stages[this_stage] - last_growth_at + if ticks_since_last >= ticks_between_stage * 0.8: + output_text += "You notice your plant looks different.\n" + + output_text += get_stage_description(this_stage, description_num, this_species, this_color) + "\n" + + # if seedling + if this_stage == 1: + species_options = [species_list[plant.species], + species_list[(plant.species+3) % len(species_list)], + species_list[(plant.species-3) % len(species_list)]] + random.shuffle(species_options) + plant_hint = "It could be a(n) " + species_options[0] + ", " + species_options[1] + ", or " + species_options[2] + output_text += plant_hint + ".\n" + + # if young plant + if this_stage == 2: + if plant.rarity >= 2: + rarity_hint = "You feel like your plant is special." + output_text += rarity_hint + ".\n" + + # if mature plant + if this_stage == 3: + color_options = [color_list[plant.color], + color_list[(plant.color+3) % len(color_list)], + color_list[(plant.color-3) % len(color_list)]] + random.shuffle(color_options) + return "You can see the first hints of " + color_options[0] + ", " + color_options[1] + ", or " + color_options[2] + + return output_text + +def get_plant_art(plant: Plant): + + if plant.dead == True: + filename = 'rip.txt' + elif datetime.date.today().month == 10 and datetime.date.today().day == 31: + filename = 'jackolantern.txt' + elif plant.stage == 0: + filename = 'seed.txt' + elif plant.stage == 1: + filename = 'seedling.txt' + elif plant.stage == 2: + filename = plant_art_list[plant.species]+'1.txt' + elif plant.stage == 3 or plant.stage == 5: + filename = plant_art_list[plant.species]+'2.txt' + elif plant.stage == 4: + filename = plant_art_list[plant.species]+'3.txt' + + # Prints ASCII art from file at given coordinates + this_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "art") + this_filename = os.path.join(this_dir, filename) + this_file = open(this_filename,"r") + this_string = this_file.read() + this_file.close() + return this_string + +def get_plant_info(plant: Plant): + + return f''' +{get_plant_description(plant)} +```{get_plant_art(plant)}``` +{plant.parse_plant()} + +{get_plant_water(plant)} + +Points: {plant.points} +Bonus: x{plant.generation_bonus - 1} +'''
A art/agave1.txt

@@ -0,0 +1,10 @@

+ + + + . , , . + |\ |`, || /| ., + |\v| \v /|v/| |/ | + \| \\\/ /| / V / + \_| \ / / ,/ +. , _ .\ \ |,/_/., _ . + ^ ' ` '
A art/agave2.txt

@@ -0,0 +1,10 @@

+ + + , , . + . |`. |\ /| ., + . |\ | | /||^| | /| + \ \v| \v /|v/| |/ | + \ |\ |/ /| / V / + \^\ \ \ \ / / ,| / +. , \ \\ \ |,/_/./ / . + ^ ' ` '
A art/agave3.txt

@@ -0,0 +1,10 @@

+ oo|oo + oo|oo + , oo|oo . + . |`. \|\ /| ., + . |\ | | /||^| | /| + \ \v| \v /|v/| |/ | + \ |\ |/ /| / V / + \^\ \ \ \ / / ,| / +. , \ \\ \ |,/_/./ / . + ^ ' ` '
A art/aloe1.txt

@@ -0,0 +1,10 @@

+ + + + + . . . + |\.,n/|./| + \\\/ /| / + '| \ / / +. , _ . .\ |,/_ ., _ . + ^ ' ` '
A art/aloe2.txt

@@ -0,0 +1,10 @@

+ + + .\ .| + \\ || ._ + ..\ \\. //. // + \ \.\|v ||// + \\\ || // + '| \ / / +. , _ . .\ |,/_ ., _ . + ^ ' ` '
A art/aloe3.txt

@@ -0,0 +1,10 @@

+ =\= + =|= + .\ | .| + \\ | || ._ + ..\ \\||//. // + \ \.\|v ||// + \\\ || // + '| \ / / +. , _ . .\ |,/_ ., _ . + ^ ' ` '
A art/baobab1.txt

@@ -0,0 +1,10 @@

+ + + && & & & && + ^ \ | ^ | ^/ + ^|^ |^ ^|^/ + | * | + |. ; `| + | . | +. , _ .(. ) _ . + ^ ' ` '
A art/baobab2.txt

@@ -0,0 +1,10 @@

+ + &&& && && &&& + &&&&\& & v & /& && + && \ | \^ , &/^/& + | |^ + | , | + |. ; | + / . \ +. , _ ( . )_ . + ^ ' ` '
A art/baobab3.txt

@@ -0,0 +1,10 @@

+ * *& * * + &&& *&& && &&& + &*&&\* & * & /* && + *& \ | \^ , &/*/& + *| |^ + | , | + |. ; | + / . \ +. , _ ( . )_ . + ^ ' ` '
A art/bee.txt

@@ -0,0 +1,12 @@

+ _ + /_) +(8_))}- . + \_) '. + .--. . + : '. .' + '---'`; + . + _.' + .' + ' _ + '._. , ' `, .
A art/brugmansia1.txt

@@ -0,0 +1,10 @@

+ + + _. + //\\ //\ + | |\\ // \\ + \V//| | + || + ||/ +. , _ . ., || _ ., _ . + ^ ' ` '
A art/brugmansia2.txt

@@ -0,0 +1,10 @@

+ + _ /n\ + //.\ || \| + // \\|`//\ + | ||\|// \ + /\V/| | + | || + ||/\ +. , _ . ., || _ ., _ . + ^ ' ` '
A art/brugmansia3.txt

@@ -0,0 +1,10 @@

+ + _ /n\ + //.\^||^\^ + // \\|`//\ + /^ ||\|// ^\^ + ^ /\V/|^ ^ + | ||^ + ^ ||/\ +. , _ . ., || _ ., _ . + ^ ' ` '
A art/cactus1.txt

@@ -0,0 +1,10 @@

+ + + + + + _\_\/ + -( / )- + \_/ +. , _ . .,@@@ _ ., _ . + ^ ' ` '
A art/cactus2.txt

@@ -0,0 +1,10 @@

+ + + +-+, + ,+\/|`| \ + \' | |'| ., + \ `| | |/ ) + | |'| , / + |'| |, / +. , _ . |_|_| | ., _ . + ^ ' ` '
A art/cactus3.txt

@@ -0,0 +1,10 @@

+ + + +*+, + *+\/|`* \ + \' | |'| ., + * `| | |/ ) + | |'| , / + |'| |, / +. , _ . |_|_| | ., _ . + ^ ' ` '
A art/columbine1.txt

@@ -0,0 +1,10 @@

+ + + + + + \ | | / + | \|&| + &\/&/ +. , _ . ., &/ _ ., _ . + ^ ' ` '
A art/columbine2.txt

@@ -0,0 +1,10 @@

+ + + + \ | / + | &|/ |& / + &\ | / / + \| \|&| + &\/&/ +. , _ . ., &/ _ ., _ . + ^ ' ` '
A art/columbine3.txt

@@ -0,0 +1,10 @@

+ + + % % + %\ | / % + % | &|/ |& / + %&\ | / /% + \| \|&| + &\/&/ +. , _ . ., &/ _ ., _ . + ^ ' ` '
A art/daffodil1.txt

@@ -0,0 +1,10 @@

+ + + + + -\ + |/- + - | + \| +. , _ . ., l, _ ., _ . + ^ ' ` '
A art/daffodil2.txt

@@ -0,0 +1,10 @@

+ + + -\, + |/- + \| + -| |/- + \ | | /- + \|/.| +. , _ . ., l,/_ ., _ . + ^ ' ` '
A art/daffodil3.txt

@@ -0,0 +1,10 @@

+ + /|< + >|\ / + |/-|< + \| + >|-| |/-|< + \ | | /-|< + \|/.| +. , _ . ., l,/_ ., _ . + ^ ' ` '
A art/fern1.txt

@@ -0,0 +1,10 @@

+ + + + + + \|/, + .\|/ |/ + \|/ l/ +. , _ . ., l /_ ., _ . + ^ ' ` '
A art/fern2.txt

@@ -0,0 +1,10 @@

+ + + | + \|/ | + \|/, \|/ + .| \|/,\// . + \|/ \|/ |/ |/` + \\/,\|/|l///, +. , _ .`\,\lv/_// _ . + ^ ' ` '
A art/fern3.txt

@@ -0,0 +1,10 @@

+ + % + % + \|/ % + \|/, \%/ + .% \|/,\// . + \%/ \|/ %/ |/% + \\/,\|/|l///, +. , _ .`\,\lv/_// _ . + ^ ' ` '
A art/ficus1.txt

@@ -0,0 +1,10 @@

+ & \ & & + &\|,/ |/& && + &|/& / & & + \ { |___/_& + { {/ / & + `, \{______/_& + } }{ \_& + }{{ +. , , -=-~{ .-^- _ _ . + ^ '
A art/ficus2.txt

@@ -0,0 +1,10 @@

+ &&&\/& &&& + &\|,/ |/& && + &&/ / /_&& && + \ { |_____/_& + { / / & & &&& + `, \{___________/_&& + } }{ &\____& + }{{ `&\&& + {}{ && +. , , -=-~{ .-^- _ _ .
A art/ficus3.txt

@@ -0,0 +1,10 @@

+ &*&\/& *&& + &\|,/ |/& *& + *&/ / /_&& && + \ { |_____/_* + {* / / & & *&& + `, \{___________/_*& + } }{ *\____& + }{{ `&\*& + {}{ && +. , , -=-~{ .-^- _ _ .
A art/flytrap1.txt

@@ -0,0 +1,10 @@

+ + + + + + + C % c + (\C/ +. , _ . ., l, _ ., _ . + ^ ' ` '
A art/flytrap2.txt

@@ -0,0 +1,10 @@

+ + ._, + .__, ,/ | _,_,, + ._\ \, |--/ /\ \ \< + '\ \ | \/ ||\ \,|< + '\_+/, || // \_/` + ' \\ ||// , + \\\|/ / +. , _ . .\ l,/_ ., _ . + ^ ' ` '
A art/flytrap3.txt

@@ -0,0 +1,10 @@

+ % % + \| ._, + .__,| ,/ | _,_,, + ._\ \,\|--/ /\ \ \< + '\ \ | \\/ ||\ \,|< + '\_+/, ||%// \_/` + ' \\ ||// % + \\\|/ / +. , _ . .\ l,/_ ., _ . + ^ ' ` '
A art/hemp1.txt

@@ -0,0 +1,10 @@

+ + + + ^ + l% + %\| _ + |/ % + %\| /% +. , _ . ., l/ _ ., _ . + ^ ' ` '
A art/hemp2.txt

@@ -0,0 +1,10 @@

+ + ^ + ^+^ + + ^+^+ + \+^+^/ + ^+\|^/^/ + \+^\|/ ^ + ^+\|+/+/ +. , _ . ., l/ _ ., _ . + ^ ' ` '
A art/hemp3.txt

@@ -0,0 +1,10 @@

+ + % + ~ %+% + + %+%+ ~ + ~ \+%+%/ + ^%\|%/%/ ~ + ~ \+^\|/ ^ + ^+\|+/+/ +. , _ . ., l/ _ ., _ . + ^ ' ` '
A art/iris1.txt

@@ -0,0 +1,10 @@

+ + + + _, . , + / \ \V / /\ + |\ \\v/ |` + /\ v ||/ \ + \\v// +. , _ . .,\V/ _ ., _ . + ^ ' ` '
A art/iris2.txt

@@ -0,0 +1,10 @@

+ + /\ + /\ | /\ + _ | || / + / \ \||/ /\ + |\ \\v/ ` + /\ v ||/\ + \\v// +. , _ . .,\V/ _ ., _ . + ^ ' ` '
A art/iris3.txt

@@ -0,0 +1,10 @@

+ + /\ + %/\ | % /\ + _ | || / % + / \ \||/ /\ + % |\ \\v/ % + /\ v ||/\ + % \\v// % +. , _ . .,\V/ _ ., _ . + ^ ' ` '
A art/jackolantern.txt

@@ -0,0 +1,10 @@

+ /)) HAPPY + __(((__ HALLOWEEN + .' _`""`_`'. + / /\\ /\\ \ + | /)_\\/)_\\ | + | _ _()_ _ | + | \\/\\/\\// | + \ \/\/\/\/ / + . , .'.___..___.' _ ., _ . + ^ ' ` '
A art/jadeplant1.txt

@@ -0,0 +1,10 @@

+ + + + + + . , + o%O %,o + \%o' +. , _ . ., l, _ ., _ . + ^ ' ` '
A art/jadeplant2.txt

@@ -0,0 +1,10 @@

+ + % % %% + %% |O%o| %o % + &&O%\o|%|/% /& + & &\o%O %,o& + O &\%o& + ||.|/ + \\ | +. , _ . .|,l, _ ., _ . + ^ ' ` '
A art/jadeplant3.txt

@@ -0,0 +1,10 @@

+ + o o %* + %* |O%o| *o % + *oO%\o|o|/% *& + * &\o%O *,o& + O *\*o& + ||.|/ + \\ | +. , _ . .|,l, _ ., _ . + ^ ' ` '
A art/lithops1.txt

@@ -0,0 +1,10 @@

+ + + + + + + + __ __ +. , _ . ( | ) ., _ . + ^ ' ` '
A art/lithops2.txt

@@ -0,0 +1,10 @@

+ + + + + + + + .__v___ +. , _ .( | )., _ . + ^ ' ` '
A art/lithops3.txt

@@ -0,0 +1,10 @@

+ + + + + + ***** + \V/ + .__v___ +. , _ .( | )., _ . + ^ ' ` '
A art/moon.txt

@@ -0,0 +1,7 @@

+ _.._ + .' .-'` + / / + | | + \ '.___.; + '._ _.' + ``
A art/moss1.txt

@@ -0,0 +1,10 @@

+ + + + /\ __ + _/ / \ + _/ / / `--. + __/ ' _ \_ \ + / / _/ ##- \ \ \ +._ / _ . .#### _|., _ .| + ^ ' ` '
A art/moss2.txt

@@ -0,0 +1,10 @@

+ + + + /\ __ + _/##/ \ + _/ /##/####`--. + __/ ' _###\_ ### \ + / / #_/###-#\####\ \ +._ / _#########_|#,#_ .| + ^ ' ` '
A art/moss3.txt

@@ -0,0 +1,10 @@

+ + + + /\ __ + _/##/ \ + _/ /*#/*#*#`--. + __/ ' _###\_ *## \ + / / #_/##*-#\###*\ \ +._ / _###*#*###_|#,#_ .| + ^ ' ` '
A art/pachypodium1.txt

@@ -0,0 +1,10 @@

+ + + + _ / _ + / \/|// \ + < > + < .> + < ` '> +` , <' > _ . _ . + ^ ' . ` '
A art/pachypodium2.txt

@@ -0,0 +1,10 @@

+ _ / _ + /_\/|//u + U | \ + < > + <`> _/ + <, > <> + < .><.> + < ` >'> +` , <' o >_ . _ . + ^ / ' \ . ` '
A art/pachypodium3.txt

@@ -0,0 +1,10 @@

+ _ <, _ + <_\/|//\\ + // | \\ U + U // >\) _ + u<`> _/ | + <, >/<>\ + <o.>U.> + < ` >'> +` , <' o >_ . _ . + ^ / ' \ . ` '
A art/palm1.txt

@@ -0,0 +1,10 @@

+ + + + _ , . _ + / \`\ / /^\ + | /\ ||/ \ | + | /\||\ | + || +. , _ . .,|_| _ ., _ . + ^ ' ` '
A art/palm2.txt

@@ -0,0 +1,10 @@

+ _ _ + ',\ / / '-. + /--\ \ / /^\ + |/ /\ ||/ \,| + ` | /\=|\,| ` + ` |_| ` + |_| + |_|. +. , _ . .|__| _ ., _ . + ^ ' ` '
A art/palm3.txt

@@ -0,0 +1,10 @@

+ _ _ + ',* /*/ '-. + /--\ **/ /^\ + |/ /\**|/ \,| + ` | /\=|\,| ` + ` |_| ` + |_| + |_|. +. , _ . .|__| _ ., _ . + ^ ' ` '
A art/pansy1.txt

@@ -0,0 +1,10 @@

+ + + + + + \ o / + o| |o o + \/ / +. , _ . ., l/ _ ., _ . + ^ ' ` '
A art/pansy2.txt

@@ -0,0 +1,10 @@

+ + + + o o + \o /_o o + o\| / /__o + | |o /o + \/ /o +. , _ . ., l/ _ ., _ . + ^ ' ` '
A art/pansy3.txt

@@ -0,0 +1,10 @@

+ + + + % % + \% /_% % + %\| / /__% + | |% /% + \/ /% +. , _ . ., l/ _ ., _ . + ^ ' ` '
A art/poppy1.txt

@@ -0,0 +1,10 @@

+ + + + O + | + \o + |o + \/ +. , _ . ., l, _ ., _ . + ^ ' ` '
A art/poppy2.txt

@@ -0,0 +1,10 @@

+ + O + o | + | | o + o| |&| + &\\o/ + ||o + &\/ +. , _ . ., l, _ ., _ . + ^ ' ` '
A art/poppy3.txt

@@ -0,0 +1,10 @@

+ + % + % | + | | % + %| |&| + &\\%/ + ||% + &\/ +. , _ . ., l, _ ., _ . + ^ ' ` '
A art/rip.txt

@@ -0,0 +1,10 @@

+ ______________ + / \ + | | + | | + | R.I.P. | + | | + | | + | | +. |, _\/ .. \. \ /,|_ . + ^ ' ` '
A art/sage1.txt

@@ -0,0 +1,10 @@

+ + + + + + '\+/` /` + '\|/`|/` + \|/ |/` +. , _ . . ,l-/`,., _ . + ^ ' ` '
A art/sage2.txt

@@ -0,0 +1,10 @@

+ + + + `\' + `\' /` + `| '\|/` /` + `\|'\|/`|/` + ,'\ \|/ |/` +. , _ .\|/,l-/`,., _ . + ^ ' ` '
A art/sage3.txt

@@ -0,0 +1,10 @@

+ + + ++ + +\+ + + + +\+ /+ + +| '\|/` /+ + `\|'\|/`|/` + ,'\ \|/ |/` +. , _ .\|/,l-/`,., _ . + ^ ' ` '
A art/seed.txt

@@ -0,0 +1,10 @@

+ + + + + + + + +. , _ . . _ , _ ., _ . + ^ ' o ` '
A art/seedling.txt

@@ -0,0 +1,10 @@

+ + + + + + + . ; + \| +. , _ . ., l, _ ., _ . + ^ ' ` '
A art/snapdragon1.txt

@@ -0,0 +1,10 @@

+ + + + + + |/ + \| + |/ + \| +. , _ . ., l, _ ., _ . + ^ ' ` '
A art/snapdragon2.txt

@@ -0,0 +1,10 @@

+ + + + + | , + + , |/ + '\ \| , + \| ,|/ + , + \|/ \| |/ +. , _ . \, l,/_ ., _ . + ^ ' ` '
A art/snapdragon3.txt

@@ -0,0 +1,10 @@

+ + + % + | % + % % |/ + %\ \| % + \| ,|/ % % + \|/ \| |/ +. , _ . \, l,/_ ., _ . + ^ ' ` '
A art/sun.txt

@@ -0,0 +1,7 @@

+ . + \ | / + '-.;;;;;.-' +-==;;;;;;;==- + .-';;;;;'-. + / | \ + '
A art/sunflower1.txt

@@ -0,0 +1,10 @@

+ + + + O + \// + || + ||/ + \|| +. , _ . ., || _ ., _ . + ^ ' ` '
A art/sunflower2.txt

@@ -0,0 +1,10 @@

+ + __ + (##) + & || + \//& + || + ||/& + &\|| +. , _ . ., || _ ., _ . + ^ ' ` '
A art/sunflower3.txt

@@ -0,0 +1,10 @@

+ + \||/ + |--OO-- + -o-/||\ + |\//& + || + ||/& + &\|| +. , _ . ., || _ ., _ . + ^ ' ` '
A art/template.txt

@@ -0,0 +1,10 @@

+ + + + + + + + +. , _ . ., , _ ., _ . + ^ ' ` '
A main.py

@@ -0,0 +1,128 @@

+import os, logging +logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) +from telegram import Update +from telegram.ext import Updater, CallbackContext, CallbackQueryHandler, CommandHandler, MessageHandler, PicklePersistence +from dotenv import load_dotenv +load_dotenv() +from Gardening import Plant, get_plant_info + +def reply(update: Update, context: CallbackContext, text: str = "", markup: str = ""): + return context.bot.send_message(chat_id=update.effective_chat.id, text=text, reply_markup=markup, parse_mode='Markdown') + +def get_plant(update: Update, context: CallbackContext): + try: + plant = context.bot_data[update.effective_user.id]["plant"] + except KeyError: + return None + + if plant is None: # probably useless but heh + print("############### This wasn't so useless after all! ###############") + return None + + plant.update() + return plant + +def start(update: Update, context: CallbackContext): + plant = get_plant(update, context) + + if plant is not None: + return reply(update, context, "Hai già una pianta. Usa /water se vuoi innaffiarla.") + + context.bot_data[update.effective_user.id] = { "plant" : Plant(update.effective_user.id) } + return reply(update, context, "Hai piantato un seme! Adesso usa /water per innaffiarlo.") + +def water(update: Update, context: CallbackContext): + plant = get_plant(update, context) + + if plant is None: + return reply(update, context, "Non hai nessuna pianta da innaffiare! Usa /start per piantarne una.") + + if plant.dead: + return reply(update, context, "La tua pianta è morta... Usa /harvest per piantarne un'altra.") + + plant.water() + return reply(update, context, "Pianta innaffiata.") + +def show(update: Update, context: CallbackContext): + plant = get_plant(update, context) + + if plant is None: + return reply(update, context, "Non hai nessuna pianta da mostrare! Usa /start per piantarne una.") + + return reply(update, context, get_plant_info(plant)) + +def harvest(update: Update, context: CallbackContext): + plant = get_plant(update, context) + + if plant is None: + return reply(update, context, "Non hai nessuna pianta! Usa /start per piantarne una.") + + if plant.dead: + plant.start_over() + return reply(update, context, "Hai piantato un nuovo seme. Usa /water per innaffiarlo, magari stavolta un po' più spesso.") + + if plant.stage != 5: + return reply(update, context, "La tua pianta non è ancora pronta per andarsene!") + + plant.start_over() + return reply(update, context, "Complimenti, hai piantato un nuovo seme! Usa /water per innaffiarlo.") +''' +def keyboard_handler(update: Update, context: CallbackContext): + query = update.callback_query + data = query.data + + if data.startswith("reroll"): + amount = int(data.split(" ")[1]) + + if amount <= 1: + return spin(update, context) + return autospin(context, update.effective_chat.id, amount) + + match data: + case "none": + return query.answer("This button doesn't do anything.", context)) + case other: + logging.error(f"unknown callback: {data}") + + return query.answer() + +def unknown(update: Update, context: CallbackContext): + logging.info(f"User {update.message.from_user.full_name} sent {update.message.text_markdown_v2} and I don't know what that means.") +''' +def main(): + + updater = Updater(token=os.getenv("token"), + persistence=PicklePersistence(filename='bot-data.pkl', + store_user_data=False, + store_bot_data=True, + store_callback_data=False, + store_chat_data=False + )) + + dispatcher = updater.dispatcher + + + # commands + dispatcher.add_handler(CommandHandler('start', start)) + dispatcher.add_handler(CommandHandler('water', water)) + dispatcher.add_handler(CommandHandler('show', show)) + dispatcher.add_handler(CommandHandler('harvest', harvest)) + + ''' + # slot + dispatcher.add_handler(CommandHandler('spin', spin)) + dispatcher.add_handler(CommandHandler('bet', bet)) + dispatcher.add_handler(CommandHandler('cash', cash)) + ''' + + ''' + dispatcher.add_handler(CallbackQueryHandler(callback=keyboard_handler)) + dispatcher.add_handler(MessageHandler(Filters.command, unknown)) + ''' + + updater.start_polling() + print(os.getenv("bot_name")) + updater.idle() + +if __name__ == "__main__": + main()
A requirements.txt

@@ -0,0 +1,2 @@

+python-dotenv +python-telegram-bot