Example #1
0
func publishArticle(articleTitle, articleBody string, forumID int, user *pekar.Pekar) error {

	log.Printf("Publishing article to the http://forum.sc2tv.ru/forums/%v\n", forumID)

	log.Println("logging in as ", user.Name)

	if isLg, err := user.IsLogged(); err != nil {
		return err
	} else {
		if !isLg {
			if err = user.LoginForum(); err != nil {
				return err
			}
		}
	}
	log.Println("Forum login successful")

	if isB, err := user.IsBanned(); err != nil {
		return err
	} else {
		if isB {
			return errors.New(user.Name + " was banned")
		}
	}

	if err := user.CreateThread(forumID, articleTitle, articleBody); err != nil {
		return err
	}

	log.Println("Article published!")
	time.Sleep(1 * time.Minute)

	return nil
}
Example #2
0
func publishArticle(articleTitle, articleBody string, forumID int, user *pekar.Pekar) error {

	log.Printf("Publishing article to the http://forum.sc2tv.ru/forums/%v\n", forumID)

	cmd := exec.Command("/usr/bin/tor")
	if err := cmd.Start(); err != nil {
		return err
	}
	torPidS := strconv.Itoa(cmd.Process.Pid)
	log.Printf("Launching Tor(PID:%v)..\n", torPidS)
	defer cmd.Process.Kill()

	if transport, err := makeTorTransport(); (err != nil) ||
		(transport == nil) {
		return err
	} else {
		log.Println("Tor transport created")
		user.Client.Transport = transport
	}

	log.Println("logging in as ", user.Name)

	if isLg, err := user.IsLogged(); err != nil {
		return err
	} else {
		if !isLg {
			if err = user.LoginForum(); err != nil {
				return err
			}
		}
	}
	log.Println("Forum login successful")

	if isB, err := user.IsBanned(); err != nil {
		return err
	} else {
		if isB {
			curAccID++
			return errors.New(user.Name + " was banned")
		}
	}

	if err := user.CreateThread(forumID, articleTitle, articleBody); err != nil {
		return err
	}

	log.Println("Article published!")

	return nil
}