0rx

ival-command-for-chatango-bot

0rx
Jun 8th, 2016
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.57 KB | None | 0 0
  1. #####################################################################################################
  2. #  I WILL REMIND YOU, TO USE THIS IVAL COMMAND, YOU WILL NEED TO EDIT
  3. #  YOUR CH.PY ON THIS PART:
  4. #
  5. #  class Room:   #IT'S NOT EXACTLY LIKE THIS, But you will know when you find somthing similiar in ch.py
  6. #     def __init__(self, room, uid = None, server = None, port = None, mgr = None):
  7. #         """
  8. #         JUST BELOW def __init__(self, room, uid = None, server = None, port = None, mgr = None):
  9. #         YOU NEED TO ADD THIS THING --> self._ivalTasks = {}
  10. #         """
  11. #
  12. #         self._ivalTasks = {}  ## <<---- Yup, just add this thing
  13. #
  14. ##################################################################################################
  15. # if you ever feel confused even after reading the notice up ^ there , feel free to PM me (0rx)
  16. # GOOD LUCK !
  17. #################################################################################################
  18.  
  19.         if cmd == "ival":
  20.             interval_task = room._ivalTasks  #READ the instruction above regarding room._ivalTasks !!!!!
  21.             args = args.split(" ", 1)
  22.             if args[0] == "kill": # to kill a task - you need to do -> !ival kill TASKNAME
  23.                 if len(args) == 2:
  24.                     if args[1] in interval_task:
  25.                         self._tasks.remove(interval_task[args[1]][0])
  26.                         room.message("Task killed: "+str(args[1])+" - "+str(interval_task[args[1]][0]))
  27.                         interval_task.pop(args[1])
  28.             if args[0] == "tasks": # To check on task list of current room - you need to do -> !ival tasks
  29.                 if len(interval_task) > 0:
  30.                     tasklist = []
  31.                     for i in interval_task:
  32.                         _task = interval_task
  33.                         tasklist.append("(Name: "+str(i)+" - (every "+str(_task[i][1])+" seconds) post "+str(_task[i][2])+" ["+str(_task[i][0])+"])")
  34.                     room.message(", ".join(tasklist))
  35.             if args[0] not in ["kill", "tasks"]: # To create a task - you need to do -> !ival TASKNAME <time> <interval_message>
  36.                 if len(args) > 1:
  37.                     task_name = args[0]
  38.                     ivaltime, task_output = args[1].split(" ", 1)
  39.                     task_interval_time = int(ivaltime)
  40.                     task = self.setInterval(task_interval_time, room.message, str(task_output))
  41.                     interval_task.update({task_name:[task, ivaltime, task_output]})
  42.                     room.message("task created: "+str(task_name)+" ("+str(ivaltime)+" seconds interval)")
Advertisement
Add Comment
Please, Sign In to add comment