mirror of
https://github.com/yibaiba/hideck.git
synced 2026-12-06 08:02:21 +00:00
Incoming calls and the call log resolve 10086/10010 and mobile prefixes to 中国移动/中国联通, plus country for international numbers. Names saved as contacts replace the raw number on screen.
142 lines
4.8 KiB
Go
142 lines
4.8 KiB
Go
package phonelookup
|
|
|
|
func matchService(candidates ...string) (svc serviceNumber, ok bool) {
|
|
best := 0
|
|
for _, cand := range candidates {
|
|
if cand == "" {
|
|
continue
|
|
}
|
|
if item, found := cnServiceNumbers[cand]; found && len(cand) >= best {
|
|
svc, ok, best = item, true, len(cand)
|
|
}
|
|
}
|
|
return svc, ok
|
|
}
|
|
|
|
func matchCNMobile(national string) (string, bool) {
|
|
if len(national) < 3 || national[0] != '1' {
|
|
return "", false
|
|
}
|
|
return matchLongest(national, cnMobilePrefixes)
|
|
}
|
|
|
|
func matchCNArea(national string) (string, bool) {
|
|
n := national
|
|
if len(n) > 0 && n[0] != '0' {
|
|
n = "0" + n
|
|
}
|
|
if len(n) < 3 {
|
|
return "", false
|
|
}
|
|
return matchLongest(n, cnAreaCodes)
|
|
}
|
|
|
|
type serviceNumber struct {
|
|
carrier string
|
|
}
|
|
|
|
var cnServiceNumbers = map[string]serviceNumber{
|
|
"10086": {carrier: "中国移动"},
|
|
"10085": {carrier: "中国移动"},
|
|
"10080": {carrier: "中国移动"},
|
|
"10010": {carrier: "中国联通"},
|
|
"10011": {carrier: "中国联通"},
|
|
"10016": {carrier: "中国联通"},
|
|
"10015": {carrier: "中国联通"},
|
|
"10000": {carrier: "中国电信"},
|
|
"10001": {carrier: "中国电信"},
|
|
"10099": {carrier: "中国广电"},
|
|
"118100": {carrier: "中国联通"},
|
|
"12580": {carrier: "中国移动"},
|
|
"10050": {carrier: "中国铁通"},
|
|
"114": {carrier: "号码查询"},
|
|
"116114": {carrier: "号码查询"},
|
|
"12306": {carrier: "铁路客服"},
|
|
"12315": {carrier: "消费者投诉"},
|
|
"12345": {carrier: "政务服务"},
|
|
"12321": {carrier: "网络不良信息"},
|
|
"12329": {carrier: "住房公积金"},
|
|
"12333": {carrier: "社保"},
|
|
"12320": {carrier: "公共卫生"},
|
|
"95588": {carrier: "工商银行"},
|
|
"95533": {carrier: "建设银行"},
|
|
"95566": {carrier: "中国银行"},
|
|
"95599": {carrier: "农业银行"},
|
|
"95559": {carrier: "交通银行"},
|
|
"95555": {carrier: "招商银行"},
|
|
"95558": {carrier: "中信银行"},
|
|
"95568": {carrier: "民生银行"},
|
|
"95561": {carrier: "兴业银行"},
|
|
"95595": {carrier: "光大银行"},
|
|
"95508": {carrier: "广发银行"},
|
|
"95528": {carrier: "浦发银行"},
|
|
"95577": {carrier: "华夏银行"},
|
|
"110": {carrier: "报警"},
|
|
"119": {carrier: "火警"},
|
|
"120": {carrier: "急救"},
|
|
"122": {carrier: "交通事故"},
|
|
"12121": {carrier: "天气预报"},
|
|
}
|
|
|
|
var cnMobilePrefixes = map[string]string{
|
|
"134": "中国移动", "135": "中国移动", "136": "中国移动", "137": "中国移动", "138": "中国移动", "139": "中国移动",
|
|
"147": "中国移动", "148": "中国移动",
|
|
"150": "中国移动", "151": "中国移动", "152": "中国移动", "157": "中国移动", "158": "中国移动", "159": "中国移动",
|
|
"165": "中国移动",
|
|
"172": "中国移动", "178": "中国移动",
|
|
"182": "中国移动", "183": "中国移动", "184": "中国移动", "187": "中国移动", "188": "中国移动",
|
|
"195": "中国移动", "197": "中国移动", "198": "中国移动",
|
|
"1703": "中国移动", "1705": "中国移动", "1706": "中国移动",
|
|
"130": "中国联通", "131": "中国联通", "132": "中国联通",
|
|
"145": "中国联通", "146": "中国联通",
|
|
"155": "中国联通", "156": "中国联通",
|
|
"166": "中国联通", "167": "中国联通",
|
|
"171": "中国联通", "175": "中国联通", "176": "中国联通",
|
|
"185": "中国联通", "186": "中国联通",
|
|
"196": "中国联通",
|
|
"1704": "中国联通", "1707": "中国联通", "1708": "中国联通", "1709": "中国联通",
|
|
"133": "中国电信", "149": "中国电信", "153": "中国电信",
|
|
"162": "中国电信", "173": "中国电信", "174": "中国电信", "177": "中国电信",
|
|
"180": "中国电信", "181": "中国电信", "189": "中国电信",
|
|
"190": "中国电信", "191": "中国电信", "193": "中国电信", "199": "中国电信",
|
|
"1700": "中国电信", "1701": "中国电信", "1702": "中国电信",
|
|
"192": "中国广电",
|
|
}
|
|
|
|
var cnAreaCodes = map[string]string{
|
|
"010": "北京",
|
|
"020": "广州",
|
|
"021": "上海",
|
|
"022": "天津",
|
|
"023": "重庆",
|
|
"024": "沈阳",
|
|
"025": "南京",
|
|
"027": "武汉",
|
|
"028": "成都",
|
|
"029": "西安",
|
|
"0311": "石家庄", "0315": "唐山",
|
|
"0351": "太原",
|
|
"0371": "郑州", "0379": "洛阳",
|
|
"0411": "大连",
|
|
"0431": "长春",
|
|
"0451": "哈尔滨",
|
|
"0471": "呼和浩特",
|
|
"0512": "苏州", "0510": "无锡", "0516": "徐州", "0519": "常州", "0513": "南通",
|
|
"0531": "济南", "0532": "青岛", "0535": "烟台", "0536": "潍坊",
|
|
"0551": "合肥",
|
|
"0571": "杭州", "0574": "宁波", "0577": "温州", "0579": "金华",
|
|
"0591": "福州", "0592": "厦门",
|
|
"0731": "长沙",
|
|
"0755": "深圳", "0756": "珠海", "0757": "佛山", "0760": "中山", "0769": "东莞",
|
|
"0771": "南宁",
|
|
"0791": "南昌",
|
|
"0851": "贵阳",
|
|
"0871": "昆明",
|
|
"0891": "拉萨",
|
|
"0898": "海口",
|
|
"0931": "兰州",
|
|
"0951": "银川",
|
|
"0971": "西宁",
|
|
"0991": "乌鲁木齐",
|
|
}
|