use markovify
This commit is contained in:
@@ -4,6 +4,7 @@ from random import choice, seed
|
||||
from uuid import uuid4
|
||||
|
||||
import humanize
|
||||
import markovify
|
||||
from django.db import models
|
||||
from django.utils.timezone import localdate, now, make_aware
|
||||
from jsoneditor.forms import JSONEditor
|
||||
@@ -14,7 +15,6 @@ from telegram.ext import Dispatcher, CallbackContext, MessageHandler, Filters, C
|
||||
from telegram.utils.helpers import mention_html
|
||||
|
||||
from bots.models import TelegramBotModuleConfig
|
||||
from bots.modules._mtg import MTG
|
||||
|
||||
|
||||
class CyberLinaBotModuleConfig(TelegramBotModuleConfig):
|
||||
@@ -42,7 +42,7 @@ class CyberLinaBotModuleConfig(TelegramBotModuleConfig):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.mtg = MTG(self._mtg_data)
|
||||
self.mtg = markovify.Text.from_dict(self._mtg_data)
|
||||
|
||||
def message_handler(self, update: Update, ctx: CallbackContext):
|
||||
if not update.effective_chat or not update.effective_user:
|
||||
@@ -114,9 +114,7 @@ class CyberLinaBotModuleConfig(TelegramBotModuleConfig):
|
||||
|
||||
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
|
||||
if self.mtg_train:
|
||||
self.mtg.train_from_text(self.mtg_train)
|
||||
self._mtg_data = self.mtg.save()
|
||||
self.mtg_train = None
|
||||
self._mtg_data = markovify.Text(self.mtg_train).to_dict()
|
||||
super().save(force_insert, force_update, using, update_fields)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user