File tree 5 files changed +39
-14
lines changed
5 files changed +39
-14
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
2
import logging
3
-
3
+ import bot_osm_edit
4
4
import ee_osmose
5
5
import osmose
6
6
from telegram import *
@@ -156,13 +156,15 @@ def main():
156
156
# Get the dispatcher to register handlers
157
157
dp = updater .dispatcher
158
158
159
+ editor = bot_osm_edit .ElemEditor ()
159
160
# on different commands - answer in Telegram
160
161
dp .add_handler (CommandHandler ("start" , start ))
161
162
dp .add_handler (CommandHandler ("help" , help ))
162
163
dp .add_handler (CommandHandler ('user' , user_issue ))
163
164
dp .add_handler (CallbackQueryHandler (button ))
164
165
dp .add_handler (MessageHandler (Filters .location , loc_issue ))
165
166
dp .add_handler (CommandHandler ("loc" , loc_issue ))
167
+ dp .add_handler (editor .get_conversation ())
166
168
167
169
# on non-command i.e message - echo the message on Telegram
168
170
# dp.add_handler(MessageHandler(Filters.text, echo))
Original file line number Diff line number Diff line change 13
13
14
14
class ElemEditor :
15
15
def __init__ (self ):
16
-
17
- return self .get_conversation ()
16
+ pass
18
17
19
18
def get_conversation (self ):
20
19
return ConversationHandler (
21
20
entry_points = [CommandHandler ('_edit' , self .start )],
22
21
23
22
states = {
24
- CHOOSING : [MessageHandler (Filters .regex ('Tag ' ), self .tag ),
23
+ CHOOSING : [MessageHandler (Filters .regex ('tag ' ), self .tag ),
25
24
MessageHandler (Filters .regex ('cancel' ), self .cancel )
26
25
],
27
26
@@ -35,11 +34,13 @@ def get_conversation(self):
35
34
fallbacks = [MessageHandler (Filters .regex ('^Done$' ), self .cancel )]
36
35
)
37
36
38
- def start (self ):
39
- pass
37
+ def start (self , update , context ):
38
+ print ('hello here conversation start' )
39
+ return CHOOSING
40
40
41
- def tag (self ):
42
- pass
41
+ def tag (self , update , context ):
42
+ print ('hay here is converseation Tag' )
43
+ return CHOOSING
43
44
44
45
def value (self ):
45
46
pass
Original file line number Diff line number Diff line change @@ -37,12 +37,13 @@ def request_token(self):
37
37
self .owner_secret = fetch_response .get ('oauth_token_secret' )
38
38
return self .owner_key , self .owner_secret
39
39
40
- # Using OAuth1Session
41
- def authorize (self ):
40
+ def prepare_auth_url (self ):
42
41
authorization_url = self .oauth .authorization_url (self .base_authorization_url )
43
42
print ('Please go here and authorize,' , authorization_url ) # TODO send this message to user
44
- redirect_response = 'raw_input("Paste the full redirect URL here: ")' # TODO create socket for redirect
45
- oauth_response = self .oauth .parse_authorization_response (redirect_response )
43
+
44
+ # Using OAuth1Session
45
+ def authorize (self , response ):
46
+ oauth_response = self .oauth .parse_authorization_response (response )
46
47
logger .debug (oauth_response )
47
48
self .verifier = oauth_response .get ('oauth_verifier' )
48
49
return self .verifier
@@ -54,5 +55,5 @@ def access_token(self):
54
55
resource_owner_key = self .owner_key ,
55
56
resource_owner_secret = self .owner_secret ,
56
57
verifier = self .verifier )
57
- oauth_tokens = self .oauth .fetch_access_token (self .acc_token_url )
58
+ oauth_tokens = self .oauth .fetch_access_token (self .access_token_url )
58
59
Original file line number Diff line number Diff line change
1
+ import unittest
2
+ import o_auth
3
+ import requests
4
+
5
+ class MyTestCase (unittest .TestCase ):
6
+ auth = o_auth .Authorisation ()
7
+
8
+ def test_something (self ):
9
+ owner_cr = self .auth .request_token ()
10
+ self .auth .prepare_auth_url ()
11
+
12
+ def test_something (self ):
13
+ self .auth .authorize ()
14
+
15
+
16
+
17
+
18
+
19
+ if __name__ == '__main__' :
20
+ unittest .main ()
Original file line number Diff line number Diff line change @@ -95,7 +95,8 @@ def test_close_note(self):
95
95
96
96
def test_edit_elem (self ):
97
97
node = self .osmo .get_element ('node' , 4314858041 )
98
- data = self .osmo .edit_element (node , 177967 )
98
+ data = self .osmo .edit_element (node , 178488 )
99
+ print (data )
99
100
100
101
def test_get_users (self ):
101
102
users = self .osmo .get_users ([7634 , 7122 ])
You can’t perform that action at this time.
0 commit comments