diff --git a/bottools/methods.py b/bottools/methods.py index 6133086..faa7aad 100644 --- a/bottools/methods.py +++ b/bottools/methods.py @@ -29,9 +29,9 @@ def twoExceptions(e, message): 323: bottools.strings.multipleGIFs, 326: bottools.strings.accountLocked, 354: bottools.strings.longTweet - }.get(e.api_code) + }.get(e.api_code, bottools.strings.twoFail) - message.reply_text(text or bottools.strings.twoFail) + message.reply_text(text) def silence(bot, update): pass @@ -105,9 +105,20 @@ def makeMenu(buttons, columns = 2): # Authentication process def shareLocation(bot, update): - rmo = telegram.ReplyKeyboardMarkup([[telegram.KeyboardButton(text = "Share location", request_location = True)]]) + buttons = [ + telegram.KeyboardButton(text = bottools.strings.shareLocationAgree, request_location = True), + ] + + rmo = telegram.ReplyKeyboardMarkup(makeMenu(buttons, 1)) update.message.reply_text(bottools.strings.shareLocation, reply_markup = rmo) +def unsetLocation(bot, update): + dbtools.dbHelper().storeLocation(update.message.chat_id, "NULL", "NULL") + update.message.reply_text(bottools.strings.unsetLocation) + +def noLocation(bot, update): + update.message.reply_text(bottools.strings.noLocation, reply_markup=telegram.ReplyKeyboardRemove()) + def storeLocation(bot, update): cid = update.message.chat_id lat = update.message.location.latitude @@ -115,6 +126,8 @@ def storeLocation(bot, update): dbtools.dbHelper().storeLocation(cid, lat, lon) + update.message.reply_text(bottools.strings.storeLocation, reply_markup=telegram.ReplyKeyboardRemove()) + def auth(bot, update): db = dbtools.dbHelper() cid = update.message.chat_id @@ -594,6 +607,7 @@ commands = { "login": auth, "logout": unauth, "mentionstream": mentionstream, + "nolocation": noLocation, "quote": quote, "reply": reply, "restart": restart, @@ -614,6 +628,7 @@ commands = { "unauth": unauth, "unfollow": unfollow, "unlike": unlike, + "unsetlocation": unsetLocation, "user": user, "verify": verify } diff --git a/bottools/strings.py b/bottools/strings.py index 7ea3216..22fc085 100644 --- a/bottools/strings.py +++ b/bottools/strings.py @@ -2,9 +2,9 @@ auth = '''To get authenticated with Twitter, please visit this URL and sign in: * %s -You will receive a six-digit PIN. Please send it to me like this: +You will receive a seven-digit PIN. Please send it to me like this: -* /verify 123456''' +* /verify 1234567''' authimp = '''You can't currently log in to a new account as you are either already logged in or I'm waiting for your verification code. @@ -136,3 +136,13 @@ restart = '''Restarting. Be right back. Hopefully.''' shareLocation = '''Would you like to share your location with me?''' trends = '''The current trends are:''' + +storeLocation = '''Thanks, I will now use this location.''' + +shareLocationAgree = '''Sure!''' + +shareLocationDecline = '''Nope.''' + +unsetLocation = '''Alright, I will no longer use your location data.''' + +noLocation = '''Okay, I will not change your location data.'''