خرید بک لینک

Vote count: 0

from bin import pmGetter
from threading import Thread
import time

possibleRequests = ['test', 'test1']
inbox = []

inbox = pmGetter.getPms()


# time to do threading
def pmGetterLoop():
    while True:
        inbox = pmGetter.getPms()


def inboxReader():
    print('triggered')
    while True:
        tempInbox = []
        tempInbox = inbox.inboxMessage #inboxMesage remains filled?
        print(inbox.inboxMessage)
        i = 0
        while (i < len(tempInbox)):
            if (tempInbox[i] in possibleRequests):
                print('THIS IS WORKING')
            #print(i)
            i+=1
        time.sleep(2)

def commandBreaker(commandString):
    retu commandString.split(',')


threadOne = Thread(target=pmGetterLoop)
threadTwo = Thread(target=inboxReader)

threadTwo.start()
threadOne.start()

#print(commandBreaker('this,is,a,test'))#this is what will be used to split commands

this is the main

import praw
import time


class getPms():
    r = praw.Reddit(user_agent="Test Bot By /u/**********")
    r.login(useame='******************', password='*************')

    cache = []
    inboxMessage = []
    file = 'cache.txt'

    def __init__(self):

        self.cache = self.cacheRead(self.file)
        self.bot_run()
        self.cacheSave(self.file)
        time.sleep(2)
        #retu self.inboxMessage

    def bot_run(self):
        print(self.inboxMessage, ' why?')
        self.inboxMessage = []
        inbox = self.r.get_inbox(limit=25)

        # print(r.get_friends())#this works
        for message in inbox:
            if message.id not in self.cache:
                #print(message.id)
                print(message.body)
                # print(message.subject)
                self.cache.append(message.id)
                self.inboxMessage.append(message.body)
                # else:
                # print("no messages")

    def cacheSave(self, file):
        with open(file, 'w') as f:
            for s in self.cache:
                f.write(s + 'n')

    def cacheRead(self, file):
        with open(file, 'r') as f:
            cache1 = [line.rstrip('n') for line in f]
        retu cache1

for some reason I get this output

[] why? test this is a test triggered ['test', 'this is a test'] THIS IS WORKING [] why? #this is from getPms.bot_run() ['test', 'this is a test']#this is from def inboxReader THIS IS WORKING

where the [] why? indicates that the array has been emptied but ['test', this is a test'] indicates that the array has still been filled

I attempt to empty the array by doing self.inboxMessage = []

asked 41 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 خرداد 1395 ساعت: 0:02

صفحه بندی