matrix/telegram: workaround for broken mautrix-telegram

Change-Id: I79e4ff0513f3f2fc25fdf655942627655f1b4900
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1858
Reviewed-by: implr <implr@hackerspace.pl>
diff --git a/app/matrix/lib/appservice-telegram.libsonnet b/app/matrix/lib/appservice-telegram.libsonnet
index 0d5341b..b5fadea 100644
--- a/app/matrix/lib/appservice-telegram.libsonnet
+++ b/app/matrix/lib/appservice-telegram.libsonnet
@@ -138,6 +138,23 @@
                                 volumeMounts_: {
                                     data: { mountPath: "/data" },
                                 },
+
+                                # Dirty hack to schedule telegram bridge at 3AM
+                                # every day. mautrix_telegram/telethon seems to
+                                # have a nasty bug that makes it think the
+                                # connection to telegram service is open, even
+                                # though none of the events pass through. This
+                                # is the dumbest and most effective way of
+                                # solving this without delving into their
+                                # codebase...
+                                livenessProbe: {
+                                    exec: {
+                                        command: ["exit $(test $(date +%H) -eq 3 && echo 1 || echo 0)"],
+                                    },
+                                    failureThreshold: 1,
+                                    initialDelaySeconds: 3600,
+                                    periodSeconds: 60,
+                                },
                             },
                         },
                     },