Esempio n. 1
0
async def cdoDefaultCategory(msg : Message,**kwargs):
    """
    Sets a default category for the channels created
    :param kwargs: 
    :return: 
    """
    try:
        defaultCategory = Settings.objects.get(name="defaultCategory")
    except ObjectDoesNotExist:
        defaultCategory = None

    if "parameter0" not in kwargs.keys():
        if defaultCategory is not None:
            return CDOInteralResponseData(f"Default category is **{defaultCategory.value}**")
        else:
            return CDOInteralResponseData(f"No default category set yet")

    if defaultCategory is not None:
        defaultCategory.value = kwargs['parameter0']
    else:
        defaultCategory = Settings(name="defaultCategory",value=kwargs['parameter0'])

    defaultCategory.save()

    return CDOInteralResponseData(f"Default category set to **{defaultCategory.value}**")
Esempio n. 2
0
async def cdoSetStartCDO(**kwargs):
    """
    Sets a commandline argument to start the bot.
    :param kwargs:
    :return:
    """
    data = kwargs['msg'].content.split(" ")
    if len(data) == 0:
        return CDOInteralResponseData("You need to set a command to be executed to start the bot")

    commandString = kwargs['msg'].content.replace(data[0] + " ", "")

    obj = Settings(name="startCommando",value=commandString)
    obj.save()
    return CDOInteralResponseData(f"Setting startup command to {commandString}")
Esempio n. 3
0
async def cdoSetPrefix(msg : Message,**kwargs):
    """
    Sets the prefix for the commands
    :param kwargs:
    :return:
    """
    if kwargs['parameter0'] in kwargs.keys():
        return CDOInteralResponseData("You need to set a command to be executed to start the bot")

    commandString = kwargs['parameter0']
    try:
        prefix = Settings.objects.get(name="prefix")
        prefix.value = commandString
    except ObjectDoesNotExist:
        prefix = Settings(name="prefix",value=commandString)

    prefix.save()
    return CDOInteralResponseData(f"New prefix is {prefix.value}")
Esempio n. 4
0
async def cdoSetPrefix(**kwargs):
    """
    Sets the prefix for the commands
    :param kwargs:
    :return:
    """
    data = kwargs['msg'].content.split(" ")
    if len(data) == 0:
        return CDOInteralResponseData("You need to set a command to be executed to start the bot")

    commandString = kwargs['msg'].content.replace(data[0] + " ", "")
    try:
        prefix = Settings.objects.get(name="prefix")
        prefix.value = commandString
    except ObjectDoesNotExist:
        prefix = Settings(name="prefix",value=commandString)

    prefix.save()
    return CDOInteralResponseData(f"New prefix is {prefix.value}")
Esempio n. 5
0
    def show_add_class_window(self):
        discipline = Discipline()
        d_name = discipline.show_name(self.session)
        self.add_class_ui.comboBox.clear()
        self.add_class_ui.comboBox.addItems(d_name)

        group = Group()
        ls_name = group.show_name(self.session)
        self.add_class_ui.comboBox_6.clear()
        self.add_class_ui.comboBox_6.addItems(ls_name)

        c = ClassFormat()
        c_name = c.show_name(self.session)
        self.add_class_ui.comboBox_2.clear()
        self.add_class_ui.comboBox_2.addItems(c_name)

        a = Audience()
        a_name = a.show_name(self.session)
        self.add_class_ui.comboBox_5.clear()
        self.add_class_ui.comboBox_5.addItems(a_name)

        s = Settings()
        schedule_format = s.get(self.session)
        if schedule_format == 0:
            s_name = ['Каждую неделю']
        else:
            s_name = ['Каждую неделю', '1-ая неделя', '2-ая неделя']
        self.add_class_ui.comboBox_4.clear()
        self.add_class_ui.comboBox_4.addItems(s_name)

        date_now = self.add_class_ui.dateEdit.date().currentDate()
        self.add_class_ui.dateEdit.setDate(date_now)
        self.add_class_ui.dateEdit_2.setDate(date_now)
        time_now = self.add_class_ui.timeEdit.time().currentTime()
        self.add_class_ui.timeEdit.setTime(time_now)

        self.add_class_window.show()
Esempio n. 6
0
async def cdoSetStartCDO(msg : Message,**kwargs):
    """
    Sets a commandline argument to start the bot.
    :param kwargs:
    :return:
    """
    if kwargs['parameter0'] not in kwargs.keys():
        if len(Settings.objects.filter(name="startCommando")) == 0:
            return CDOInteralResponseData("You need to set a command to be executed to start the bot")
        else:
            obj = Settings.objects.get(name='startCommando')
            return CDOInteralResponseData(f"Current restart command: _{obj.value}_")
    commandString = kwargs['parameter0']

    try:
        Settings(name="startCommando",value=commandString)
    except IntegrityError:
        obj = Settings.objects.get(name='startCommando')
        obj.value=commandString
        obj.save()

    obj = Settings(name="startCommando",value=commandString)
    obj.save()
    return CDOInteralResponseData(f"Setting startup command to {commandString}")
Esempio n. 7
0
 def show_settings_timetable_window(self):
     s = Settings()
     schedule_format = s.get(self.session)
     self.settings_timetable_ui.comboBox.setCurrentIndex(
         int(schedule_format))
     self.settings_timetable_window.show()
Esempio n. 8
0
 def save(self):
     new_value = self.comboBox.currentIndex()
     s = Settings()
     s.set(self.session, new_value)
     self.settings_timetable_window.close()