-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot_server.py
33 lines (21 loc) · 1.01 KB
/
bot_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import time
import os
import telebot
BOT_TOKEN = os.environ['BOT_TOKEN']
bot = telebot.TeleBot(BOT_TOKEN, parse_mode='markdown')
help_msg = """Howdy, this is a bot that can notify you via TG when your slurm job finishes on certain clusters.
Below are steps to use this bot.
1. Send `/getcid` to this bot, and get your unique CID
2. Run `snotified.sh <CID>` on head node of the cluster (maybe use a tmux session to keep it always online)
3. Use `srun` with argument `--mail-type=END` (see more in `man srun`) to get notified for this job.
"""
@bot.message_handler(commands=['start', 'hello'])
def send_welcome(message):
print('[{}] Recv msg: {} {}'.format(time.time(), message.chat.id, message.chat.username))
bot.reply_to(message, help_msg)
@bot.message_handler(commands=['getcid'])
def bind_user(message):
cid = message.chat.id
print('[{}] Recv cid: {} {}'.format(time.time(), message.chat.id, message.chat.username))
bot.reply_to(message, 'Please remember your cid: `{}`'.format(cid))
bot.polling()