Best JavaScript code snippet using wpt
string.js
Source:string.js
1<script>2var TAB_CODE=93var DEL_CODE=46 4var BS_CODE=85var SP_CODE=326var DOT_CODE=1907var DOT2_CODE=1108var IDX_ON=09var IDX_OFF=110var IDX_AP_MODE=011var IDX_CBRIDGE_MODE=112var IDX_WWAN_MODE=213var IDX_KAI_MODE=314var IDX_MBRIDGE_MODE=415var WIRELESS_AP_MODE=0;16var WIRELESS_CBRIDGE_MODE=1;17var WIRELESS_CWAN_MODE=2;18var WIRELESS_KAI_MODE=3;19var WIRELESS_MBRIDGE_MODE=4;20var KAID_MODE_INIT=0 // ap mode21var KAID_MODE_PSP=0 // psp kai22var KAID_MODE_NORMAL=0 // xbox kai23var AUTH_OPEN=124var AUTH_KEY=225var AUTH_AUTO=326var AUTH_WPA=427var AUTH_WPAPSK=528var AUTH_OPEN8021X=629var AUTH_WPANONE=730var AUTH_WPA2=831var AUTH_WPA2PSK=932var AUTH_WPAPSKWPA2PSK=1033var AUTH_NOCHANGE=10034var IDX_NOENC=035var IDX_WEP64=136var IDX_WEP128=237var IDX_TKIP=338var IDX_AES=439var IDX_TKIPAES=540var ENCRYPT_OFF=041var ENCRYPT_64=142var ENCRYPT_128=243var ENCRYPT_TKIP=344var ENCRYPT_AES=445var ENCRYPT_TKIPAES=546var KEY_STRING=0;47var KEY_HEX=1;48var IDX_KEY_STRING=0;49var IDX_KEY_HEX=1;50var REGION_USA=1;51var REGION_JAPAN=2;52var DMZTWINIP_MODE_DMZ=1;53var DMZTWINIP_MODE_TWINIP=2;54var QOS_SHARING_BOUNDED=2;55var QOS_SHARING_BORROW=3;56var MSG_RESTART_CONFIRM_UPNP='æ¹åUPNPé
ç½®åç³»ç»å°éæ°å¯å¨.\næ¨æ¯å¦ç¡®å®æ´æ¹ ? ';57var MSG_RESTART_CONFIRM_REBOOT='ç³»ç»å³å°éå¯.\næ¨æ¯å¦ç¡®å®æ´æ¹?';58var MSG_RESTART_CONFIRM_CHANGE_LANIP='æ´æ¹å±åç½IPå°ååç³»ç»å°éå¯.\næ¨æ¯å¦ç¡®å®æ´æ¹ ?';59var MSG_RESTART_CONFIRM_CHANGE_LANIP_FAKE_TWINIP='æ´æ¹å±åç½IPå°ååç³»ç»å°éå¯.\næ¨æ¯å¦ç¡®å®æ´æ¹ ?';60var MSG_RESTART_CONFIRM_WIRELESS='æ´æ¹æ 线模å¼åç³»ç»å°éå¯.\næ¨æ¯å¦ç¡®å®æ´æ¹ ?';61var MSG_KAID_MODE_CHANGE_WARNING='ä¿®æ¹KAI模å¼åç³»ç»å°éå¯.\næ¨æ¯å¦ç¡®å®æ´æ¹ ?';62var MSG_RESTART_CONFIRM_WIRELESS_CBRIDGE='æ´æ¹æ 线模å¼åç³»ç»å°éå¯.\næ¨æ¯å¦ç¡®å®æ´æ¹?';63var MSG_RESTART_CONFIRM_WIRELESS_WWAN='æ´æ¹æ 线模å¼åç³»ç»å°éå¯.\næ¨æ¯å¦ç¡®å®æ´æ¹?';64var MSG_TWINIP_CONFIRM_WARNING='åºç¨Twin IPåç³»ç»å°éå¯.\næ¨æ¯å¦ç¡®å®æ´æ¹ ? ';65var MSG_WAN_FOR_LAN_WARNING='æ´æ¹å¹¿åç½é
ç½®åç³»ç»å°éå¯\nç¡®å®?';66// common67var MODIFY_OP='Modify'68var MSG_INVALID_HWADDR="æ æçMACå°å." 69var MSG_DELETE_RULE_CONFIRM="è§åå°è¢«å é¤.\næ¨æ¯å¦ç¡®å®æ´æ¹?" 70var MSG_SELECT_RULE_TO_DEL="éæ©è¦å é¤çè§å."71var MSG_ALL_STOP_RULE="æ¨æ³æ¸
é¤ææè§åå?"72var MSG_OPENER_PAGE_MOVED="页é¢åæ´."73var MSG_INVALID_VALUE="æ æå¼."74// wireless_config_wizard75var MSG_INVALID_WEP_KEY_HEXVALUE2="ç½ç»å¯é¥åºè¯¥æ¯åå
è¿å¶çå符串."76var MSG_INVALID_WPAPSK_KEY_MISMATCH="ä¸åçç½ç»å¯é¥.\nå¡«åç¸åçå¯é¥."77//NATè·¯ç± MSG_RULE_NAME_IS_BLANK="è§åå称æ¯ç©ºç½ç."78// wirelessconf_wdssetup79var MSG_WDS_DEL_WARNING="æ¨ç¡®å®è¦å é¤WDSå?" 80var MSG_APADD_REQUEST_APPLY="å¦ææ 'å¢å ' æé®, WDSé
ç½®å°å®æ."81var MSG_NO_DEL_WDS="éæ©è¦å é¤çWDS!"82// wirelessconf_basicsetup83var MSG_BLANK_SSID="è¾å
¥SSID."84var MSG_INVALID_WEP_KEY_LENGTH="æ æçç½ç»å¯é¥é¿åº¦."85var MSG_INVALID_WEP_KEY_HEXVALUE="ç½ç»å¯é¥åºä¸ºåå
è¿å¶."86var MSG_INVALID_WPAPSK_KEY_LENGTH="ç½ç»å¯é¥åºè¶
è¿8个å符."87var MSG_INVALID_5_KEY_LENGTH="ç½ç»å¯é¥åºä¸º5个å符."88var MSG_INVALID_13_KEY_LENGTH="ç½ç»å¯é¥åºä¸º13个å符."89var SAVE_CONFIGURATION_STRING="ä¿åææé
ç½®?"90var MSG_BLANK_REQUEST_SSID="è¾å
¥SSIDï¼å¹¶æâåºç¨âæé®."91var MSG_INVALID_REQUEST_KEY="è¾å
¥ç½ç»å¯é¥å¹¶æâåºç¨âæé®."92var MSG_INVALID_REQUEST_APPLY="æâåºç¨âæé®è¿æ¥æå®çAP."93var MSG_APPLY_REQUEST_KEY="æâåºç¨âæé®åºç¨1ä¿¡é"94var MSG_BEST_CHANNEL_PRE="æ好çä¿¡éæ¯ " 95var MSG_BEST_CHANNEL_POST="1ä¿¡é"96var MSG_KEY_LENGTH_DESC="å¯é¥é¿åº¦ = "97// é
ç½®å导 MSG_BLANK_ACCOUNT="è¾å
¥ç¨æ·å."98var MSG_BLANK_PASSWORD="è¾å
¥å¯ç ."99var MSG_INVALID_IP="æ æçIPå°å."100var MSG_INVALID_NETMASK="æ æçåç½æ©ç ."101var MSG_INVALID_GATEWAY="æ æçç½å
³å°å."102var MSG_INVALID_FDNS="æ æçé¦éDNS"103var MSG_INVALID_SDNS="æ æç次级DNS"104//netconf_lansetup105var NETCONF_INTERNAL_INVALID_NETWORK="å±åç½IPå°åå广åç½IPå°åç¸å."106var STATIC_LEASE_ALREADY_EXIST_IPADDRESS="æ¤IPå°å已被添å ."107var STATIC_LEASE_ALREADY_EXIST_HWADDRESS="æ¤MACå°å已被添å ."108var MSG_ERROR_NETWORK_LANIP="å±åç½IPå°åä¸è½å广åç½IPå°åç¸å"109var MSG_ERROR_BROAD_LANIP="å±åç½IPå°åä¸è½åæ¬å°å¹¿æå°åç¸å"110//netconf_wansetup111//netconf_lansetup112var NETCONF_INTERNAL_INVALID_DHCP_S_ADDR="æ æçDHCPå°åæ± å¼å§"113var NETCONF_INTERNAL_INVALID_DHCP_E_ADDR="æ æçDHCPå°åæ± ç»æ"114var NETCONF_INTERNAL_INVALID_DHCP_ADDR="æ æçDHCPæ± èå´"115var NETCONF_INTERNAL_DELETE_IP="æ¯å¦è¦å é¤æ¤ä¿ççIPå°å?"116// wirelessconf_advanced117var DESC_INVALID_TX_POWER="TXåçåºè¯¥æ¯ä»1å°100.";118var DESC_INVALID_RTS_THRESHOLD="RTSé¨éåºè¯¥ä»1å°2347.";119var DESC_INVALID_FRAG_THRESHOLD="ç¢çåé¨æ§åºä»256å°2346.";120var DESC_INVALID_BEACON_INTERVAL="Beacon å¨æåºä¸º50è³1024.";121// expertconf_kai122var KAID_MODE_CHANGE_WARNING="éæ°å¯å¨ç³»ç»ãä½ ç¡®å®è¦ç»§ç»å ?"123var KAID_MUST_SELECT_OBT_SERVER="è³å°ï¼ä¸ä¸ªæå¡å¨åºè¯¥è¢«éæ©."124var KAID_RESTART_KAI_UI="请éæ°å¯å¨ç¨æ·çé¢."125//natrouterconf_portforward126var MAX_PORT_FORWARD=60127var NATCONF_PORTFORWARD_NO_MORE_RULE="ä¸è½åæ·»å æ´å¤ç端å£."128var NATCONF_PORTFORWARD_INVALID_INT_IP_ADDRESS="æ æçå
é¨IPå°å."129var NATCONF_PORTFORWARD_EXT_PORT_IS_BLANK="å¤é¨ç«¯å£æ¯ç©ºç½ç"130var NATCONF_PORTFORWARD_INVALID_EXT_PORT="æ æçå¤é¨ç«¯å£."131var NATCONF_PORTFORWARD_INVALID_EXT_PORT_RANGE="æ æçå¤é¨ç«¯å£èå´."132var NATCONF_PORTFORWARD_INVALID_INT_PORT="æ æçå
é¨ç«¯å£."133var NATCONF_PORTFORWARD_INVALID_INT_PORT_RANGE="æ æçå
é¨ç«¯å£èå´"134var NATCONF_PORTFORWARD_RUN_RULE="ä½ æ³åºç¨è§åå?"135//firewallconf_firewall136var USER_FWSCHED_TYPE=1137var APP_FWSCHED_TYPE=2138var URL_FWSCHED_TYPE=4139var MAX_FWSCHED_COUNT=200 140var FIREWALLCONF_FIREWALL_INVALID_TIME_TO_BLOCK="æ æçæ¶é´èå´."141var FIREWALLCONF_FIREWALL_DATE_WARNING="éæ©æ¶é´èå´."142var FIREWALLCONF_FIREWALL_INVALID_SOURCE_IP="æ æçæºIPå°å."143var FIREWALLCONF_FIREWALL_INVALID_SOURCE_HW="æ æçæºIPå°å."144var FIREWALLCONF_FIREWALL_INVALID_DEST_IP="æ æç®çå°å."145var FIREWALLCONF_FIREWALL_INVALID_DEST_PORT="æ æçç®ç端å£."146var FIREWALLCONF_FIREWALL_RUN_RULE="æ¨æ³åºç¨è§åå?"147var FIREWALLCONF_FIREWALL_NO_MORE_RULE="没ææ´å¤çå¸æ·."148var FIREWALLCONF_FIREWALL_INVALID_PRIORITY="æ æçä¼å
."149//firewallconf_netdetect150var NETCONF_NETDETECT_WARNING1="æå°è¿æ¥å¼ä¸º10."151var NETCONF_NETDETECT_WARNING2="0 ~ 23 èå´å¼"152//firewallconf_internet153var FIREWALLCONF_INTERNET_RESTRICTIVE_WARNING="PCçæ°éåºä»1~253."154var FIREWALLCONF_INTERNET_RESTRICTIVE_CLEARANCE="æ¨æ³æ¸
é¤ææçPCé
置信æ¯?"155//trafficconf_switch156var SELECT_VLAN_PORT_WARNING ="éæ©ç«¯å£."157var SELECT_VLAN_PORT_TRUNK_WARNING ="ææç端å£(%s) å¿
é¡»å¨VLANå
."158var SELECT_TRUNK_PORT_WARNING ="éæ©ä¸ç»§ç«¯å£."159var SELECT_TRUNK_PORT_VLAN_WARNING ="ææ端å£å¿
é¡»å¨VLAN(%s) æè
å
¶ä»çVLAN."160var MAX_MEMBER_TRUNK_WARNING="æ大端å£æ° %d."161var ALREADY_OTHER_GROUP_MEMBER="端å£ä¸è½å
å«å¨å¤ä¸ªç»ä¸."162//trafficconf_loadshare163var NATCONF_PORTFORWARD_NO_MORE_RULE="没ææ´å¤çæ·»å 端å£."164var NATCONF_PORTFORWARD_RULE_NAME_IS_BLANK="è§åå称空ç½."165var NATCONF_INTSERVER_INVALID_EXT_PORT="æ æç端å£."166var NATCONF_LOADSHARE_KEEP_WRR="å½WRR LSæ¿æ´»æ¨å¯ä»¥å
³éèªå¨å¤ä»½åè½." 167var NATCONF_LOADSHARE_ON_LINE_BACKUP="èªå¨å¤ä»½ä¹å°è¢«æ¿æ´»ãæ¨æ³ç»§ç»å?"168var NATCONF_LOADSHARE_DELETE_RULE="æ¯å¦è¦å é¤è§å?"169var NATCONF_PORTFORWARD_SELECT_RULE_TO_DEL="éæ©è¦æ£æµçè§å."170//sysconf_login171//reboot172var REBOOT_CHANGEIP_RETRY_LOGIN="ç±äºæ¬å°IPå°åçæ´æ¹ï¼è¯·éæ°è¿æ¥."173var REBOOT_CHANGEIP_RETRY_NOLOGIN_WINDOWS="éæ°è¿æ¥å°é
置页."174// wirelessconf_multibssid175var MSG_DEL_MBSSID_WARNING="æ 线ç½ç»å°è¢«å é¤ãä½ ç¡®å®è¦ç»§ç»å ?"176var MSG_MBSSID_QOS_WARNING="æå°å¼ä¸º 100 Kbps."177//sysconf_misc178var MSG_WBM_POPUP="éæ°è¿æ¥."179// trafficconf_switch180var MSG_SAME_PORT_MIRROR="åæ ·ç端å£ä¸è½è¢«éå."181var MSG_HUBMODE_WARNING="!!! è¦å !!\nHUB模å¼ï¼NATè·¯ç±åè½å°åæ¢å¹¶è®¾ç½®æ æ³è¿æ¥é
置页é¢ã\n \n\n继ç»? "182var MSG_HUBMODE_CONFIRM="æâç¡®å®âæé®ç»§ç»."183// trafficconf_portqos184var MSG_PORTQOS_BOTH_ZERO=": 0 Mbps ä¸è½è¢«é
ç½®."185var MSG_PORTQOS_MAX_ERROR=": 大äº100 Mbps ä¸è½è¢«é
ç½®."186var MSG_PORTQOS_INVALID_VALUE=": æ æ(åºè¯¥ä¸º "187// wirelessconf_multibridge188var MSG_DEL_WWAN_WANRING="æ线广åç½ç«¯å£(广åç½ç«¯å£) å°è¢«å
³é. æ¨æ¯å¦æ³ç»§ç»?"189// iframe_pppoe_sched190var MSG_INVALID_HOUR_VALUE="å°æ¶èå´ä¸º 0 ~ 23."191var MSG_INVALID_MIN_VALUE="åéèå´ä¸º0 ~ 59."192var MSG_PPPOE_SCHEDULE_SAME_RULE="ç¸åçæ¶é´è¡¨å·²ç»åå¨."193// trafficconf_lspolicy194var MSG_BACKUP_METHOD_AT_LEAST_ONE="è³å°éæ©ä¸ä¸ªç¨åº"195var MSG_BACKUP_METHOD_DOMAIN="åºæå®åå"196var MSG_INVALID_PROTONUM="Invalid Proto Num"197var MSG_MBRIDGE_AUTO_CHANNEL_STRING="[èªå¨æ索信é] æ¤åè½å¨æç´¢å
¶ä»çAPæºä¿¡å·çä¿¡é.\n\å½ç½æ¡¥åè½ä¸¢å¤±é£ä¹è¿ä¸ªAPå°ä¿æè¿æ¥ä¸çº§APï¼è¿ä¸ªåè½å¯ä»¥ä¿æAPåè½ææ.\n\æ以ï¼æ们ä¸å»ºè®®ä½¿ç¨ç½æ¡¥åè½åAPåè½ï¼åªæå½ [èªå¨æ索信é] æªå¼å¯.\n\继ç»?";198var TRAFFICCONF_ALL_OPTIONS_CLEAR = "ææçé项å°æ¸
é¤.\n继ç»?"199var MSG_SELECT_DEL_MBSS = "éæ©è¦å é¤çæ 线ç½ç»."200var AUTO_STRING = "èªå¨"201var MBRIDGE_AUTO_CHANNEL_SEARCH = "èªå¨æ索信é"202var UPPER_CHANNEL_TXT = "ä½çº§ç"203var LOWER_CHANNEL_TXT = "é«çº§ç"204var LAN_GATEWAY_WARNING_MSG = "å½æ²¡æ广åç½è¿æ¥æ¶ï¼æ¤é项对路ç±å¨æ¬èº«è¿æ¥äºèç½æ¯ææç.\nContinue?";205var MSG_IPPOOL_MAX_WARNING = "没æ使ç¨IPå°åçèå´."206var MSG_DFS_WARNING="è¿ä¸ªé¢éæ¯DFSä¿¡é.\nåªæå¨é·è¾¾ä¿¡å·è¢«åç°æ¶æ被æ¿æ´» 1 ~ 10 minutes."207var SYSCONF_LOGIN_BLANK_ID = "è´¦æ·æ¯ç©ºç."208var SYSCONF_LOGIN_BLANK_PASS = "å¯ç æ¯ç©ºç."209var SYSCONF_LOGIN_REMOVE_WARNING = "å é¤å¸æ·/å¯ç ã继ç»?"210var MSG_PPTPVPN_REBOOT = "æ¹åPPTP VPNåéæ°å¯å¨æå¡å¨?"211var MSG_QOS_REBOOT="æ¹åQoSé
ç½®åéæ°å¯å¨."212var DESC_INVALID_DCS_PERIOD="èå´åº 1 ~ 100."213var INVALID_HOUR_TEXT="èå´åº 0 ~ 23."214var INVALID_MIN_TEXT="èå´åº 0 ~ 59."215var SELECT_DAY_DESC="æå°ä¸å¤©æ£æ¥ä¸æ¬¡."216var SNMP_INVALID_PORT= "端å£èå´ 1 - 65535."217var SNMP_COMMUNITY_ALERT= "å为强å¶æ§."218var MSG_INVALID_RADIUS_SERVER="æ æçRADIUSæå¡å¨å°å"219var MSG_INVALID_RADIUS_SECRET="æ æçRADIUSæå¡å¨å¯ç "220var MSG_INVALID_RADIUS_PORT="æ æçRADIUSæå¡å¨ç«¯å£"221var MSG_WEP_WARNING="æ大è¿æ¥æ°ç 54Mbps(11g) å½éæ©WEPæè
TKIP.\n继ç»?"222var MSG_WEP_SEC_WARNING="WEPæ¯å¾å¼±çå å¯è®¾ç½®.æ们ä¸æ¨è使ç¨WEP.\n使ç¨WEPæè
ä¸ä½¿ç¨?"223var MSG_WIRELESS_WAN_WARNING="æ 线广åç½åè½å·²ç»è¢«å¦ä¸ä¸ªæ 线æ¥å£ä½¿ç¨äºãå
³éå
¶ä»æ 线æ¥å£ä¸çæ 线广åç½åè½."224var MSG_WDS_CHANNEL_WARNING="ä¿¡éå¹é
ä¸å¯¹.\næ´æ¹ä¿¡éååºç¨.\n继ç»?"225var MSG_NEW_BSS="æ°çæ 线ç½ç»"226var MSG_ADD_MAC_WARNING="没ææ£æ¥æ·»å çå°å."227var MSG_REMOVE_MAC_WARNING="没ææ£æ¥å é¤çå°å."228var MSG_NEED_REBOOT_FOR_WWAN="ç³»ç»å°è¢«éæ°å¯å¨ã继ç»?"229var PASSWORD_NEEDED_TO_SET_THIS="åºæ´æ¹å¸æ·åå¯ç ï¼ä»¥å¯ç¨æ¤åè½.\n设置å¸æ·åå¯ç [ç³»ç»]->[è´¦å·é
ç½®]页é¢."230var SYSCONF_LOGIN_NEED_CAPTCHA_CODE="å¡«åå®å
¨ç "231var MSG_SELECT_ITUNES_FOLDER_ERR="éæ©iTunesæ件夹."232var MSG_USB_MODE_WARNING="æ¹åUSB模å¼ï¼åºè¯¥éæ°å¯å¨ç³»ç».\n继ç»?"233var MSG_HWADDR_NO_INPUT=MSG_INVALID_HWADDR234var MSG_SELECT_MAC_REMOVED=NATCONF_PORTFORWARD_SELECT_RULE_TO_DEL235// NASCONF236var MSG_NASCONF_SAME_AS_MGMT_PORT="è·¯ç±å¨ç®¡ç端å£ä½¿ç¨çåä¸ä¸ªç«¯å£.\né¦å
ï¼æ´æ¹è·¯ç±å¨ç®¡ç端å£å使ç¨æ¤ç«¯å£."237// WIRELESSCONF238var MSG_5G_LOW_CHANNEL_WARNING="ä½åçä¿¡ééæ©ãæ¨èä½¿ç¨ [149-161] é¿è¦çä¿¡é."239var MSG_5G_USA_CHANNEL="[ç¾å½,å æ¿å¤§] åºåæ¯æé«åçãå¨å
¶ä»å½å®¶ä½¿ç¨å¯ä»¥ç¦æ¢å½å®¶è§å®."240var MSG_DYNAMIC_CHANNEL_WARNING="å¦æä¿¡é被使ç¨, [å¨æä¿¡éæç´¢] åè½å°è¢«ç¦ç¨\n继ç»?"241var PLUGIN_INSTALL_BT_TXT="å®è£
"242var PLUGIN_UPDATE_BT_TXT="å级"243var PLUGIN_CANCEL_BT_TXT="æ¸
é¤"244var PLUGIN_REMOVE_BT_TXT="移å¨"245var MSG_TOO_LONG_SSID="SSIDé¿åº¦å¤ªé¿.\néASCIIå符æ3个åè.\nSSIDçç£åºçµæµçé¿åº¦: "246var MSG_INVALID_FILE_STR = "æ æ件.";247var MSG_REBOOT_SECONDS_REMAINS1 = '';248var MSG_REBOOT_SECONDS_REMAINS2 = 'ç§';...
wxapi.py
Source:wxapi.py
...151 filepath = os.path.join(folder, '../', "data/text_reply.yaml")152 with open(filepath, "r") as f:153 result = yaml.load(f)154 return result155 def receive_msg(self, msg):156 root = etree.fromstring(msg)157 msg_type = root.xpath('.//MsgType')[0].text158 if msg_type == "event":159 return self.receive_event_msg(msg)160 elif msg_type == "text":161 return self.receive_text_msg(msg)162 elif msg_type == "image":163 return self.receive_image_msg(msg)164 elif msg_type == "voice":165 return self.receive_voice_msg(msg)166 elif msg_type == "video":167 return self.receive_video_msg(msg)168 elif msg_type == "shortvideo":169 return self.receive_shortvideo_msg(msg)170 elif msg_type == "location":171 return self.receive_location_msg(msg)172 elif msg_type == "link":173 return self.receive_link_msg(msg)174 elif msg_type == "music":175 return self.receive_music_msg(msg)176 elif msg_type == "news":177 return self.receive_news_msg(msg)178 def receive_text_msg(self, msg):179 print(msg)180 root = etree.fromstring(msg)181 to_user = root.xpath('.//ToUserName')[0].text182 from_user = root.xpath('.//FromUserName')[0].text183 msg_type = root.xpath('.//MsgType')[0].text184 msg_id = root.xpath('.//MsgId')[0].text185 content = root.xpath('.//Content')[0].text186 timestamp = root.xpath('.//CreateTime')[0].text187 msg = TextMsg(from_user, to_user, timestamp,188 content, msg_id)189 return msg190 def create_text_msg(self, from_user, to_user, content):191 timestamp = int(time.time())192 xml_form = """193 <xml>194 <ToUserName><![CDATA[{to_user}]]></ToUserName>195 <FromUserName><![CDATA[{from_user}]]></FromUserName>196 <CreateTime>{timestamp}</CreateTime>197 <MsgType><![CDATA[text]]></MsgType>198 <Content><![CDATA[{content}]]></Content>199 </xml>200 """.format(to_user=to_user, from_user=from_user,201 timestamp=timestamp, content=content)202 return xml_form203 def receive_event_msg(self, msg):204 print(msg)205 root = etree.fromstring(msg)206 to_user = root.xpath('.//ToUserName')[0].text207 from_user = root.xpath('.//FromUserName')[0].text208 msg_type = root.xpath('.//MsgType')[0].text209 event = root.xpath('.//Event')[0].text210 timestamp = root.xpath('.//CreateTime')[0].text211 if event == "subscribe" or event == "unsubscribe":212 msg = EventMsg(from_user, to_user, timestamp, event)213 return msg214 if event == "SCAN":215 pass216 if event == "LOCATION":217 pass218 if event == "CLICK":219 pass220 return result221 def receive_image_msg(self, msg):222 print(msg)223 root = etree.fromstring(msg)224 to_user = root.xpath('.//ToUserName')[0].text225 from_user = root.xpath('.//FromUserName')[0].text226 msg_type = root.xpath('.//MsgType')[0].text227 msg_id = root.xpath('.//MsgId')[0].text228 pic_url = root.xpath('.//PicUrl')[0].text229 media_id = root.xpath('.//MediaId')[0].text230 timestamp = root.xpath('.//CreateTime')[0].text231 msg = ImageMsg(from_user, to_user, timestamp,232 pic_url, media_id, msg_id)233 return msg234 def receive_voice_msg(self, msg):235 print(msg)236 root = etree.fromstring(msg)237 to_user = root.xpath('.//ToUserName')[0].text238 from_user = root.xpath('.//FromUserName')[0].text239 msg_type = root.xpath('.//MsgType')[0].text240 msg_id = root.xpath('.//MsgId')[0].text241 media_id = root.xpath('.//MediaId')[0].text242 timestamp = root.xpath('.//CreateTime')[0].text243 vformat = root.xpath('.//Format')[0].text244 msg = VoiceMsg(from_user, to_user, timestamp,245 media_id, vformat, msg_id)246 return msg247 def receive_video_msg(self, msg):248 print(msg)249 root = etree.fromstring(msg)250 to_user = root.xpath('.//ToUserName')[0].text251 from_user = root.xpath('.//FromUserName')[0].text252 msg_type = root.xpath('.//MsgType')[0].text253 msg_id = root.xpath('.//MsgId')[0].text254 media_id = root.xpath('.//MediaId')[0].text255 timestamp = root.xpath('.//CreateTime')[0].text256 thumb_id = root.xpath('.//ThumbMediaId')[0].text257 msg = VideoMsg(from_user, to_user, timestamp,258 media_id, thumb_id, msg_id)259 return msg260 def receive_shortvideo_msg(self, msg):261 print(msg)262 root = etree.fromstring(msg)263 to_user = root.xpath('.//ToUserName')[0].text264 from_user = root.xpath('.//FromUserName')[0].text265 msg_type = root.xpath('.//MsgType')[0].text266 msg_id = root.xpath('.//MsgId')[0].text267 media_id = root.xpath('.//MediaId')[0].text268 timestamp = root.xpath('.//CreateTime')[0].text269 thumb_id = root.xpath('.//ThumbMediaId')[0].text270 msg = ShortvideoMsg(from_user, to_user, timestamp,271 media_id, thumb_id, msg_id)272 return msg273 def receive_music_msg(self, msg):274 print(msg)275 pass276 def receive_location_msg(self, msg):277 print(msg)278 root = etree.fromstring(msg)279 to_user = root.xpath('.//ToUserName')[0].text280 from_user = root.xpath('.//FromUserName')[0].text281 msg_type = root.xpath('.//MsgType')[0].text282 msg_id = root.xpath('.//MsgId')[0].text283 location_x = root.xpath('.//Location_X')[0].text284 location_y = root.xpath('.//Location_Y')[0].text285 timestamp = root.xpath('.//CreateTime')[0].text286 scale = root.xpath('.//Scale')[0].text287 label = root.xpath('.//Label')[0].text288 msg = LocationMsg(from_user, to_user, timestamp,289 location_x, location_y, scale, label, msg_id)290 return msg291 def receive_link_msg(self, msg):292 print(msg)293 root = etree.fromstring(msg)294 to_user = root.xpath('.//ToUserName')[0].text295 from_user = root.xpath('.//FromUserName')[0].text296 msg_type = root.xpath('.//MsgType')[0].text297 msg_id = root.xpath('.//MsgId')[0].text298 timestamp = root.xpath('.//CreateTime')[0].text299 title = root.xpath('.//Title')[0].text300 desc = root.xpath('.//Description')[0].text301 url = root.xpath('.//Url')[0].text302 msg = ShortvideoMsg(from_user, to_user, timestamp,303 title, desc, url, msg_id)304 return msg305 def receive_news_msg(self, msg):306 print(msg)307 pass308 def create_menu(self):309 url = WXAPI_URL + "/menu/create?access_token={}".format(self.token)310 body = json.dumps({311 "button":[312 {313 "type":"click",314 "name":"ä»æ¥ææ²",315 "key":"V1001_TODAY_MUSIC"316 },317 {318 "name":"èå",319 "sub_button":[...
uchar.js
Source:uchar.js
1goog.provide('goog.i18n.uChar'); 2goog.i18n.uChar.charData_ = null; 3goog.i18n.uChar.toHexString = function(ch) { 4 var chCode = goog.i18n.uChar.toCharCode(ch); 5 var chCodeStr = 'U+' + goog.i18n.uChar.padString_(chCode.toString(16).toUpperCase(), 4, '0'); 6 return chCodeStr; 7}; 8goog.i18n.uChar.padString_ = function(str, length, ch) { 9 while(str.length < length) { 10 str = ch + str; 11 } 12 return str; 13}; 14goog.i18n.uChar.toCharCode = function(ch) { 15 var chCode = ch.charCodeAt(0); 16 if(chCode >= 0xD800 && chCode <= 0xDBFF) { 17 var chCode2 = ch.charCodeAt(1); 18 chCode =(chCode - 0xD800) * 0x400 + chCode2 - 0xDC00 + 0x10000; 19 } 20 return chCode; 21}; 22goog.i18n.uChar.fromCharCode = function(code) { 23 if(! code || code > 0x10FFFF) { 24 return null; 25 } else if(code >= 0x10000) { 26 var hi = Math.floor((code - 0x10000) / 0x400) + 0xD800; 27 var lo =(code - 0x10000) % 0x400 + 0xDC00; 28 return String.fromCharCode(hi) + String.fromCharCode(lo); 29 } else { 30 return String.fromCharCode(code); 31 } 32}; 33goog.i18n.uChar.toName = function(ch) { 34 if(! goog.i18n.uChar.charData_) { 35 goog.i18n.uChar.createCharData(); 36 } 37 var names = goog.i18n.uChar.charData_; 38 var chCode = goog.i18n.uChar.toCharCode(ch); 39 var chCodeStr = chCode + ''; 40 if(ch in names) { 41 return names[ch]; 42 } else if(chCodeStr in names) { 43 return names[chCode]; 44 } else if(0xFE00 <= chCode && chCode <= 0xFE0F || 0xE0100 <= chCode && chCode <= 0xE01EF) { 45 var seqnum; 46 if(0xFE00 <= chCode && chCode <= 0xFE0F) { 47 seqnum = chCode - 0xFDFF; 48 } else { 49 seqnum = chCode - 0xE00EF; 50 } 51 var MSG_VARIATION_SELECTOR_SEQNUM = goog.getMsg('Variation Selector - {$seqnum}', { 'seqnum': seqnum }); 52 return MSG_VARIATION_SELECTOR_SEQNUM; 53 } 54 return null; 55}; 56goog.i18n.uChar.createCharData = function() { 57 var MSG_CP_ARABIC_SIGN_SANAH = goog.getMsg('Arabic Sign Sanah'); 58 var MSG_CP_CANADIAN_SYLLABICS_HYPHEN = goog.getMsg('Canadian Syllabics Hyphen'); 59 var MSG_CP_ARABIC_SIGN_SAFHA = goog.getMsg('Arabic Sign Safha'); 60 var MSG_CP_ARABIC_FOOTNOTE_MARKER = goog.getMsg('Arabic Footnote Marker'); 61 var MSG_CP_FOUR_PER_EM_SPACE = goog.getMsg('Four-per-em Space'); 62 var MSG_CP_THREE_PER_EM_SPACE = goog.getMsg('Three-per-em Space'); 63 var MSG_CP_FIGURE_SPACE = goog.getMsg('Figure Space'); 64 var MSG_CP_MONGOLIAN_SOFT_HYPHEN = goog.getMsg('Mongolian Soft Hyphen'); 65 var MSG_CP_THIN_SPACE = goog.getMsg('Thin Space'); 66 var MSG_CP_SOFT_HYPHEN = goog.getMsg('Soft Hyphen'); 67 var MSG_CP_ZERO_WIDTH_SPACE = goog.getMsg('Zero Width Space'); 68 var MSG_CP_ARMENIAN_HYPHEN = goog.getMsg('Armenian Hyphen'); 69 var MSG_CP_ZERO_WIDTH_JOINER = goog.getMsg('Zero Width Joiner'); 70 var MSG_CP_EM_SPACE = goog.getMsg('Em Space'); 71 var MSG_CP_SYRIAC_ABBREVIATION_MARK = goog.getMsg('Syriac Abbreviation Mark'); 72 var MSG_CP_MONGOLIAN_VOWEL_SEPARATOR = goog.getMsg('Mongolian Vowel Separator'); 73 var MSG_CP_NON_BREAKING_HYPHEN = goog.getMsg('Non-breaking Hyphen'); 74 var MSG_CP_HYPHEN = goog.getMsg('Hyphen'); 75 var MSG_CP_EM_QUAD = goog.getMsg('Em Quad'); 76 var MSG_CP_EN_SPACE = goog.getMsg('En Space'); 77 var MSG_CP_HORIZONTAL_BAR = goog.getMsg('Horizontal Bar'); 78 var MSG_CP_EM_DASH = goog.getMsg('Em Dash'); 79 var MSG_CP_DOUBLE_OBLIQUE_HYPHEN = goog.getMsg('Double Oblique Hyphen'); 80 var MSG_CP_MUSICAL_SYMBOL_END_PHRASE = goog.getMsg('Musical Symbol End Phrase'); 81 var MSG_CP_MEDIUM_MATHEMATICAL_SPACE = goog.getMsg('Medium Mathematical Space'); 82 var MSG_CP_WAVE_DASH = goog.getMsg('Wave Dash'); 83 var MSG_CP_SPACE = goog.getMsg('Space'); 84 var MSG_CP_HYPHEN_WITH_DIAERESIS = goog.getMsg('Hyphen With Diaeresis'); 85 var MSG_CP_EN_QUAD = goog.getMsg('En Quad'); 86 var MSG_CP_RIGHT_TO_LEFT_EMBEDDING = goog.getMsg('Right-to-left Embedding'); 87 var MSG_CP_SIX_PER_EM_SPACE = goog.getMsg('Six-per-em Space'); 88 var MSG_CP_HYPHEN_MINUS = goog.getMsg('Hyphen-minus'); 89 var MSG_CP_POP_DIRECTIONAL_FORMATTING = goog.getMsg('Pop Directional Formatting'); 90 var MSG_CP_NARROW_NO_BREAK_SPACE = goog.getMsg('Narrow No-break Space'); 91 var MSG_CP_RIGHT_TO_LEFT_OVERRIDE = goog.getMsg('Right-to-left Override'); 92 var MSG_CP_PRESENTATION_FORM_FOR_VERTICAL_EM_DASH = goog.getMsg('Presentation Form For Vertical Em Dash'); 93 var MSG_CP_WAVY_DASH = goog.getMsg('Wavy Dash'); 94 var MSG_CP_PRESENTATION_FORM_FOR_VERTICAL_EN_DASH = goog.getMsg('Presentation Form For Vertical En Dash'); 95 var MSG_CP_KHMER_VOWEL_INHERENT_AA = goog.getMsg('Khmer Vowel Inherent Aa'); 96 var MSG_CP_KHMER_VOWEL_INHERENT_AQ = goog.getMsg('Khmer Vowel Inherent Aq'); 97 var MSG_CP_PUNCTUATION_SPACE = goog.getMsg('Punctuation Space'); 98 var MSG_CP_HALFWIDTH_HANGUL_FILLER = goog.getMsg('Halfwidth Hangul Filler'); 99 var MSG_CP_KAITHI_NUMBER_SIGN = goog.getMsg('Kaithi Number Sign'); 100 var MSG_CP_LEFT_TO_RIGHT_EMBEDDING = goog.getMsg('Left-to-right Embedding'); 101 var MSG_CP_HEBREW_PUNCTUATION_MAQAF = goog.getMsg('Hebrew Punctuation Maqaf'); 102 var MSG_CP_IDEOGRAPHIC_SPACE = goog.getMsg('Ideographic Space'); 103 var MSG_CP_HAIR_SPACE = goog.getMsg('Hair Space'); 104 var MSG_CP_NO_BREAK_SPACE = goog.getMsg('No-break Space'); 105 var MSG_CP_FULLWIDTH_HYPHEN_MINUS = goog.getMsg('Fullwidth Hyphen-minus'); 106 var MSG_CP_PARAGRAPH_SEPARATOR = goog.getMsg('Paragraph Separator'); 107 var MSG_CP_LEFT_TO_RIGHT_OVERRIDE = goog.getMsg('Left-to-right Override'); 108 var MSG_CP_SMALL_HYPHEN_MINUS = goog.getMsg('Small Hyphen-minus'); 109 var MSG_CP_COMBINING_GRAPHEME_JOINER = goog.getMsg('Combining Grapheme Joiner'); 110 var MSG_CP_ZERO_WIDTH_NON_JOINER = goog.getMsg('Zero Width Non-joiner'); 111 var MSG_CP_MUSICAL_SYMBOL_BEGIN_PHRASE = goog.getMsg('Musical Symbol Begin Phrase'); 112 var MSG_CP_ARABIC_NUMBER_SIGN = goog.getMsg('Arabic Number Sign'); 113 var MSG_CP_RIGHT_TO_LEFT_MARK = goog.getMsg('Right-to-left Mark'); 114 var MSG_CP_OGHAM_SPACE_MARK = goog.getMsg('Ogham Space Mark'); 115 var MSG_CP_SMALL_EM_DASH = goog.getMsg('Small Em Dash'); 116 var MSG_CP_LEFT_TO_RIGHT_MARK = goog.getMsg('Left-to-right Mark'); 117 var MSG_CP_ARABIC_END_OF_AYAH = goog.getMsg('Arabic End Of Ayah'); 118 var MSG_CP_HANGUL_CHOSEONG_FILLER = goog.getMsg('Hangul Choseong Filler'); 119 var MSG_CP_HANGUL_FILLER = goog.getMsg('Hangul Filler'); 120 var MSG_CP_FUNCTION_APPLICATION = goog.getMsg('Function Application'); 121 var MSG_CP_HANGUL_JUNGSEONG_FILLER = goog.getMsg('Hangul Jungseong Filler'); 122 var MSG_CP_INVISIBLE_SEPARATOR = goog.getMsg('Invisible Separator'); 123 var MSG_CP_INVISIBLE_TIMES = goog.getMsg('Invisible Times'); 124 var MSG_CP_INVISIBLE_PLUS = goog.getMsg('Invisible Plus'); 125 var MSG_CP_WORD_JOINER = goog.getMsg('Word Joiner'); 126 var MSG_CP_LINE_SEPARATOR = goog.getMsg('Line Separator'); 127 var MSG_CP_KATAKANA_HIRAGANA_DOUBLE_HYPHEN = goog.getMsg('Katakana-hiragana Double Hyphen'); 128 var MSG_CP_EN_DASH = goog.getMsg('En Dash'); 129 var MSG_CP_MUSICAL_SYMBOL_BEGIN_BEAM = goog.getMsg('Musical Symbol Begin Beam'); 130 var MSG_CP_FIGURE_DASH = goog.getMsg('Figure Dash'); 131 var MSG_CP_MUSICAL_SYMBOL_BEGIN_TIE = goog.getMsg('Musical Symbol Begin Tie'); 132 var MSG_CP_MUSICAL_SYMBOL_END_BEAM = goog.getMsg('Musical Symbol End Beam'); 133 var MSG_CP_MUSICAL_SYMBOL_BEGIN_SLUR = goog.getMsg('Musical Symbol Begin Slur'); 134 var MSG_CP_MUSICAL_SYMBOL_END_TIE = goog.getMsg('Musical Symbol End Tie'); 135 var MSG_CP_INTERLINEAR_ANNOTATION_ANCHOR = goog.getMsg('Interlinear Annotation Anchor'); 136 var MSG_CP_MUSICAL_SYMBOL_END_SLUR = goog.getMsg('Musical Symbol End Slur'); 137 var MSG_CP_INTERLINEAR_ANNOTATION_TERMINATOR = goog.getMsg('Interlinear Annotation Terminator'); 138 var MSG_CP_INTERLINEAR_ANNOTATION_SEPARATOR = goog.getMsg('Interlinear Annotation Separator'); 139 var MSG_CP_ZERO_WIDTH_NO_BREAK_SPACE = goog.getMsg('Zero Width No-break Space'); 140 goog.i18n.uChar.charData_ = { 141 '\u0601': MSG_CP_ARABIC_SIGN_SANAH, 142 '\u1400': MSG_CP_CANADIAN_SYLLABICS_HYPHEN, 143 '\u0603': MSG_CP_ARABIC_SIGN_SAFHA, 144 '\u0602': MSG_CP_ARABIC_FOOTNOTE_MARKER, 145 '\u2005': MSG_CP_FOUR_PER_EM_SPACE, 146 '\u2004': MSG_CP_THREE_PER_EM_SPACE, 147 '\u2007': MSG_CP_FIGURE_SPACE, 148 '\u1806': MSG_CP_MONGOLIAN_SOFT_HYPHEN, 149 '\u2009': MSG_CP_THIN_SPACE, 150 '\u00AD': MSG_CP_SOFT_HYPHEN, 151 '\u200B': MSG_CP_ZERO_WIDTH_SPACE, 152 '\u058A': MSG_CP_ARMENIAN_HYPHEN, 153 '\u200D': MSG_CP_ZERO_WIDTH_JOINER, 154 '\u2003': MSG_CP_EM_SPACE, 155 '\u070F': MSG_CP_SYRIAC_ABBREVIATION_MARK, 156 '\u180E': MSG_CP_MONGOLIAN_VOWEL_SEPARATOR, 157 '\u2011': MSG_CP_NON_BREAKING_HYPHEN, 158 '\u2010': MSG_CP_HYPHEN, 159 '\u2001': MSG_CP_EM_QUAD, 160 '\u2002': MSG_CP_EN_SPACE, 161 '\u2015': MSG_CP_HORIZONTAL_BAR, 162 '\u2014': MSG_CP_EM_DASH, 163 '\u2E17': MSG_CP_DOUBLE_OBLIQUE_HYPHEN, 164 '\u1D17A': MSG_CP_MUSICAL_SYMBOL_END_PHRASE, 165 '\u205F': MSG_CP_MEDIUM_MATHEMATICAL_SPACE, 166 '\u301C': MSG_CP_WAVE_DASH, 167 ' ': MSG_CP_SPACE, 168 '\u2E1A': MSG_CP_HYPHEN_WITH_DIAERESIS, 169 '\u2000': MSG_CP_EN_QUAD, 170 '\u202B': MSG_CP_RIGHT_TO_LEFT_EMBEDDING, 171 '\u2006': MSG_CP_SIX_PER_EM_SPACE, 172 '-': MSG_CP_HYPHEN_MINUS, 173 '\u202C': MSG_CP_POP_DIRECTIONAL_FORMATTING, 174 '\u202F': MSG_CP_NARROW_NO_BREAK_SPACE, 175 '\u202E': MSG_CP_RIGHT_TO_LEFT_OVERRIDE, 176 '\uFE31': MSG_CP_PRESENTATION_FORM_FOR_VERTICAL_EM_DASH, 177 '\u3030': MSG_CP_WAVY_DASH, 178 '\uFE32': MSG_CP_PRESENTATION_FORM_FOR_VERTICAL_EN_DASH, 179 '\u17B5': MSG_CP_KHMER_VOWEL_INHERENT_AA, 180 '\u17B4': MSG_CP_KHMER_VOWEL_INHERENT_AQ, 181 '\u2008': MSG_CP_PUNCTUATION_SPACE, 182 '\uFFA0': MSG_CP_HALFWIDTH_HANGUL_FILLER, 183 '\u110BD': MSG_CP_KAITHI_NUMBER_SIGN, 184 '\u202A': MSG_CP_LEFT_TO_RIGHT_EMBEDDING, 185 '\u05BE': MSG_CP_HEBREW_PUNCTUATION_MAQAF, 186 '\u3000': MSG_CP_IDEOGRAPHIC_SPACE, 187 '\u200A': MSG_CP_HAIR_SPACE, 188 '\u00A0': MSG_CP_NO_BREAK_SPACE, 189 '\uFF0D': MSG_CP_FULLWIDTH_HYPHEN_MINUS, 190 '8233': MSG_CP_PARAGRAPH_SEPARATOR, 191 '\u202D': MSG_CP_LEFT_TO_RIGHT_OVERRIDE, 192 '\uFE63': MSG_CP_SMALL_HYPHEN_MINUS, 193 '\u034F': MSG_CP_COMBINING_GRAPHEME_JOINER, 194 '\u200C': MSG_CP_ZERO_WIDTH_NON_JOINER, 195 '\u1D179': MSG_CP_MUSICAL_SYMBOL_BEGIN_PHRASE, 196 '\u0600': MSG_CP_ARABIC_NUMBER_SIGN, 197 '\u200F': MSG_CP_RIGHT_TO_LEFT_MARK, 198 '\u1680': MSG_CP_OGHAM_SPACE_MARK, 199 '\uFE58': MSG_CP_SMALL_EM_DASH, 200 '\u200E': MSG_CP_LEFT_TO_RIGHT_MARK, 201 '\u06DD': MSG_CP_ARABIC_END_OF_AYAH, 202 '\u115F': MSG_CP_HANGUL_CHOSEONG_FILLER, 203 '\u3164': MSG_CP_HANGUL_FILLER, 204 '\u2061': MSG_CP_FUNCTION_APPLICATION, 205 '\u1160': MSG_CP_HANGUL_JUNGSEONG_FILLER, 206 '\u2063': MSG_CP_INVISIBLE_SEPARATOR, 207 '\u2062': MSG_CP_INVISIBLE_TIMES, 208 '\u2064': MSG_CP_INVISIBLE_PLUS, 209 '\u2060': MSG_CP_WORD_JOINER, 210 '8232': MSG_CP_LINE_SEPARATOR, 211 '\u30A0': MSG_CP_KATAKANA_HIRAGANA_DOUBLE_HYPHEN, 212 '\u2013': MSG_CP_EN_DASH, 213 '\u1D173': MSG_CP_MUSICAL_SYMBOL_BEGIN_BEAM, 214 '\u2012': MSG_CP_FIGURE_DASH, 215 '\u1D175': MSG_CP_MUSICAL_SYMBOL_BEGIN_TIE, 216 '\u1D174': MSG_CP_MUSICAL_SYMBOL_END_BEAM, 217 '\u1D177': MSG_CP_MUSICAL_SYMBOL_BEGIN_SLUR, 218 '\u1D176': MSG_CP_MUSICAL_SYMBOL_END_TIE, 219 '\uFFF9': MSG_CP_INTERLINEAR_ANNOTATION_ANCHOR, 220 '\u1D178': MSG_CP_MUSICAL_SYMBOL_END_SLUR, 221 '\uFFFB': MSG_CP_INTERLINEAR_ANNOTATION_TERMINATOR, 222 '\uFFFA': MSG_CP_INTERLINEAR_ANNOTATION_SEPARATOR, 223 '\uFEFF': MSG_CP_ZERO_WIDTH_NO_BREAK_SPACE 224 }; ...
gameServer.py
Source:gameServer.py
1from twisted.internet.protocol import Factory,Protocol2from twisted.internet import reactor3from support import *4import json5from messageType import *6import messageHandle7from room import *8class ClientHandle(Protocol):9 def __init__(self):10 self.handshake = False11 self.GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"12 self.path = "/"13 self.index = 014 self.clientName = "" 15 16 def dataReceived(self, data): 17 if self.handshake == False: 18 headers = {}19 buffer = bytes.decode(data) 20 21 if buffer.find('\r\n\r\n') != -1: 22 header, data = buffer.split('\r\n\r\n', 1) 23 for line in header.split("\r\n")[1:]: 24 key, value = line.split(": ", 1) 25 headers[key] = value 26 27 headers["Location"] = ("ws://%s%s" %(headers["Host"], self.path)) 28 key = headers['Sec-WebSocket-Key'] 29 token = b64encode(hashlib.sha1(str.encode(str(key + self.GUID))).digest()) 30 31 handshake='HTTP/1.1 101 WebSocket Protocol Hybi-10\r\n\32Upgrade: WebSocket\r\n\33Connection: Upgrade\r\n\34Sec-WebSocket-Accept: %s\r\n\r\n' %(bytes.decode(token))35 36 self.transport.write(str.encode(str(handshake))) 37 self.handshake = True 38 print ('Socket %s Handshaken with %s success!' %(self.index, self.getId())) 39 #self.sendMessage('Welcome, ' + self.name + ' !') 40 else: 41 if len(data) <= 0: 42 return 43 44 #print 'Data before handle: ',data45 try:46 headerLength,codeLength = get_datalength(data)47 except Exception:48 print 'data error'49 return50 51 52 if len(data) - headerLength < codeLength :53 print 'Msg bad'54 return 55 else : 56 buffer_utf8 = parse_data(data) #解æåºUTF-8ç¼ç çæ°æ® 57 msg_unicode = str(buffer_utf8[:codeLength]).decode('utf-8', 'ignore') #解ç æunicode58 59 #print 'MsgData: %s' % (msg_unicode)60 self.processMessage(msg_unicode)61 62 remainData = data[headerLength+codeLength:]63 self.dataReceived(remainData)64 65 66 67 def getId(self):68 return str(self.transport.getPeer())69 70 def connectionMade(self):71 print "New connection from",self.getId()72 self.factory.addClient(self)73 74 def connectionLost(self, reason):75 print "connection lose"76 self.factory.delClient(self)77 78 def sendSingleMessage(self,msg):79 newMsg = processMessage(msg)80 self.transport.write(newMsg)81 82 def sendMessage(self,name,msg): 83 newMsg = processMessage(msg)84 #print "Send msg: %s" %(newMsg)85 self.factory.sendMsg(name,newMsg) #以UTF-8ç¼ç åéæ°æ®86 87 def sendToAll(self,msg):88 newMsg = processMessage(msg)89 #print "Send msg: %s" %(newMsg)90 self.factory.sendAll(newMsg)91 92 def sendToOther(self,name,msg): 93 newMsg = processMessage(msg)94 #print "Send msg: %s" %(newMsg)95 self.factory.sendToOther(name,newMsg)96 97 def sendToAllOther(self,name,msg):98 newMsg = processMessage(msg)99 #print "Send msg: %s" %(newMsg)100 self.factory.sendToAllOther(name,newMsg)101 102 def processMessage(self,msg):103 try:104 msgData = json.loads(msg)105 except Exception:106 print 'catch exception in json.loads(msg)'107 return108 109 if msgData['MsgType'] == msgType['Login']:110 result = messageHandle.processLogin(msgData['Data'])111 code = result[0]112 if code==1:113 self.clientName = msgData['Data']['Name']114 self.factory.addClientMap(msgData['Data']['Name'],self)115 116 returnMsg = json.dumps(result[1])117 self.sendSingleMessage(returnMsg)118 #self.sendMessage(msgData['Data']['Name'],returnMsg)119 elif msgData['MsgType'] == msgType['Account_Info']:120 code = messageHandle.processAccountInfo(msgData['Name'])121 returnMsg = json.dumps(code)122 self.sendMessage(msgData['Name'],returnMsg)123 elif msgData['MsgType'] == msgType['ChatSend']:124 result = messageHandle.processChatSend(msgData)125 code = result[0]126 if code:pass127 128 returnMsg = json.dumps(result[1])129 self.sendToOther(msgData['Receiver'],returnMsg)130 elif msgData['MsgType'] == msgType['StartSingleGame']:131 result = messageHandle.processStartSingleGame(self.factory,msgData)132 code = result[0]133 if code:pass134 135 returnMsg = json.dumps(result[1])136 enterPlayerMsg = json.dumps(result[2])137 self.sendMessage(msgData['AccountName'],returnMsg)138 self.sendToAllOther(msgData['AccountName'], enterPlayerMsg)139 elif msgData['MsgType'] == msgType['Move']:140 result = messageHandle.processPlayerMove(msgData)141 code = result[0]142 if code:pass143 144 returnMsg = json.dumps(result[1])145 self.sendToAllOther(msgData['AccountName'], returnMsg)146 elif msgData['MsgType'] == msgType['Divide']:147 result = messageHandle.processPlayerDivide(msgData)148 code = result[0]149 if code:pass150 151 returnMsg = json.dumps(result[1])152 self.sendToAllOther(msgData['AccountName'], returnMsg)153 elif msgData['MsgType'] == msgType['UpdatePosition']:154 result = messageHandle.processUpdatePlayer(self.factory, msgData)155 code = result[0]156 if code:157 returnMsg = json.dumps(result[1])158 self.sendToAllOther(msgData['AccountName'], returnMsg)159 elif msgData['MsgType'] == msgType['SpitSpore']:160 result = messageHandle.processSpitSpore(self.factory, msgData)161 code = result[0]162 if code:163 returnMsg = json.dumps(result[1])164 self.sendToAll(returnMsg)165 elif msgData['MsgType'] == msgType['PlayerConcentrate']:166 result = messageHandle.processPlayerConcentrate(msgData)167 code = result[0]168 if code:pass169 170 returnMsg = json.dumps(result[1])171 self.sendToAllOther(msgData['AccountName'], returnMsg)172 elif msgData['MsgType'] == msgType['UpdateSpore']:173 messageHandle.processUpdateSpore(self.factory, msgData)174 elif msgData['MsgType'] == msgType['EatPrick']:175 messageHandle.processEatPrick(self.factory, msgData)176 177 def serverSynMessage(self,msg):178 returnMsg = json.dumps(msg)179 self.sendMessage(self.clientName, returnMsg)180 181class GameServer(Factory):182 protocol = ClientHandle183 184 def __init__(self):185 self.clients = []186 self.clientMap = {}187 self.roomMap = {}188 self.roomSerialID = 0189 190 def addClient(self,newClient):191 self.clients.append(newClient)192 193 def delClient(self,client):194 self.clients.remove(client)195 if self.clientMap.has_key(client.clientName):196 self.clientMap.pop(client.clientName)197 198 def addClientMap(self,name,client):199 self.clientMap[name] = client200 201 def sendAll(self,message):202 for proto in self.clients:203 proto.transport.write(message)204 205 def sendToOther(self,name,message):206 if self.clientMap.has_key(name):207 self.clientMap[name].transport.write(message)208 209 def sendToAllOther(self,name,message):210 for key,client in self.clientMap.items():211 if key != name:212 client.transport.write(message)213 214 def sendMsg(self,name,message):215 if self.clientMap.has_key(name):216 self.clientMap[name].transport.write(message)217 218 def addRoom(self,type):219 self.roomMap[self.roomSerialID] = Room(self.roomSerialID,type,self)220 self.roomMap[self.roomSerialID].start()221 self.roomSerialID +=1222 return self.roomSerialID-1223 224 def removeRoom(self,roomID):225 self.roomMap.pop(roomID)226 227factory = GameServer() 228reactor.listenTCP(8766,factory) 229print "GameServer run..." 230reactor.run() 231 232 233 234 235 236 237 238 ...
tx_server.py
Source:tx_server.py
1#!/usr/bin/env python2from tx import *3# stdlib4import time5import signal6import hashlib7import binascii8# 3rd Party9import zmq10from bitcoin import SelectParams11###########################################################################12## SETTINGS13###########################################################################14LOCK_TIME = 615N_HASHES = 1516HASH_LEN = 2017TUMBLER_ADDRESS = "mzaMTvKBDiYoqkHaDz3w7AmHHETHEQKUiWs"18AMOUNT = 0.00119FEE = 0.000620MINE_FEE = 0.000121AMOUNT_FUND = AMOUNT + FEE22tx_o = TX(test=True)23# tx_o = TX()24###########################################################################25## HELPERS26###########################################################################27def error(n, e):28 return "Wrong number of arguments" + \29 "got %d expected %d" % (n, e)30def get_keys_from_tx(socket, msg):31 e = 232 if len(msg) != e:33 socket.send(error(len(msg), e))34 return35 keys = tx_o.get_keys_from_tx(msg[1], N_HASHES)36 serial_keys = tx_o.serialize_list(keys)37 socket.send(serial_keys)38 return39###########################################################################40## PREIMAGE41###########################################################################42def setup_preimage(socket, msg):43 e = 444 if len(msg) != e:45 socket.send(error(len(msg), e))46 return47 hashes = tx_o.get_hashes_from_serial(msg[3], N_HASHES,48 HASH_LEN)49 amount2 = AMOUNT + FEE50 result = tx_o.setup_preimage(msg[1], msg[2], hashes, amount2,51 LOCK_TIME)52 reply = [result[0], result[1], result[2], result[3]]53 socket.send_multipart(reply)54 return55def spend_preimage(socket, msg):56 e = 557 if len(msg) != e:58 socket.send(error(len(msg), e))59 return60 keys = tx_o.get_keys_from_serial(msg[1])61 tx = tx_o.spend_preimage(keys, msg[2], msg[3], msg[4])62 socket.send(tx)63 return64###########################################################################65## ESCROW66###########################################################################67def setup_escrow(socket, msg):68 e = 369 if len(msg) != e:70 socket.send(error(len(msg), e))71 return72 result = tx_o.setup_escrow(msg[1], msg[2], AMOUNT, LOCK_TIME)73 reply = [result[0], result[1], result[2], result[3]]74 socket.send_multipart(reply)75 return76def spend_escrow(socket, msg):77 e = 578 if len(msg) != e:79 socket.send(error(len(msg), e))80 return81 tx = tx_o.spend_escrow(msg[1], msg[2], msg[3], msg[4])82 socket.send(tx)83 return84def spend_escrow_with_address(socket, msg):85 e = 686 if len(msg) != e:87 socket.send(error(len(msg), e))88 return89 # 1 - payer_sig, 2 - redeemer_sig90 # 3 - address, 4 - redeem_script91 # 5 - funding_tx_id92 temp_tx, _ = tx_o.get_tx(msg[4], msg[3],93 AMOUNT - MINE_FEE, msg[5])94 tx = tx_o.spend_escrow(msg[1], msg[2], temp_tx, msg[4])95 socket.send(tx)96 return97###########################################################################98## GET TX99###########################################################################100def get_tx_with_address(socket, msg):101 e = 3102 if len(msg) != e:103 socket.send(error(len(msg), e))104 return105 address = get_btc_address()[0]106 _, sighash = tx_o.get_tx(msg[1], address,107 AMOUNT - MINE_FEE, msg[2])108 reply = [sighash, address]109 socket.send_multipart(reply)110 return111def get_tx_with_vout(socket, msg):112 e = 5113 if len(msg) != e:114 socket.send(error(len(msg), e))115 return116 _, sighash = tx_o.get_tx(msg[1], msg[2],117 AMOUNT - MINE_FEE, msg[3], vout=msg[4])118 reply = [sighash, address]119 socket.send_multipart(reply)120 return121def get_tx(socket, msg):122 e = 5123 if len(msg) != e:124 socket.send(error(len(msg), e))125 return126 if msg[4] == "preimage":127 amount = AMOUNT - (2 * MINE_FEE)128 print "PREIAMGE"129 else:130 amount = AMOUNT - MINE_FEE131 tx, sighash = tx_o.get_tx(msg[1], msg[2],132 amount, msg[3])133 reply = [tx, sighash]134 socket.send_multipart(reply)135###########################################################################136## REFUND137###########################################################################138def get_tx_refund(socket, msg):139 if len(msg) != 5:140 error = "Wrong number of arguments to %s, " + \141 "got %d expected 4" % (msg[0], len(msg))142 socket.send(error)143 print "Lock time is %d" % int(msg[4])144 # Check to see if it's preimage tx145 if len(msg[1]) > 300:146 amount = AMOUNT - (2 * MINE_FEE)147 else:148 amount = AMOUNT - MINE_FEE149 tx, sighash = tx_o.get_tx(msg[1], msg[2],150 amount, msg[3],151 lock_time=int(msg[4]))152 reply = [tx, sighash]153 socket.send_multipart(reply)154 return155def get_refund_tx_with_vout(socket, msg):156 e = 6157 if len(msg) != e:158 socket.send(error(len(msg), e))159 return160 tx, sighash = tx_o.get_tx(msg[1], msg[2],161 amount, msg[3],162 lock_time=int(msg[4]), vout=msg[5])163 reply = [tx, sighash]164 socket.send_multipart(reply)165 return166def send_refund_tx(socket, msg):167 e = 4168 if len(msg) != e:169 socket.send(error(len(msg), e))170 return171 tx = tx_o.refund_tx(msg[1], msg[2], msg[3])172 socket.send(tx)173 return174###########################################################################175## MAIN176###########################################################################177options = {178 "setup_preimage": setup_preimage,179 "spend_preimage": spend_preimage,180 "setup_escrow": setup_escrow,181 "spend_escrow": spend_escrow,182 "spend_escrow_with_address": spend_escrow_with_address,183 "get_tx_with_address": get_tx_with_address,184 "get_tx": get_tx,185 "get_tx_refund": get_tx_refund,186 "send_refund_tx": send_refund_tx,187 "get_keys_from_tx": get_keys_from_tx,188 "get_refund_tx_with_vout": get_refund_tx_with_vout,189 "get_tx_with_vout": get_tx_with_vout190}191def main():192 SelectParams('testnet')193 context = zmq.Context()194 socket = context.socket(zmq.REP)195 socket.bind("ipc:///tmp/TumbleBit_tx")196 try:197 while True:198 msg = socket.recv_multipart()199 # print "Received message %s" % msg200 if msg[0] in options:201 print "Entering -> %s" % msg[0]202 options[msg[0]](socket, msg)203 print "Exiting -> %s" % msg[0]204 else:205 # printf206 socket.send(b"METHOD NOT AVAILABLE")207 except KeyboardInterrupt:208 print "Interrupt received. Stoping ...."209 finally:210 # Clean up211 socket.close()212 context.term()213if __name__ == "__main__":...
barebones_notifications.js
Source:barebones_notifications.js
1function TopNotification( msg ) {2 AddNotification(msg, $('#TopNotifications'));3}45function BottomNotification(msg) {6 AddNotification(msg, $('#BottomNotifications'));7}89function TopRemoveNotification(msg){10 RemoveNotification(msg, $('#TopNotifications'));11}1213function BottomRemoveNotification(msg){14 RemoveNotification(msg, $('#BottomNotifications'));15}161718function RemoveNotification(msg, panel){19 var count = msg.count;20 if (count > 0 && panel.GetChildCount() > 0){21 var start = panel.GetChildCount() - count;22 if (start < 0)23 start = 0;2425 for (i=start;i<panel.GetChildCount(); i++){26 var lastPanel = panel.GetChild(i);27 //lastPanel.SetAttributeInt("deleted", 1);28 lastPanel.deleted = true;29 lastPanel.DeleteAsync(0);30 }31 }32}3334function AddNotification(msg, panel) {35 var newNotification = true;36 var lastNotification = panel.GetChild(panel.GetChildCount() - 1)37 //$.Msg(msg)3839 msg.continue = msg.continue || false;40 //msg.continue = true;4142 if (lastNotification != null && msg.continue) 43 newNotification = false;4445 if (newNotification){46 lastNotification = $.CreatePanel('Panel', panel, '');47 lastNotification.AddClass('NotificationLine')48 lastNotification.hittest = false;49 }5051 var notification = null;52 53 if (msg.hero != null)54 notification = $.CreatePanel('DOTAHeroImage', lastNotification, '');55 else if (msg.image != null)56 notification = $.CreatePanel('Image', lastNotification, '');57 else if (msg.ability != null)58 notification = $.CreatePanel('DOTAAbilityImage', lastNotification, '');59 else if (msg.item != null)60 notification = $.CreatePanel('DOTAItemImage', lastNotification, '');61 else62 notification = $.CreatePanel('Label', lastNotification, '');6364 if (typeof(msg.duration) != "number"){65 //$.Msg("[Notifications] Notification Duration is not a number!");66 msg.duration = 367 }68 69 if (newNotification){70 $.Schedule(msg.duration, function(){71 //$.Msg('callback')72 if (lastNotification.deleted)73 return;74 75 lastNotification.DeleteAsync(0);76 });77 }7879 if (msg.hero != null){80 notification.heroimagestyle = msg.imagestyle || "icon";81 notification.heroname = msg.hero82 notification.hittest = false;83 } else if (msg.image != null){84 notification.SetImage(msg.image);85 notification.hittest = false;86 } else if (msg.ability != null){87 notification.abilityname = msg.ability88 notification.hittest = false;89 } else if (msg.item != null){90 notification.itemname = msg.item91 notification.hittest = false;92 } else{93 notification.html = true;94 var text = msg.text || "No Text provided";95 notification.text = $.Localize(text)96 notification.hittest = false;97 notification.AddClass('TitleText');98 }99 100 if (msg.class)101 notification.AddClass(msg.class);102 else103 notification.AddClass('NotificationMessage');104105 if (msg.style){106 for (var key in msg.style){107 var value = msg.style[key]108 notification.style[key] = value;109 }110 }111}112113114(function () {115 GameEvents.Subscribe( "top_notification", TopNotification );116 GameEvents.Subscribe( "bottom_notification", BottomNotification );117 GameEvents.Subscribe( "top_remove_notification", TopRemoveNotification );118 GameEvents.Subscribe( "bottom_remove_notification", BottomRemoveNotification );
...
Using AI Code Generation
1var wpt = require('webpagetest');2wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log(data);5 wpt.getTestResults(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 console.log(data);8 });9});10var wpt = require('webpagetest');11wpt = new WebPageTest('www.webpagetest.org');12 if (err) return console.error(err);13 console.log(data);14 wpt.getTestResults(data.data.testId, function(err, data) {15 if (err) return console.error(err);16 console.log(data);17 });18});19var wpt = require('webpagetest');20wpt = new WebPageTest('www.webpagetest.org');21 if (err) return console.error(err);22 console.log(data);23 wpt.getTestResults(data.data.testId, function(err, data) {24 if (err) return console.error(err);25 console.log(data);26 });27});28var wpt = require('webpagetest');29wpt = new WebPageTest('www.webpagetest.org');30 if (err) return console.error(err);31 console.log(data);32 wpt.getTestResults(data.data.testId, function(err, data) {33 if (err) return console.error(err);34 console.log(data);35 });36});37var wpt = require('webpagetest');38wpt = new WebPageTest('www.webpagetest.org');39 if (err) return console.error(err);40 console.log(data);41 wpt.getTestResults(data.data.test
Using AI Code Generation
1var wpt = require('wpt');2var msg = wpt.msg;3msg.info('this is a test message');4msg.warn('this is a test message');5msg.error('this is a test message');6msg.debug('this is a test message');7var wpt = require('wpt');8var msg = wpt.msg;9msg.info('this is a test message');10msg.warn('this is a test message');11msg.error('this is a test message');12msg.debug('this is a test message');13var wpt = require('wpt');14var msg = wpt.msg;15msg.info('this is a test message');16msg.warn('this is a test message');17msg.error('this is a test message');18msg.debug('this is a test message');19var wpt = require('wpt');20var msg = wpt.msg;21msg.info('this is a test message');22msg.warn('this is a test message');23msg.error('this is a test message');24msg.debug('this is a test message');25var wpt = require('wpt');26var msg = wpt.msg;27msg.info('this is a test message');28msg.warn('this is a test message');29msg.error('this is a test message');30msg.debug('this is a test message');31var wpt = require('wpt');32var msg = wpt.msg;33msg.info('this is a test message');34msg.warn('this is a test message');35msg.error('this is a test message');36msg.debug('this is a test message');37var wpt = require('wpt');38var msg = wpt.msg;39msg.info('this is a test message');40msg.warn('this is a test message');41msg.error('this is a test message');42msg.debug('this is a test message');43var wpt = require('wpt');44var msg = wpt.msg;45msg.info('this is a test message');46msg.warn('this is a test message');47msg.error('this is a test message');48msg.debug('this is a test message');
Using AI Code Generation
1msg = wpt.msg("hello world");2console.log(msg);3msg = wpt.msg("hello world");4console.log(msg);5msg = wpt.msg("hello world");6console.log(msg);7msg = wpt.msg("hello world");8console.log(msg);9msg = wpt.msg("hello world");10console.log(msg);11msg = wpt.msg("hello world");12console.log(msg);13msg = wpt.msg("hello world");14console.log(msg);15msg = wpt.msg("hello world");16console.log(msg);17msg = wpt.msg("hello world");18console.log(msg);19msg = wpt.msg("hello world");20console.log(msg);21msg = wpt.msg("hello world");22console.log(msg);23msg = wpt.msg("hello world");24console.log(msg);25msg = wpt.msg("hello world");26console.log(msg);27msg = wpt.msg("hello world");28console.log(msg);29msg = wpt.msg("hello world");30console.log(msg);31msg = wpt.msg("hello world");32console.log(msg);33msg = wpt.msg("hello world");34console.log(msg);
Using AI Code Generation
1var wpt = require('./wpt.js');2wpt.msg("hello world");3exports.msg = function(msg) {4 console.log(msg);5}6var wpt = require('./wpt.js');7wpt.msg("hello world");8exports.msg = function(msg) {9 console.log(msg);10}11exports.myFunction = function() {12 console.log('myFunction was called');13}14node -e "require('./module.js').myFunction()"15node -e "require('./module.js').myFunction"16var wpt = require('./wpt.js');17wpt.msg("hello world");18exports.msg = function(msg) {19 console.log(msg);20}
Using AI Code Generation
1var wpt = require('webpagetest');2var msg = wpt.msg;3var log = wpt.log;4msg('hello world');5log('hello world');6var wpt = require('webpagetest');7var msg = wpt.msg;8var log = wpt.log;9msg('hello world');10log('hello world');11var wpt = require('webpagetest');12var msg = wpt.msg;13var log = wpt.log;14msg('hello world');15log('hello world');16var wpt = require('webpagetest');17var msg = wpt.msg;18var log = wpt.log;19msg('hello world');20log('hello world');21var wpt = require('webpagetest');22var msg = wpt.msg;23var log = wpt.log;24msg('hello world');25log('hello world');26var wpt = require('webpagetest');27var msg = wpt.msg;28var log = wpt.log;29msg('hello world');30log('hello world');31var wpt = require('webpagetest');32var msg = wpt.msg;33var log = wpt.log;34msg('hello world');35log('hello world');36var wpt = require('webpagetest');37var msg = wpt.msg;38var log = wpt.log;39msg('hello world');40log('hello world');41var wpt = require('webpagetest');
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!