lodash#pull TypeScript Examples

The following examples show how to use lodash#pull. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: subscribe.ts    From Adachi-BOT with MIT License 6 votes vote down vote up
function subscribe( userID: number, send: SendFunc, a: AuthLevel, CONFIRM: Order ): string {
	if ( tempSubscriptionList.includes( userID ) ) {
		return "您已经处于私人服务申请状态";
	}
	
	tempSubscriptionList.push( userID );
	
	const d = new Date();
	scheduleJob( d.setMinutes( d.getMinutes() + 3 ), async () => {
		const isFinish: number | undefined = tempSubscriptionList.find( el => el === userID );
		
		if ( isFinish !== undefined ) {
			pull( tempSubscriptionList, userID );
			await send( "私人服务申请超时,BOT 自动取消" );
		}
	} );
	
	return "这是一条提醒,请确保你非常明确你在做什么\n" +
			"如果要开启私人服务功能,必须提供你的米游社 cookie\n" +
			"这可能会导致你的账号出现安全风险,请务必确保 BOT 持有者可信\n" +
			`如果确定开启该功能,使用「${ CONFIRM.getHeaders()[0] }+cookie」来继续\n` +
			"你可以在 https://docs.adachi.top/faq 中查看获取 cookie 的方法\n" +
			"这需要在 3 分钟内进行,此后将会自动取消本次申请";
}
Example #2
Source File: subscribe.ts    From Adachi-BOT with MIT License 6 votes vote down vote up
async function confirm(
	userID: number, cookie: string,
	a: AuthLevel, SUBSCRIBE: Order
): Promise<string> {
	if ( !tempSubscriptionList.some( el => el === userID ) ) {
		return `你还未申请私人服务,请先使用「${ SUBSCRIBE.getHeaders()[0] }」`;
	}
	
	const reg = new RegExp( /.*?ltuid=([0-9]+).*?/g );
	const execRes: RegExpExecArray | null = reg.exec( cookie );
	
	if ( execRes === null ) {
		return "无效的 cookie,请重新提交正确的 cookie";
	}
	
	const mysID: number = parseInt( execRes[1] );
	const { retcode, message, data } = await getBaseInfo( mysID, cookie );
	
	if ( !ApiType.isBBS( data ) ) {
		return ErrorMsg.UNKNOWN;
	} else if ( retcode !== 0 ) {
		return ErrorMsg.FORM_MESSAGE + message;
	} else if ( !data.list || data.list.length === 0 ) {
		return ErrorMsg.NOT_FOUND;
	}
	
	const genshinInfo: ApiType.Game | undefined = data.list.find( el => el.gameId === 2 );
	if ( !genshinInfo ) {
		return ErrorMsg.NOT_FOUND;
	}
	
	const uid: string = genshinInfo.gameRoleId;
	pull( tempSubscriptionList, userID );
	return await privateClass.addPrivate( uid, cookie, userID );
}
Example #3
Source File: main.ts    From Adachi-BOT with MIT License 6 votes vote down vote up
public async delPrivate( p: Private ): Promise<void> {
		Object.values( p.services ).forEach( ( service ) => {
			if ( 'toggleEnableStatus' in service ) {
				service.toggleEnableStatus( false, false );
			}
		} )
		pull( this.list, p );
		await bot.redis.deleteKey( p.dbKey );
	}
Example #4
Source File: index.tsx    From next-basics with GNU General Public License v3.0 6 votes vote down vote up
private _updateUrlChecked = (options: any[], checked) => {
    const history = getHistory();
    let checkedOptions: string[] = this._getCheckedFromUrl();
    if (checked) {
      checkedOptions = [...checkedOptions, ...options];
    } else {
      pull(checkedOptions, ...options);
    }
    if (this.shouldUpdateUrlParams) {
      history.pushQuery(
        { checked: checkedOptions.join(",") },
        { notify: false }
      );
    }
  };
Example #5
Source File: index.tsx    From next-basics with GNU General Public License v3.0 6 votes vote down vote up
// 点击展开图标时触发的事件
  // istanbul ignore next
  private _handleOnExpand = (
    expanded: boolean,
    record: Record<string, any>
  ): void => {
    if (this.expandedRowKeys) {
      const rowKey =
        this.rowKey ?? this._fields.rowKey ?? this.configProps?.rowKey;
      const pullKeys: string[] = [get(record, rowKey)];
      const recordChildren = get(record, this.childrenColumnName);
      if (!isEmpty(recordChildren)) {
        const keysToPull = map(
          filter(recordChildren, (c) =>
            isEmpty(get(c, this.childrenColumnName))
          ),
          rowKey
        );
        pullKeys.push(...keysToPull);
      }
      this.expandedRowKeys = expanded
        ? [...this.expandedRowKeys, ...pullKeys]
        : pull(this.expandedRowKeys, ...pullKeys);
      this._render();
    }
    this.rowExpand.emit({
      expanded,
      record,
    });
  };