예제 #1
0
	def get(self):
		twitter = TwitterAuth()
		twitterapi = twitter.getAuth()
		tl = twitterapi.friends_timeline()
		#texts = ''
		results = []
		soup = TestSoup()
		for line in tl:
			# @、URL、Photo、RTなどの文字列を弾く
			text = self.deleteObstacle(line.text)
			result = soup.getFromY(text) # 配列が返ってくる
			for w in result:
				results.append(w)
		#for b in results:
		#	self.response.out.write(b)
		#	self.response.out.write('<br />')
		#self.response.out.write('-----------------------<br />')
		updateText = ''
		if len(results)!=0:
			results.sort()
			manylist = self.checkMany(results)
			if len(manylist)!=0:
				text = u'と'.join(manylist)
				updateText = u'%sが盛り上がってるかも!' % text
			else:
				updateText = u'(´・ω・`)うーん'
		else:
			updateText = u'(´・ω・`)あれ?'
		self.response.out.write(updateText)
		twitter.update(twitterapi,updateText)
예제 #2
0
	def get(self):
		twitter = TwitterAuth()
		twitterapi = twitter.getAuth()
		#money = Money(category=u'',money=150)
		#money.put()
		key = db.Key.from_path('SinceId','dm_last')
		now_sinceid = db.get(key).sinceid
		self.response.out.write(now_sinceid)
		now_sinceid = long(now_sinceid)
		dmlist = twitterapi.direct_messages(now_sinceid)
		p = re.compile(u'(.+)?@(\d+)?円')
		if len(dmlist) != 0:
			dmlist.reverse()
			for line in dmlist:
				#self.response.out.write(line.text)
				#self.response.out.write(line.id)
				#self.response.out.write(line.sender_id)
				#self.response.out.write(line.sender_screen_name)
				#self.response.out.write(line.created_at)
				if line.sender_screen_name == 'eibiisii':
					if u'円' and u'@' in line.text:
						a = p.search(line.text)
						self.response.out.write(a.group(1))
						self.response.out.write(" ")
						self.response.out.write(a.group(2))
						self.response.out.write(" ")
						money = Money(category=a.group(1),money=int(a.group(2)),date=line.created_at)
						money.put()
			twitter.update(twitterapi,u'@eibiisii できたよ!')
			now_sinceid = dmlist.pop().id
			self.response.out.write(now_sinceid);
			t = SinceId(key_name="dm_last",sinceid=str(now_sinceid))
			t.put()
		else:
			self.response.out.write(u'DMないよ!');
예제 #3
0
	def get(self):
		findlist = self.doParse()
		twitter = TwitterAuth()
		twitterapi = twitter.getAuth()
		rnd = random.randint(0,len(findlist)-1)
		tweet = u'@eibiisii これつくってー! / %s %s' % (findlist[rnd].string, findlist[rnd]['href'])
		twitter.update(twitterapi,tweet)
		self.response.out.write(tweet)
예제 #4
0
	def get(self):
		twitter = TwitterAuth()
		twitterapi = twitter.getAuth()
		#p = Status(content=u"できたかなー")
		#p.put()
		posts_query = Status.all()
		posts = posts_query.fetch(1000)
		post = posts[random.randint(0,len(posts)-1)].content
		self.response.out.write(post)
		twitter.update(twitterapi,post)
예제 #5
0
	def get(self):
		twitter = TwitterAuth()
		twitterapi = twitter.getAuth()
		key = db.Key.from_path('SinceId','m_last')
		now_sinceid = db.get(key).sinceid
		self.response.out.write(now_sinceid)
		now_sinceid = long(now_sinceid)
		mentionlist = twitterapi.mentions(now_sinceid)
		if len(mentionlist) != 0:
			mentionlist.reverse()
			cooking = Cooking()
			findlist = cooking.doParse()
			#osusumeMyIdList = OsusumeMyId.all()
			#osusumeMyIdLists = osusumeMyIdList.fetch(1000)
			for line in mentionlist:
				'''
				for osusumeMyId in osusumeMyIdLists:
					if str(line.in_reply_to_status_id) == osusumeMyId.statusid:
						category_name = osusumeMyId.key().name()
						#str(category_name)
						self.response.out.write(u'成功だよ!')
						soup = TestSoup()
						line_text = line.text.replace('@eibiisii_bot','')
						osusume_good = soup.getKeyPhrase(line_text)
						self.response.out.write(osusume_good)
						#osusume_good = str(osusume_good)
						status = u'「%s」' % osusume_good
						statusid = line.id
						screen_name = line.user.screen_name
						#screen_name = str(screen_name)
						text = u'@%s %s へー' % (screen_name,status)
						twitter.reply_update(twitterapi,text,statusid)
						self.response.out.write(text)
						osusume_good = unicode(str(osusume_good),'utf-8')
						o = Osusume(user_name=screen_name,osusume=osusume_good)
						o.put()
						break
					continue
				'''
				if u'料理' in line.text:
					rnd = random.randint(0,len(findlist)-1)
					status = u'これつくってー! / %s %s' % (findlist[rnd].string, findlist[rnd]['href'])
					screen_name = line.user.screen_name
					statusid = line.id
					text = u"@%s %s" % (screen_name,status)
					twitter.reply_update(twitterapi,text,statusid)
					self.response.out.write(text)
				else:
					continue
			new_sinceid = mentionlist.pop().id
			d = SinceId(key_name="m_last",sinceid=str(new_sinceid))
			d.put()
예제 #6
0
	def get(self):
		parse = MyHTMLParser()
		findlist = parse.getFromS()
		url = 'http://www.genkotsu-hb.com/'
		for find in findlist:
			text = find.string
			self.response.out.write(text)
			if u'創業価格フェア' in text:
				text = '%s%s%s%s' % (u'@eibiisii 「',text,u'」だって!―炭焼きレストランさわやか ',url)
				self.response.out.write(text)
				twitter = TwitterAuth()
				twitterapi = twitter.getAuth()
				twitter.update(twitterapi,tweet)
예제 #7
0
	def get(self):
		twitter = TwitterAuth()
		twitterapi = twitter.getAuth()
		categories = [u'漫画',u'映画',u'音楽',u'アニメ']
		index = random.randint(0,len(categories)-1)
		tweet = u'@eibiisii6 !' % categories[index]
		twitter.update(twitterapi,tweet)
		mytweets = twitterapi.user_timeline(screen_name = 'eibiisii_bot',count = 1)
		if len(mytweets) != 0:
			last_tweet_id = mytweets[0].id
			self.response.out.write(last_tweet_id)
			o = OsusumeMyId(key_name = categories[index],statusid = str(last_tweet_id))
			o.put()
예제 #8
0
	def get(self):
		twitter = TwitterAuth()
		twitterapi = twitter.getAuth()
		key = db.Key.from_path('SinceId','tl_last')
		now_sinceid = db.get(key).sinceid
		self.response.out.write(now_sinceid)
		now_sinceid = long(now_sinceid)
		tl = twitterapi.friends_timeline(since_id=now_sinceid)
		texts = ''
		i = 1
		for line in tl:
			if i==1:
				now_sinceid = line.id
				i = i+1
			text = line.text
			if '@' in text:
				text = re.sub('@\w+?\s','',text)
			self.response.out.write(text)
			self.response.out.write("<br />")
			texts = '%s%s' % (texts,text)
		self.response.out.write(texts)
		self.response.out.write(now_sinceid)
		t = SinceId(key_name="tl_last",sinceid=str(now_sinceid))
		t.put()
예제 #9
0
 def __init__(self, tokens, debug=False):
     self.tokens = tokens
     self.DEBUG = debug
     self.tw = TwitterAuth(self.tokens)
예제 #10
0
 def post(self, tweet):
     twitter = TwitterAuth()
     twitter.post(tweet)
예제 #11
0
import logging

from twitter import TwitterAuth, TwitterApi
from resources.config import configuration

logging.getLogger("").setLevel(logging.INFO)

twitter = TwitterApi(
    TwitterAuth.get_oauth1_auth(
        configuration["twitter"]["consumer_key"],
        configuration["twitter"]["consumer_secret"],
        configuration["twitter"]["access_token_key"],
        configuration["twitter"]["access_token_secret"],
    ))


def main():
    global twitter
    from resources.flask_server import app

    app.run(
        host=configuration["http"]["bind"]["host"],
        port=configuration["http"]["bind"]["port"],
        debug=False,
        threaded=True,
    )