2019-09-19 15:15:46 +02:00
import random
2019-09-29 14:17:02 +02:00
import gettext
import os
2019-09-19 15:15:46 +02:00
2019-09-29 14:17:02 +02:00
class Voice :
def __init__ ( self , lang ) :
localedir = os . path . join ( os . path . abspath ( os . path . dirname ( __file__ ) ) , ' locale ' )
translation = gettext . translation (
' voice ' , localedir ,
languages = [ lang ] ,
fallback = True ,
)
translation . install ( )
self . _ = translation . gettext
2019-09-19 15:15:46 +02:00
2019-10-15 11:56:49 +02:00
def custom ( self , s ) :
return s
2019-09-29 14:17:02 +02:00
def default ( self ) :
return self . _ ( ' ZzzzZZzzzzZzzz ' )
2019-09-19 15:15:46 +02:00
2019-09-29 14:17:02 +02:00
def on_starting ( self ) :
2019-10-03 12:07:16 +02:00
return random . choice ( [
2019-10-03 11:09:25 +02:00
self . _ ( ' Hi, I \' m Pwnagotchi! Starting ... ' ) ,
self . _ ( ' New day, new hunt, new pwns! ' ) ,
2019-09-29 14:17:02 +02:00
self . _ ( ' Hack the Planet! ' ) ] )
2019-09-19 15:15:46 +02:00
2019-09-29 14:17:02 +02:00
def on_ai_ready ( self ) :
return random . choice ( [
self . _ ( ' AI ready. ' ) ,
2019-10-03 11:09:25 +02:00
self . _ ( ' The neural network is ready. ' ) ] )
2019-09-19 15:15:46 +02:00
2019-10-12 20:00:50 +02:00
def on_keys_generation ( self ) :
return random . choice ( [
self . _ ( ' Generating keys, do not turn off ... ' ) ] )
2019-09-29 14:17:02 +02:00
def on_normal ( self ) :
2019-10-03 12:07:16 +02:00
return random . choice ( [
2019-09-29 14:17:02 +02:00
' ' ,
' ... ' ] )
2019-09-19 15:15:46 +02:00
2019-09-30 23:28:42 +02:00
def on_free_channel ( self , channel ) :
2019-10-03 11:09:25 +02:00
return self . _ ( ' Hey, channel {channel} is free! Your AP will say thanks. ' ) . format ( channel = channel )
2019-09-19 15:15:46 +02:00
2019-10-30 14:25:21 +01:00
def on_reading_logs ( self , lines_so_far = 0 ) :
if lines_so_far == 0 :
return self . _ ( ' Reading last session logs ... ' )
else :
return self . _ ( ' Read {lines_so_far} log lines so far ... ' ) . format ( lines_so_far = lines_so_far )
2019-09-30 23:28:42 +02:00
def on_bored ( self ) :
2019-10-03 12:07:16 +02:00
return random . choice ( [
2019-09-29 14:17:02 +02:00
self . _ ( ' I \' m bored ... ' ) ,
self . _ ( ' Let \' s go for a walk! ' ) ] )
2019-09-19 15:15:46 +02:00
2019-09-29 14:17:02 +02:00
def on_motivated ( self , reward ) :
2019-10-03 11:09:25 +02:00
return self . _ ( ' This is the best day of my life! ' )
2019-09-19 15:15:46 +02:00
2019-09-29 14:17:02 +02:00
def on_demotivated ( self , reward ) :
return self . _ ( ' Shitty day :/ ' )
2019-09-19 15:15:46 +02:00
2019-09-29 14:17:02 +02:00
def on_sad ( self ) :
2019-10-03 12:07:16 +02:00
return random . choice ( [
2019-09-29 14:17:02 +02:00
self . _ ( ' I \' m extremely bored ... ' ) ,
self . _ ( ' I \' m very sad ... ' ) ,
self . _ ( ' I \' m sad ' ) ,
' ... ' ] )
2019-09-19 15:15:46 +02:00
2019-11-01 15:53:31 +01:00
def on_angry ( self ) :
# passive aggressive or not? :D
return random . choice ( [
' ... ' ,
self . _ ( ' Leave me alone ... ' ) ,
self . _ ( ' I \' m mad at you! ' ) ] )
2019-09-29 14:17:02 +02:00
def on_excited ( self ) :
2019-10-03 12:07:16 +02:00
return random . choice ( [
2019-09-29 14:17:02 +02:00
self . _ ( ' I \' m living the life! ' ) ,
self . _ ( ' I pwn therefore I am. ' ) ,
self . _ ( ' So many networks!!! ' ) ,
2019-10-03 11:09:25 +02:00
self . _ ( ' I \' m having so much fun! ' ) ,
self . _ ( ' My crime is that of curiosity ... ' ) ] )
2019-09-19 15:15:46 +02:00
2019-09-29 14:17:02 +02:00
def on_new_peer ( self , peer ) :
2019-10-23 19:53:23 +02:00
if peer . first_encounter ( ) :
return random . choice ( [
self . _ ( ' Hello {name} ! Nice to meet you. ' ) . format ( name = peer . name ( ) ) ] )
else :
return random . choice ( [
2019-10-24 13:02:50 +02:00
self . _ ( ' Yo {name} ! Sup? ' ) . format ( name = peer . name ( ) ) ,
self . _ ( ' Hey {name} how are you doing? ' ) . format ( name = peer . name ( ) ) ,
2019-10-23 19:53:23 +02:00
self . _ ( ' Unit {name} is nearby! ' ) . format ( name = peer . name ( ) ) ] )
2019-09-19 15:15:46 +02:00
2019-09-29 14:17:02 +02:00
def on_lost_peer ( self , peer ) :
2019-10-03 12:07:16 +02:00
return random . choice ( [
2019-10-03 11:09:25 +02:00
self . _ ( ' Uhm ... goodbye {name} ' ) . format ( name = peer . name ( ) ) ,
self . _ ( ' {name} is gone ... ' ) . format ( name = peer . name ( ) ) ] )
2019-09-19 15:15:46 +02:00
2019-09-29 14:17:02 +02:00
def on_miss ( self , who ) :
2019-10-03 12:07:16 +02:00
return random . choice ( [
2019-10-03 11:09:25 +02:00
self . _ ( ' Whoops ... {name} is gone. ' ) . format ( name = who ) ,
self . _ ( ' {name} missed! ' ) . format ( name = who ) ,
2019-09-29 14:17:02 +02:00
self . _ ( ' Missed! ' ) ] )
2019-09-19 15:15:46 +02:00
2019-10-23 18:19:43 +02:00
def on_grateful ( self ) :
return random . choice ( [
self . _ ( ' Good friends are a blessing! ' ) ,
self . _ ( ' I love my friends! ' ) ] )
2019-09-29 14:17:02 +02:00
def on_lonely ( self ) :
2019-10-03 12:07:16 +02:00
return random . choice ( [
2019-10-03 11:09:25 +02:00
self . _ ( ' Nobody wants to play with me ... ' ) ,
2019-09-29 14:17:02 +02:00
self . _ ( ' I feel so alone ... ' ) ,
self . _ ( ' Where \' s everybody?! ' ) ] )
2019-09-19 15:15:46 +02:00
2019-09-30 23:28:42 +02:00
def on_napping ( self , secs ) :
2019-10-03 12:07:16 +02:00
return random . choice ( [
2019-09-29 14:17:02 +02:00
self . _ ( ' Napping for {secs} s ... ' ) . format ( secs = secs ) ,
self . _ ( ' Zzzzz ' ) ,
self . _ ( ' ZzzZzzz ( {secs} s) ' ) . format ( secs = secs ) ] )
2019-09-19 15:15:46 +02:00
2019-10-07 19:42:29 +02:00
def on_shutdown ( self ) :
return random . choice ( [
self . _ ( ' Good night. ' ) ,
self . _ ( ' Zzz ' ) ] )
2019-09-29 14:17:02 +02:00
def on_awakening ( self ) :
return random . choice ( [ ' ... ' , ' ! ' ] )
2019-09-19 15:15:46 +02:00
2019-09-30 23:28:42 +02:00
def on_waiting ( self , secs ) :
2019-10-03 12:07:16 +02:00
return random . choice ( [
2019-09-29 14:17:02 +02:00
self . _ ( ' Waiting for {secs} s ... ' ) . format ( secs = secs ) ,
' ... ' ,
self . _ ( ' Looking around ( {secs} s) ' ) . format ( secs = secs ) ] )
2019-09-19 15:15:46 +02:00
2019-09-30 23:28:42 +02:00
def on_assoc ( self , ap ) :
2019-09-29 14:17:02 +02:00
ssid , bssid = ap [ ' hostname ' ] , ap [ ' mac ' ]
what = ssid if ssid != ' ' and ssid != ' <hidden> ' else bssid
2019-10-03 12:07:16 +02:00
return random . choice ( [
2019-10-03 11:09:25 +02:00
self . _ ( ' Hey {what} let \' s be friends! ' ) . format ( what = what ) ,
self . _ ( ' Associating to {what} ' ) . format ( what = what ) ,
self . _ ( ' Yo {what} ! ' ) . format ( what = what ) ] )
2019-09-19 15:15:46 +02:00
2019-10-02 19:58:01 +02:00
def on_deauth ( self , sta ) :
2019-10-03 12:07:16 +02:00
return random . choice ( [
2019-10-03 11:09:25 +02:00
self . _ ( ' Just decided that {mac} needs no WiFi! ' ) . format ( mac = sta [ ' mac ' ] ) ,
self . _ ( ' Deauthenticating {mac} ' ) . format ( mac = sta [ ' mac ' ] ) ,
self . _ ( ' Kickbanning {mac} ! ' ) . format ( mac = sta [ ' mac ' ] ) ] )
2019-09-19 15:15:46 +02:00
2019-09-30 23:28:42 +02:00
def on_handshakes ( self , new_shakes ) :
2019-09-29 14:17:02 +02:00
s = ' s ' if new_shakes > 1 else ' '
2019-10-03 11:09:25 +02:00
return self . _ ( ' Cool, we got {num} new handshake {plural} ! ' ) . format ( num = new_shakes , plural = s )
2019-09-19 15:15:46 +02:00
2019-10-23 15:14:55 +02:00
def on_unread_messages ( self , count , total ) :
s = ' s ' if count > 1 else ' '
2019-10-23 19:46:26 +02:00
return self . _ ( ' You have {count} new message {plural} ! ' ) . format ( count = count , plural = s )
2019-10-23 15:14:55 +02:00
2019-09-29 14:17:02 +02:00
def on_rebooting ( self ) :
2020-01-15 07:54:22 +09:30
return self . _ ( " Oops, something went wrong ... Rebooting ... " )
2019-09-19 15:15:46 +02:00
2019-10-08 14:54:03 +02:00
def on_last_session_data ( self , last_session ) :
status = self . _ ( ' Kicked {num} stations \n ' ) . format ( num = last_session . deauthed )
2019-12-08 17:16:05 -08:00
if last_session . associated > 999 :
status + = self . _ ( ' Made >999 new friends \n ' )
else :
status + = self . _ ( ' Made {num} new friends \n ' ) . format ( num = last_session . associated )
2019-10-08 14:54:03 +02:00
status + = self . _ ( ' Got {num} handshakes \n ' ) . format ( num = last_session . handshakes )
if last_session . peers == 1 :
2019-09-29 14:17:02 +02:00
status + = self . _ ( ' Met 1 peer ' )
2019-10-08 14:54:03 +02:00
elif last_session . peers > 0 :
status + = self . _ ( ' Met {num} peers ' ) . format ( num = last_session . peers )
2019-09-29 14:17:02 +02:00
return status
2019-09-19 15:15:46 +02:00
2019-10-08 14:54:03 +02:00
def on_last_session_tweet ( self , last_session ) :
2019-10-02 19:58:01 +02:00
return self . _ (
' I \' ve been pwning for {duration} and kicked {deauthed} clients! I \' ve also met {associated} new friends and ate {handshakes} handshakes! #pwnagotchi #pwnlog #pwnlife #hacktheplanet #skynet ' ) . format (
2019-10-08 14:54:03 +02:00
duration = last_session . duration_human ,
deauthed = last_session . deauthed ,
associated = last_session . associated ,
handshakes = last_session . handshakes )
2019-10-03 07:47:38 +03:00
2019-10-05 14:15:36 +02:00
def hhmmss ( self , count , fmt ) :
if count > 1 :
# plural
if fmt == " h " :
return self . _ ( " hours " )
if fmt == " m " :
return self . _ ( " minutes " )
if fmt == " s " :
return self . _ ( " seconds " )
else :
# sing
if fmt == " h " :
return self . _ ( " hour " )
if fmt == " m " :
return self . _ ( " minute " )
if fmt == " s " :
return self . _ ( " second " )
return fmt