Skip to content

Commit

Permalink
Update (#77)
Browse files Browse the repository at this point in the history
* .

* Update bot.py

* Update bot.py

* 1

* 1
  • Loading branch information
MrIbrahem authored Oct 29, 2024
1 parent dc475e6 commit 65df1c1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
2 changes: 2 additions & 0 deletions botEdit.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ def bot_May_Edit(text='', title_page='', botjob='all'):
# {{nobots}} منع جميع البوتات
# منع جميع البوتات
if not params:
printe.output(f'<<lightred>> botEdit.py: the page has temp:({_template}), botjob:{botjob} skipp.')
# pywikibot.output( 'return False 2 ' )
Bot_Cash[botjob][title_page] = False
return False
elif params.get('1'):
List = [x.strip() for x in params.get('1', '').split(',')]
# if 'all' in List or pywikibot.calledModuleName() in List or edit_username[1] in List:
if 'all' in List or edit_username[1] in List:
printe.output(f'<<lightred>> botEdit.py: the page has temp:({_template}), botjob:{botjob} skipp.')
# pywikibot.output( 'return False 3 ' )
Bot_Cash[title_page] = False
return False
Expand Down
15 changes: 14 additions & 1 deletion super/bot_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,20 @@

User_tables = {}

change_codes = {"nb": "no", "bat_smg": "bat-smg", "be_x_old": "be-tarask", "be-x-old": "be-tarask", "cbk_zam": "cbk-zam", "fiu_vro": "fiu-vro", "map_bms": "map-bms", "nds_nl": "nds-nl", "roa_rup": "roa-rup", "zh_classical": "zh-classical", "zh_min_nan": "zh-min-nan", "zh_yue": "zh-yue"}
change_codes = {
"bat_smg": "bat-smg",
"be-x-old": "be-tarask",
"be_x_old": "be-tarask",
"cbk_zam": "cbk-zam",
"fiu_vro": "fiu-vro",
"map_bms": "map-bms",
"nb": "no",
"nds_nl": "nds-nl",
"roa_rup": "roa-rup",
"zh_classical": "zh-classical",
"zh_min_nan": "zh-min-nan",
"zh_yue": "zh-yue",
}


def test_print(s):
Expand Down
10 changes: 5 additions & 5 deletions super/login_bots/bot_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __initialize_connection(self):
self.jar_cookie.load(ignore_discard=True, ignore_expires=True)
self.connection.cookies = self.jar_cookie # Tell Requests session to use the cookiejar.
except Exception as e:
printe.error("Could not load cookies: %s" % e)
printe.output("Could not load cookies: %s" % e)

def __initialize_site(self):
self.domain = f"{self.lang}.{self.family}.org"
Expand All @@ -87,15 +87,15 @@ def __initialize_site(self):
try:
self.site_mwclient = Site(self.domain, clients_useragent=self.user_agent, pool=self.connection, force_login=self.force_login)
except Exception as e:
printe.error(f"Could not connect to ({self.domain}): %s" % e)
printe.output(f"Could not connect to ({self.domain}): %s" % e)
return False

def do_login(self):
if not self.force_login:
return

if not self.site_mwclient:
printe.error(f"no self.ssite_mwclient to ({self.domain})")
printe.output(f"no self.ssite_mwclient to ({self.domain})")
return

if not self.site_mwclient.logged_in:
Expand All @@ -104,7 +104,7 @@ def do_login(self):
try:
self.site_mwclient.login(username=self.username, password=self.password)
except Exception as e:
printe.error(f"Could not login to ({self.domain}): %s" % e)
printe.output(f"Could not login to ({self.domain}): %s" % e)

if self.site_mwclient.logged_in:
printe.output(f"<<purple>>logged in as {self.site_mwclient.username} to ({self.domain})")
Expand Down Expand Up @@ -162,7 +162,7 @@ def make_new_r3_token(self) -> str:
try:
csrftoken = self.site_mwclient.get_token("csrf")
except Exception as e:
printe.error("Could not get token: %s" % e)
printe.output("Could not get token: %s" % e)
return False
# ---
return csrftoken
Expand Down
4 changes: 2 additions & 2 deletions super/super_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@
Save_Edit_Pages = {1: False}
# ---
change_codes = {
"nb": "no",
"bat_smg": "bat-smg",
"be_x_old": "be-tarask",
"be-x-old": "be-tarask",
"be_x_old": "be-tarask",
"cbk_zam": "cbk-zam",
"fiu_vro": "fiu-vro",
"map_bms": "map-bms",
"nb": "no",
"nds_nl": "nds-nl",
"roa_rup": "roa-rup",
"zh_classical": "zh-classical",
Expand Down
3 changes: 2 additions & 1 deletion wd_sparql.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def get_query_data(query):
try:
data = sparql.query().convert()
except Exception as e:
exception_err(e, text=f"API/tools.py quoteurl: Exception: {e}")
# exception_err(e, text=f"API/tools.py quoteurl: Exception: {e}")
print("API/tools.py get_query_data: Exception: e" )
# ---
return data

Expand Down

0 comments on commit 65df1c1

Please sign in to comment.