Skip to content

Instantly share code, notes, and snippets.

@briandfoy
Last active July 17, 2019 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briandfoy/1f136386dab2199ce866c094366697a3 to your computer and use it in GitHub Desktop.
Save briandfoy/1f136386dab2199ce866c094366697a3 to your computer and use it in GitHub Desktop.
Create a file covering all numbers in a US telephone exchange to import into Google Contants
#!/usr/bin/perl
use v5.10;
=head1 NAME
neighborhood_scam_groups.pl - generate contact groups for all the numbers in a exchange
=head1 SYNOPSIS
$ perl neighborhood_scam_groups.pl AREA_CODE EXCHANGE > scam.csv
$ perl neighborhood_scam_groups.pl 917 345 > scam.csv
=head1 DESCRIPTION
This program takes a US area code and exchange, then creates a CSV document
suitable for import into Google Contacts. It prints to standard output.
In Google Voice, I wanted to block all the phone numbers from my exchange.
I only get these calls as spam.
We can't block entire groups (or even a single contact) in Google Voice,
but we can route the calls per group, including not forwarding them at all.
I adapted this from L<https://github.com/danielsadoway/rangeblocker>.
I didn't want to compile anything just to make a CSV file, so here it
is in Perl (and a lot simpler).
Each group has 100 numbers, which is a limit in contacts, so there are
also 100 contacts to cover the 10,000 numbers.
Getting these into Google Voice is a bit of a pain.
=over 4
=item * Go to Google Contacts, L<https://contacts.google.com>
=item * Import the CSV file this creates.
=item * Rename the group to whatever you like.
=item * In Google Voice, find the "Legacy Google Voice" in settings (upper left corner hamburger menu)
=item * In Legacy Google Voice, go to settings in the upper right gear menu
=item * Find the group tab, and find your new group. Edit that group.
=item * Untick all call forwarding for that group, then save the changes
=back
=head1 AUTHOR & COPYRIGHT
Copyright © 2019, brian d foy <brian.d.foy@gmail.com>
=head1 LICENSE
You can use this code under the terms of the Artistic License 2.0.
=cut
my( $area_code, $exchange ) = @ARGV;
my @fields = (
'Name',
'Group Membership',
'Phone 1 - Value',
);
say join ',', @fields;
# Go though groups of 100
for( my $n = 0; $n < 100; $n++ ) {
my $start = $n * 100;
my $stop = $start + 9;
my @row;
$row[0] = "Neighborhood Scam $start - $stop";
$row[1] = 'Neighborhood Scam Group';
# put 100 phone numbers in each group
for( my $i = $start; $i <= $stop; $i++ ) {
$row[2] = sprintf "(%s) %s-%04d", $area_code, $exchange, $i;
say join ',', @row;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment