コード例 #1
0
    # user = int(sys.argv[2])
    cfg = Settings(CFG_FILE)
    cfg_dict = cfg.read_section(CFG_FORUM)
    phpbb = PhpBB(cfg_dict['host'])
    # forum.setUserAgent(cfg.user_agent)
    if phpbb.login(cfg_dict['username'], cfg_dict['password']):
        print('Login')
        for top in topic_list:
            topic = f'viewtopic.php?f={top.f}&t={top.t}'
            post_list = phpbb.get_topic_posts(topic, int(
                cfg_dict['max_count']))  # noqa: E501
            n = len(post_list)
            print(f"{n} posts dans ce topic")
            print("===================")

            post_list = PostList([p for p in post_list[1:] if p.old > 365])

            print("===================")
            post_list.print_posts()
            print("===================")
            print("TOUS LES MESSAGES précédents seront SUPPRIMÉS !!!")
            print("Vous pouvez supprimer les messages ?")
            phpbb.delete_post_list(post_list)
    else:
        print('> Login failed')
    phpbb.logout()
    phpbb.close()
except KeyboardInterrupt:
    print("\nAu revoir")
    sys.exit(0)
コード例 #2
0
            )
            target = postlist.merci_list(regex1, regex2, regex3)
            print("Target list")
            target.print_posts()
            target.log_posts(logfile)
            if len(target) == 0:
                print("Nothing to do in this topic")
            else:
                print(f"Vous pouvez supprimer {len(target)} messages")
                # Join = input('Voulez-vous continuer ? '
                #              '(Seuls les posts humains '
                #              'seront supprimés) '
                #              '(y/n) ?\n')
                # if Join.lower() == 'yes' or Join.lower() == 'y':
                print("Processing")
                phpbb.delete_post_list(target)
                # else:
                #     print ("Ok, Exit")
            # Dump number of posts in the database
            table.upsert({'topic': topic_id,
                          'posts': nb_posts - len(target)},
                         pk='topic')

        # Treat a forum
        elif mode == 2:
            while True:
                choice = int(input(Const.SECTION_CHOICE))
                if choice < 1 or choice > 10:
                    print("\nValeur incorrect")
                else:
                    break