ChaterJee 0.4.8__py3-none-any.whl → 0.4.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ChaterJee/ChaterJee.py CHANGED
@@ -42,6 +42,8 @@ class ChatLogs:
42
42
  self.smsID = []
43
43
  self.dict = {}
44
44
  self.jobs = {}
45
+ self.runexe = "run.sh"
46
+ self.killexe = "kill_run.sh"
45
47
 
46
48
  def cmdTRIGGER(self, read_timeout=7, get_updates_read_timeout=42):
47
49
  #que = asyncio.Queue()
@@ -52,6 +54,9 @@ class ChatLogs:
52
54
  start_handler = CommandHandler('start', self.start)
53
55
  application.add_handler(start_handler)
54
56
 
57
+ jobrun_handler = CommandHandler('run', self.runjob)
58
+ application.add_handler(jobrun_handler)
59
+
55
60
  #fEdit_handler = CommandHandler('edit', self.EditorBabu)
56
61
  #application.add_handler(fEdit_handler)
57
62
 
@@ -64,11 +69,13 @@ class ChatLogs:
64
69
  jobs_handler = ConversationHandler(\
65
70
  entry_points=[CommandHandler("jobs", self.ShowJobs),\
66
71
  CommandHandler("clear", self.ask2clear),\
67
- CommandHandler("edit", self.EditorBabu)],\
72
+ CommandHandler("edit", self.EditorBabu),\
73
+ CommandHandler("kill", self.ask2kill)],\
68
74
  states={
69
75
  0: [MessageHandler(filters.Regex("^(JOB)"), self.StatJobs)],
70
76
  1: [MessageHandler(filters.Regex("^(Yes|No)$"), self.ClearChat)],
71
77
  2: [MessageHandler(filters.Regex("^(FILE)"), self.SendEditButton)],
78
+ 3: [MessageHandler(filters.Regex("^(Yes|No)$"), self.killjob)],
72
79
  },
73
80
  fallbacks=[CommandHandler("cancel", self.cancel)],
74
81
  )
@@ -372,6 +379,49 @@ class ChatLogs:
372
379
  self.smsID.append(msg.message_id)
373
380
  return 1
374
381
 
382
+ async def runjob(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
383
+ cmd = f"./{self.runexe}"
384
+ try:
385
+ os.popen('%s'%(cmd))#.read()
386
+ self.txt='job submitted !'
387
+ except:
388
+ self.txt='error !'
389
+ await self.sendUpdate(update, context)
390
+
391
+ async def ask2kill(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
392
+ self.smsID.append(update.message.message_id)
393
+ reply_keyboard = [['Yes','No']]
394
+ print(reply_keyboard)
395
+ await context.bot.sendChatAction(chat_id=self.CHATID, action="typing")
396
+ msg = await update.message.reply_text("Your job will be killed. Proceed?",\
397
+ reply_markup=ReplyKeyboardMarkup(reply_keyboard, one_time_keyboard=True, input_field_placeholder="Select to proceed."\
398
+ ),\
399
+ )
400
+ self.smsID.append(msg.message_id)
401
+ return 3
402
+
403
+ async def killjob(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
404
+ cmd = f"./{self.killexe}"
405
+ try:
406
+ txt = os.popen('%s'%(cmd)).read()
407
+ except:
408
+ txt='error !'
409
+
410
+ self.smsID.append(update.message.message_id)
411
+ if update.message.text == 'Yes':
412
+ txt = os.popen('%s'%(cmd)).read()
413
+ await context.bot.sendChatAction(chat_id=self.CHATID, action="typing")
414
+ msg = await update.message.reply_text(
415
+ txt, reply_markup=ReplyKeyboardRemove()
416
+ )
417
+ elif update.message.text == 'No':
418
+ await context.bot.sendChatAction(chat_id=self.CHATID, action="typing")
419
+ msg = await update.message.reply_text(
420
+ "Your job is not killed.", reply_markup=ReplyKeyboardRemove()
421
+ )
422
+ self.smsID.append(msg.message_id)
423
+ return ConversationHandler.END
424
+
375
425
 
376
426
  class NoteLogs:
377
427
  def __init__(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ChaterJee
3
- Version: 0.4.8
3
+ Version: 0.4.9
4
4
  Summary: Communicate your project updates via Telegram Bot!
5
5
  Author: Pallab Dutta
6
6
  Author-email: pallab9997@gmail.com
@@ -0,0 +1,6 @@
1
+ ChaterJee/ChaterJee.py,sha256=FC6VWnyYapsz8MMkPxWQ1wnw1jMYktK7rqCr2t19K-k,19091
2
+ ChaterJee/__init__.py,sha256=tZmkZY2XbzJ8rHDh8nOmb1W73kPecPv3xcEiCPwkZf4,98
3
+ chaterjee-0.4.9.dist-info/METADATA,sha256=FWyYAxRpy4SyYyLAxnUPRpswDNCYXHcg7CtCrM45I8s,5872
4
+ chaterjee-0.4.9.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
5
+ chaterjee-0.4.9.dist-info/top_level.txt,sha256=Z1UAYoaNybpDiKjqa1yFpti_q0FNECVItb3-9yAh3gM,10
6
+ chaterjee-0.4.9.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- ChaterJee/ChaterJee.py,sha256=jWaPQ3zbhhveQXuGIW0rNlJ3GYtSbgph0L94Tcn_8sk,16990
2
- ChaterJee/__init__.py,sha256=tZmkZY2XbzJ8rHDh8nOmb1W73kPecPv3xcEiCPwkZf4,98
3
- chaterjee-0.4.8.dist-info/METADATA,sha256=qtY-cXRQfLpdZS1LYOrkFs6B6n7To1mMsmH98T87roE,5872
4
- chaterjee-0.4.8.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
5
- chaterjee-0.4.8.dist-info/top_level.txt,sha256=Z1UAYoaNybpDiKjqa1yFpti_q0FNECVItb3-9yAh3gM,10
6
- chaterjee-0.4.8.dist-info/RECORD,,