-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.rb
150 lines (131 loc) · 4.54 KB
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
require("sinatra")
require("sinatra/reloader")
require('sinatra/activerecord')
also_reload("lib/**/*.rb")
require('./lib/emoji')
require('./lib/keyword')
require('./lib/sentence')
require('./lib/tweet')
require('./lib/translate')
require("pg")
require('easy_translate')
require('dotenv')
require('pry')
require('./lib/emoji')
require('./lib/keyword')
require('./lib/sentence')
require('./lib/add_tags')
require('./lib/music_notes')
Dotenv.load
get('/') do
@user_tweets = $twitter_client.user_timeline('Twittamir_Putin')
@tweets = []
@translated = []
erb(:index)
end
post('/') do
end
post('/tweet') do
tweet = params['tweet']
putin = params['putin']
if putin == "on"
tweet = '@KremlinRussia_E ' + tweet
end
$twitter_client.update(tweet)
redirect('/emoji')
end
post('/tweet_search') do
tweet = params['tweet']
putin = params['putin']
if putin == "on"
tweet = '@KremlinRussia_E ' + tweet
end
$twitter_client.update(tweet)
redirect('/keyword_search')
end
post('/tweet_search_soviet') do
tweet = params['tweet']
tweet = '@KremlinRussia_E ' + tweet
$twitter_client.update(tweet)
redirect('/keyword_search/soviet')
end
get('/keyword_search') do
@user_tweets = $twitter_client.user_timeline('Twittamir_Putin')
@tweets = []
@translated = []
erb(:keyword_search)
end
post('/keyword_search') do
@user_tweets = $twitter_client.user_timeline('Twittamir_Putin')
search_term = params['search-term']
@translated = []
# language = params['language'].to_sym
if !search_term.count("a-zA-Z0-9").zero?
@tweets = $twitter_client.search(search_term, result_type: "recent").take(5).collect
@tweets.each() do |tweet|
tweet_text_with_info = {:user_name => tweet.user.name, :screen_name => tweet.user.screen_name,
:created_at => tweet.created_at, :text => tweet.text, :emoji => tweet.text.to_array,
:russian => (EasyTranslate.translate(tweet.text, :to => :russian).to_s),
:spanish => (EasyTranslate.translate(tweet.text, :to => :spanish)),
:japanese => (EasyTranslate.translate(tweet.text, :to => :japanese)), :music => tweet.text.music_encryption}
@translated.push(tweet_text_with_info)
end
end
if params['switch']
@target_user = params['target_user']
end
# $twitter_client.update(user_name)
# @tweets = $twitter_client.search(user_name, result_type: "recent").take(3).collect
erb(:keyword_search)
end
get '/emoji' do
@user_tweets = $twitter_client.user_timeline('Twittamir_Putin')
erb(:emoji)
end
post '/emoji' do
@user_tweets = $twitter_client.user_timeline('Twittamir_Putin')
tweet = params['sentence']
@return = {:user_name => $twitter_client.user.name, :screen_name => $twitter_client.user.screen_name,
:created_at => Time.now, :text => tweet, :emoji => tweet.to_array,
:russian => (EasyTranslate.translate(tweet, :to => :russian)),
:spanish => (EasyTranslate.translate(tweet, :to => :spanish)),
:japanese => (EasyTranslate.translate(tweet, :to => :japanese)),
:music => tweet.music_encryption}
erb(:emoji)
end
get '/emoji_tweet' do
@emoji_tweet = "@#{$twitter_client.mentions.first.user.user_name}"+" says "+" #{$twitter_client.mentions.first.text.to_array}"
erb(:test)
end
get '/tweet_back' do
@tweet_back = $twitter_client.update("@#{$twitter_client.mentions.first.user.user_name} #{$twitter_client.mentions.first.text.to_array}").text
@you_tweeted = true
erb(:test)
end
get '/keyword_search/soviet' do
@user_tweets = $twitter_client.user_timeline('Twittamir_Putin')
@tweets = []
@translated = []
erb :keyword_search_soviet,:layout => :layout_soviet
end
post'/keyword_search/soviet' do
@user_tweets = $twitter_client.user_timeline('Twittamir_Putin')
search_term = params['search-term']
@translated = []
# language = params['language'].to_sym
@tweets = $twitter_client.search(search_term, result_type: "recent").take(5).collect
@tweets.each() do |tweet|
tweet_text_with_info = {:user_name => tweet.user.name, :screen_name => tweet.user.screen_name,
:created_at => tweet.created_at, :text => tweet.text, :emoji => tweet.text.to_array,
:russian => (EasyTranslate.translate(tweet.text, :to => :russian).to_s),
:spanish => (EasyTranslate.translate(tweet.text, :to => :spanish)),
:japanese => (EasyTranslate.translate(tweet.text, :to => :japanese))}
@translated.push(tweet_text_with_info)
end
if params['switch']
@target_user = params['target_user']
end
# $twitter_client.update(user_name)
# @tweets = $twitter_client.search(user_name, result_type: "recent").take(3).collect
erb :keyword_search_soviet,:layout => :layout_soviet
end