Skip to content

Commit 915af61

Browse files
committed
添加自动打开二维码
1 parent 456c53d commit 915af61

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

wxbot.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import re
1111
import random
1212
from requests.exceptions import *
13+
import os,subprocess,sys
1314

1415

1516
class WXBot:
@@ -565,6 +566,13 @@ def gen_qr_code(self, qr_file_path):
565566
qr = pyqrcode.create(string)
566567
if self.conf['qr'] == 'png':
567568
qr.png(qr_file_path)
569+
if sys.platform.find('darwin') >= 0:
570+
subprocess.call(['open', qr_file_path])
571+
elif sys.platform.find('linux') >= 0:
572+
subprocess.call(['xdg-open', qr_file_path])
573+
else:
574+
os.startfile(qr_file_path)
575+
568576
elif self.conf['qr'] == 'tty':
569577
print(qr.terminal(quiet_zone=1))
570578

0 commit comments

Comments
 (0)