Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return jsonDb.get('threads', []).then(threads => {
const thread = threads.find(t => t.userId === user.id);
if (thread) return thread;
// If we didn't find an existing modmail thread, attempt creating one
if (! allowCreate) return null;
// Channel names are particularly picky about what characters they allow...
let cleanName = transliterate.slugify(user.username);
if (cleanName === '') cleanName = 'unknown';
cleanName = cleanName.slice(0, 95); // Make sure the discrim fits
const channelName = `${cleanName}-${user.discriminator}`;
if (originalMessage && originalMessage.cleanContent && config.ignoreAccidentalThreads) {
const cleaned = originalMessage.cleanContent.replace(/[^a-z\s]/gi, '').toLowerCase().trim();
if (accidentalThreadMessages.includes(cleaned)) {
console.log('[NOTE] Skipping thread creation for message:', originalMessage.cleanContent);
return null;
}
}
console.log(`[NOTE] Creating new thread channel ${channelName}`);
return getUtils().getInboxGuild().createChannel(`${channelName}`)
.then(channel => {
commands.addInboxThreadCommand('move', '', async (msg, args, thread) => {
const searchStr = args.category;
const normalizedSearchStr = transliterate.slugify(searchStr);
const categories = msg.channel.guild.channels.filter(c => {
// Filter to categories that are not the thread's current parent category
return (c instanceof Eris.CategoryChannel) && (c.id !== msg.channel.parentID);
});
if (categories.length === 0) return;
// See if any category name contains a part of the search string
const containsRankings = categories.map(cat => {
const normalizedCatName = transliterate.slugify(cat.name);
let i = 0;
do {
if (! normalizedCatName.includes(normalizedSearchStr.slice(0, i + 1))) break;
i++;
err: '未配置'
}
event.sender.send('qina', returnMsg)
return false;
}
if (val.Access == null || val.Bucket == null || val.Domain == null || val.Secret == null) {
returnMsg = {
state: false,
err: '配置不全'
}
event.sender.send('qina', returnMsg)
return false;
}
var key = transliteration.slugify(arg.Name) + '(' + moment().format() + ')' + path.extname(arg.Name);
var filePath = path.normalize(arg.Path);
var client = qn.create({
accessKey: val.Access,
secretKey: val.Secret,
bucket: val.Bucket,
origin: val.Domain,
});
console.log('qn 开始上传');
client.uploadFile(filePath, {
key: key
}, function(err, ret) {
console.log(ret);
if (!err) {
export default function getSlug(slugString) {
return (typeof slugString === "string" && slugify(slugString)) || "";
}
async add() {
if (this.isPost()) {
const article = this.post;
article.pinyin = slugify(article.title);
await this.model('article').add(article);
this.json('/admin/article/index', '保存成功');
} else {
if (this.query.id) {
var article = await this.model('article', {withRelated: ['file']}).find({id: this.query.id});
await this.render('article_add', {article: article});
} else {
await this.render('article_add');
}
}
}
}
indices = indices.concat(matches.map(match => {
const isComponent = match[0].indexOf('##') < 0;
const title = match[0].replace(/#{1,4}/, '').trim();
const index = { component: getComponentName(component), title };
index.ranking = isComponent ? 2 : 1;
index.anchor = slugify(title);
index.content = (match[1] || title).replace(/<[^>]+>/g, '');
return index;
}));
});
async add() {
if (this.isPost()) {
const page = this.post;
page.pinyin = slugify(page.name);
await this.model('page').add(page);
this.json('/admin/page/index', '保存成功');
} else {
if (this.query.id) {
var page = await this.model('page').find({id: this.query.id});
await this.render('page_add', {page: page});
} else {
await this.render('page_add');
}
}
function createSlug() {
var model = identity.model
var name = data ? data.name.id : ''
return (name === '' || model.toLowerCase() === name.toLowerCase()) ?
tr.slugify(model) :
tr.slugify(name + ' ' + model)
}
function createSlug() {
var model = identity.model
var name = data ? data.name.id : ''
return (name === '' || model.toLowerCase() === name.toLowerCase()) ?
tr.slugify(model) :
tr.slugify(name + ' ' + model)
}
export function H4(props) {
const { children } = props;
const id = slugify(children);
return (
<h4>
<a href="{`#${id}`}">¶</a>
<a id="{id}">
{children}
</a></h4><a id="{id}">
);
}
</a>